4.4 KiB
Contributing to Slither
First, thanks for your interest in contributing to Slither! We welcome and appreciate all contributions, including bug reports, feature suggestions, tutorials/blog posts, and code improvements.
If you're unsure where to start, we recommend our good first issue
and help wanted
issue labels.
Bug reports and feature suggestions
Bug reports and feature suggestions can be submitted to our issue tracker. For bug reports, attaching the contract that caused the bug will help us in debugging and resolving the issue quickly. If you find a security vulnerability, do not open an issue; email opensource@trailofbits.com instead.
Questions
Questions can be submitted to the issue tracker, but you may get a faster response if you ask in our chat room (in the #ethereum channel).
Code
Slither uses the pull request contribution model. Please make an account on Github, fork this repo, and submit code contributions via pull request. For more documentation, look here.
Some pull request guidelines:
- Work from the
dev
branch. We performed extensive tests prior to merging anything tomaster
, working fromdev
will allow us to merge your work faster. - Minimize irrelevant changes (formatting, whitespace, etc) to code that would otherwise not be touched by this patch. Save formatting or style corrections for a separate pull request that does not make any semantic changes.
- When possible, large changes should be split up into smaller focused pull requests.
- Fill out the pull request description with a summary of what your patch does, key changes that have been made, and any further points of discussion, if applicable.
- Title your pull request with a brief description of what it's changing. "Fixes #123" is a good comment to add to the description, but makes for an unclear title on its own.
Development Environment
Instructions for installing a development version of Slither can be found in our wiki.
To run the unit tests, you need clone this repository and run pip install ".[dev]"
.
Linters
Several linters and security checkers are run on the PRs.
To run them locally in the root dir of the repository:
pylint slither tests --rcfile pyproject.toml
black . --config pyproject.toml
We use pylint 2.13.4
, black 22.3.0
.
Detectors tests
For each new detector, at least one regression tests must be present.
- Create a test in
tests
- Update
ALL_TEST
intests/test_detectors.py
- Run
python ./tests/test_detectors.py --generate
. This will generate the json artifacts intests/expected_json
. Add the generated files to git. - Run
pytest ./tests/test_detectors.py
and check that everything worked.
To see the tests coverage, run pytest tests/test_detectors.py --cov=slither/detectors --cov-branch --cov-report html
Parser tests
- Create a test in
tests/ast-parsing
- Run
python ./tests/test_ast_parsing.py --compile
. This will compile the artifact intests/compile
. Add the compiled artifact to git. - Run
python ./tests/test_ast_parsing.py --generate
. This will generate the json artifacts intests/expected_json
. Add the generated files to git. - Run
pytest ./tests/test_ast_parsing.py
and check that everything worked.
To see the tests coverage, run pytest tests/test_ast_parsing.py --cov=slither/solc_parsing --cov-branch --cov-report html
Synchronization with crytic-compile
By default, slither
follows either the latest version of crytic-compile in pip, or crytic-compile@master
(look for dependencies in setup.py
. If crytic-compile development comes with breaking changes, the process to update slither
is:
- Update
slither/setup.py
to point to the related crytic-compile's branch - Create a PR in
slither
and ensure it passes the CI - Once the development branch is merged in
crytic-compile@master
, ensureslither
follows themaster
branch
The slither
's PR can either be merged while using a crytic-compile non-master
branch, or kept open until the breaking changes are available in crytic-compile@master
.