Git Product home page Git Product logo

woke-pdm's Introduction

Woke

Woke is a static analyzer and symbolic execution engine for Solidity.

Contributing

Creating a virtual environment

We recommend creating a virtual environment inside of the woke subdirectory; we have encountered problems when creating it in the root directory.

$ cd woke
$ mkvirtualenv woke

Using venv:

$ python3 -m venv env
$ source env/bin/activate

Installation

$ cd woke
$ pip install -e ".[tests,dev]"

Pyright, our static type checker, is distributed through npm:

$ npm i -g pyright

Git hooks

For Unix-like platforms, we provide a script that will set-up git hooks.

After cloning, execute.

$ chmod +x ./setup-githooks.sh
$ ./setup-githooks.sh

woke-pdm's People

Contributors

bemic avatar hacker-dom avatar michprev avatar

Watchers

 avatar  avatar  avatar

woke-pdm's Issues

Implement `ipdb` package functionalities

Implement ipdb package functionalities

This function relies on ipdb internal functions

We could implement all the ipdb functionalities ourselves (it is rather small codebase)

https://github.com/hacker-DOM/woke/blob/3a5d85aca8ceb54b6f669d21cbfdb1017bfd8ad7/woke/woke/m_fuzz/fuzzer.py#L43

    rpc.launch(cmd, **cmd_settings)


def _attach_debugger() -> None:
    # TODO Implement `ipdb` package functionalities
    # This function relies on `ipdb` internal functions
    # We could implement all the `ipdb` functionalities ourselves (it is rather small codebase)
    if sys.excepthook != BdbQuit_excepthook:
        BdbQuit_excepthook.excepthook_ori = sys.excepthook
        sys.excepthook = BdbQuit_excepthook
    p = _init_pdb(
        commands=["import IPython", "alias embed() IPython.embed(colors='neutral')"]
    )
    p.reset()
    p.interaction(None, sys.exc_info()[2])


def _run_core(
    fuzz_test: Callable,
    index: int,
    port: int,
    random_seed: bytes,
    finished_event: multiprocessing.synchronize.Event,
    child_conn: multiprocessing.connection.Connection,
):
    print(f"Using seed '{random_seed.hex()}' for process #{index}")
    _setup(port)

    project = brownie.project.load()

    brownie.chain.reset()

    args = []
    for arg in inspect.getfullargspec(fuzz_test).args:
        if arg in {"a", "accounts"}:
            args.append(brownie.accounts)
        elif arg == "chain":
            args.append(brownie.chain)
        elif arg == "Contract":
            args.append(brownie.Contract)
        elif arg == "history":
            args.append(brownie.history)
        elif arg == "interface":
            args.append(project.interface)
        elif arg == "rpc":
            args.append(brownie.rpc)
        elif arg == "web3":
            args.append(brownie.web3)
        elif arg in project.keys():
            args.append(project[arg])
        else:
            raise ValueError(
                f"Unable to set value for '{arg}' argument in '{fuzz_test.__name__}' function."
            )
    fuzz_test(*args)

    child_conn.send(None)
    finished_event.set()


def _run(
    fuzz_test: Callable,
    index: int,
    port: int,
    random_seed: bytes,
    log_file: Path,
    tee: bool,
    finished_event: multiprocessing.synchronize.Event,
    child_conn: multiprocessing.connection.Connection,
):
    pickling_support.install()
    random.seed(random_seed)

    if not tee:
        logging.basicConfig(filename=log_file)

    try:
        if tee:
            with closing(Tee(log_file)):
                _run_core(
                    fuzz_test, index, port, random_seed, finished_event, child_conn
                )
        else:
            with log_file.open("w") as f, redirect_stdout(f), redirect_stderr(f):
                _run_core(
                    fuzz_test, index, port, random_seed, finished_event, child_conn
                )
    except Exception:
        child_conn.send(pickle.dumps(sys.exc_info()))
        finished_event.set()

        try:
            attach: bool = child_conn.recv()
            if attach:
                sys.stdin = os.fdopen(0)
                _attach_debugger()
        finally:
            finished_event.set()
    finally:
        with log_file.open("a") as f, redirect_stdout(f), redirect_stderr(f):
            rpc.kill()


def fuzz(
    config: WokeConfig,
    fuzz_test: types.FunctionType,
    process_count: int,
    seeds: Iterable[bytes],
    logs_dir: Path,
    passive: bool,
):
    random_seeds = list(seeds)
    if len(random_seeds) < process_count:
        for i in range(process_count - len(random_seeds)):

82adbf3c5742eef474d8de7534a2d14e9947f34b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.