mirror of https://github.com/crytic/slither
commit
8fba6ba0e5
@ -1,24 +1,37 @@ |
|||||||
# Contributing to Slither |
# 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. |
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`](https://github.com/crytic/slither/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) and [`help wanted`](https://github.com/crytic/slither/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) issue labels. |
If you're unsure where to start, we recommend our [`good first issue`](https://github.com/crytic/slither/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) and [`help wanted`](https://github.com/crytic/slither/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) issue labels. |
||||||
|
|
||||||
# Bug reports and feature suggestions |
## 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. |
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 |
||||||
Questions can be submitted to the issue tracker, but you may get a faster response if you ask in our [chat room](https://empireslacking.herokuapp.com/) (in the #ethereum channel). |
Questions can be submitted to the issue tracker, but you may get a faster response if you ask in our [chat room](https://empireslacking.herokuapp.com/) (in the #ethereum channel). |
||||||
|
|
||||||
# Code |
## 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](https://guides.github.com/activities/forking/). |
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](https://guides.github.com/activities/forking/). |
||||||
|
|
||||||
Some pull request guidelines: |
Some pull request guidelines: |
||||||
|
|
||||||
- Work from the [`dev`](https://github.com/crytic/slither/tree/dev) branch. We performed extensive tests prior to merging anything to `master`, working from `dev` will allow us to merge your work faster. |
- Work from the [`dev`](https://github.com/crytic/slither/tree/dev) branch. We performed extensive tests prior to merging anything to `master`, working from `dev` 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. |
- 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. |
- 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. |
- 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. |
- 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 |
## Development Environment |
||||||
Instructions for installing a development version of Slither can be found in our [wiki](https://github.com/crytic/slither/wiki/Developer-installation). |
Instructions for installing a development version of Slither can be found in our [wiki](https://github.com/crytic/slither/wiki/Developer-installation). |
||||||
|
|
||||||
|
## Detectors regression tests |
||||||
|
|
||||||
|
For each new detector, at least one regression tests must be present. |
||||||
|
To generate the following scripts, you must have [`solc-select`](https://github.com/crytic/solc-select) installed. |
||||||
|
|
||||||
|
- Create a test in `tests` |
||||||
|
- Update `script/ci_test_detectors_[solc_version].sh`, and add `generate_expected_json tests/YOUR_FILENAME.sol "DETECTOR_NAME"`. Be sure that all the other lines are commented (otherwise you will regenerate the tests for all the detectores) |
||||||
|
- Run `./script/ci_test_detectors_[solc_version].sh`. This will generate the json artifacts in `tests/expected_json`. Add the generated files to git. |
||||||
|
- Update `scripts/ci_test_detectors_[solc_version].sh` with your new tests. |
||||||
|
- Run `scripts/ci_test_detectors_[solc_version].sh` and check that everything worked. |
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@ |
|||||||
|
[tool.black] |
||||||
|
target-version = ["py36"] |
||||||
|
line-length = 100 |
||||||
|
[tool.pylint.messages_control] |
||||||
|
disable = """ |
||||||
|
C0116,C0114 |
||||||
|
""" |
@ -0,0 +1,28 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
source "$(dirname "$0")""/ci_test.sh" |
||||||
|
|
||||||
|
solc use "0.5.1" |
||||||
|
|
||||||
|
# Be sure that only one of the following line is uncommented before running the script |
||||||
|
|
||||||
|
# generate_expected_json tests/void-cst.sol "void-cst" |
||||||
|
# generate_expected_json tests/solc_version_incorrect_05.ast.json "solc-version" |
||||||
|
# generate_expected_json tests/uninitialized-0.5.1.sol "uninitialized-state" |
||||||
|
# generate_expected_json tests/backdoor.sol "backdoor" |
||||||
|
# generate_expected_json tests/backdoor.sol "suicidal" |
||||||
|
# generate_expected_json tests/old_solc.sol.json "solc-version" |
||||||
|
# generate_expected_json tests/reentrancy-0.5.1.sol "reentrancy-eth" |
||||||
|
# generate_expected_json tests/reentrancy-0.5.1-events.sol "reentrancy-events" |
||||||
|
# generate_expected_json tests/tx_origin-0.5.1.sol "tx-origin" |
||||||
|
# generate_expected_json tests/locked_ether-0.5.1.sol "locked-ether" |
||||||
|
# generate_expected_json tests/arbitrary_send-0.5.1.sol "arbitrary-send" |
||||||
|
# generate_expected_json tests/inline_assembly_contract-0.5.1.sol "assembly" |
||||||
|
# generate_expected_json tests/inline_assembly_library-0.5.1.sol "assembly" |
||||||
|
# generate_expected_json tests/constant-0.5.1.sol "constant-function-asm" |
||||||
|
# generate_expected_json tests/constant-0.5.1.sol "constant-function-state" |
||||||
|
# generate_expected_json tests/incorrect_equality.sol "incorrect-equality" |
||||||
|
# generate_expected_json tests/too_many_digits.sol "too-many-digits" |
||||||
|
# generate_expected_json tests/unchecked_lowlevel-0.5.1.sol "unchecked-lowlevel" |
||||||
|
# generate_expected_json tests/unchecked_send-0.5.1.sol "unchecked-send" |
||||||
|
|
@ -0,0 +1,11 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
source "$(dirname "$0")""/ci_test.sh" |
||||||
|
|
||||||
|
solc use "0.6.11" |
||||||
|
|
||||||
|
# Be sure that only one of the following line is uncommented before running the script |
||||||
|
|
||||||
|
|
||||||
|
#generate_expected_json tests/filename.sol "detector_name" |
||||||
|
|
@ -0,0 +1,11 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
source "$(dirname "$0")""/ci_test.sh" |
||||||
|
|
||||||
|
solc use "0.7.0" |
||||||
|
|
||||||
|
# Be sure that only one of the following line is uncommented before running the script |
||||||
|
|
||||||
|
|
||||||
|
#generate_expected_json tests/filename.sol "detector_name" |
||||||
|
|
@ -0,0 +1,86 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
### Test Detectors |
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "$0")" && pwd)" |
||||||
|
|
||||||
|
CURRENT_PATH=$(pwd) |
||||||
|
TRAVIS_PATH='/home/travis/build/crytic/slither' |
||||||
|
|
||||||
|
# test_slither file.sol detectors |
||||||
|
test_slither(){ |
||||||
|
|
||||||
|
expected="$DIR/../tests/expected_json/$(basename "$1" .sol).$2.json" |
||||||
|
|
||||||
|
# run slither detector on input file and save output as json |
||||||
|
slither "$1" --solc-disable-warnings --detect "$2" --json "$DIR/tmp-test.json" |
||||||
|
if [ $? -eq 255 ] |
||||||
|
then |
||||||
|
echo "Slither crashed" |
||||||
|
exit 255 |
||||||
|
fi |
||||||
|
|
||||||
|
if [ ! -f "$DIR/tmp-test.json" ]; then |
||||||
|
echo "" |
||||||
|
echo "Missing generated file" |
||||||
|
echo "" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$DIR/tmp-test.json" -i |
||||||
|
result=$(python "$DIR/json_diff.py" "$expected" "$DIR/tmp-test.json") |
||||||
|
|
||||||
|
rm "$DIR/tmp-test.json" |
||||||
|
if [ "$result" != "{}" ]; then |
||||||
|
echo "" |
||||||
|
echo "failed test of file: $1, detector: $2" |
||||||
|
echo "" |
||||||
|
echo "$result" |
||||||
|
echo "" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
# run slither detector on input file and save output as json |
||||||
|
slither "$1" --solc-disable-warnings --detect "$2" --legacy-ast --json "$DIR/tmp-test.json" |
||||||
|
if [ $? -eq 255 ] |
||||||
|
then |
||||||
|
echo "Slither crashed" |
||||||
|
exit 255 |
||||||
|
fi |
||||||
|
|
||||||
|
if [ ! -f "$DIR/tmp-test.json" ]; then |
||||||
|
echo "" |
||||||
|
echo "Missing generated file" |
||||||
|
echo "" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$DIR/tmp-test.json" -i |
||||||
|
result=$(python "$DIR/json_diff.py" "$expected" "$DIR/tmp-test.json") |
||||||
|
|
||||||
|
rm "$DIR/tmp-test.json" |
||||||
|
if [ "$result" != "{}" ]; then |
||||||
|
echo "" |
||||||
|
echo "failed test of file: $1, detector: $2" |
||||||
|
echo "" |
||||||
|
echo "$result" |
||||||
|
echo "" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
# generate_expected_json file.sol detectors |
||||||
|
generate_expected_json(){ |
||||||
|
# generate output filename |
||||||
|
# e.g. file: uninitialized.sol detector: uninitialized-state |
||||||
|
# ---> uninitialized.uninitialized-state.json |
||||||
|
output_filename="$DIR/../tests/expected_json/$(basename "$1" .sol).$2.json" |
||||||
|
output_filename_txt="$DIR/../tests/expected_json/$(basename "$1" .sol).$2.txt" |
||||||
|
|
||||||
|
# run slither detector on input file and save output as json |
||||||
|
slither "$1" --solc-disable-warnings --detect "$2" --json "$output_filename" > "$output_filename_txt" 2>&1 |
||||||
|
|
||||||
|
|
||||||
|
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$output_filename" -i |
||||||
|
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$output_filename_txt" -i |
||||||
|
} |
||||||
|
|
@ -0,0 +1,18 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
### Test |
||||||
|
|
||||||
|
if ! slither "tests/*.json" --solc-ast --ignore-return-value; then |
||||||
|
echo "--solc-ast failed" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
if ! slither "tests/*0.5*.sol" --solc-disable-warnings --ignore-return-value; then |
||||||
|
echo "--solc-disable-warnings failed" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
if ! slither "tests/*0.5*.sol" --disable-color --ignore-return-value; then |
||||||
|
echo "--disable-color failed" |
||||||
|
exit 1 |
||||||
|
fi |
@ -0,0 +1,9 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
### Test data dependecy |
||||||
|
|
||||||
|
if ! python ./examples/scripts/data_dependency.py ./examples/scripts/data_dependency.sol; then |
||||||
|
echo "data dependency failed" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
exit 0 |
@ -0,0 +1,51 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
source "$(dirname "$0")""/ci_test.sh" |
||||||
|
|
||||||
|
solc use "0.5.1" |
||||||
|
|
||||||
|
test_slither tests/void-cst.sol "void-cst" |
||||||
|
test_slither tests/solc_version_incorrect_05.ast.json "solc-version" |
||||||
|
test_slither tests/unchecked_lowlevel-0.5.1.sol "unchecked-lowlevel" |
||||||
|
test_slither tests/unchecked_send-0.5.1.sol "unchecked-send" |
||||||
|
test_slither tests/uninitialized-0.5.1.sol "uninitialized-state" |
||||||
|
test_slither tests/backdoor.sol "backdoor" |
||||||
|
test_slither tests/backdoor.sol "suicidal" |
||||||
|
test_slither tests/old_solc.sol.json "solc-version" |
||||||
|
test_slither tests/reentrancy-0.5.1.sol "reentrancy-eth" |
||||||
|
test_slither tests/reentrancy-0.5.1-events.sol "reentrancy-events" |
||||||
|
test_slither tests/tx_origin-0.5.1.sol "tx-origin" |
||||||
|
test_slither tests/unused_state.sol "unused-state" |
||||||
|
test_slither tests/locked_ether-0.5.1.sol "locked-ether" |
||||||
|
test_slither tests/arbitrary_send-0.5.1.sol "arbitrary-send" |
||||||
|
test_slither tests/inline_assembly_contract-0.5.1.sol "assembly" |
||||||
|
test_slither tests/inline_assembly_library-0.5.1.sol "assembly" |
||||||
|
test_slither tests/low_level_calls.sol "low-level-calls" |
||||||
|
test_slither tests/const_state_variables.sol "constable-states" |
||||||
|
test_slither tests/external_function.sol "external-function" |
||||||
|
test_slither tests/external_function_2.sol "external-function" |
||||||
|
test_slither tests/naming_convention.sol "naming-convention" |
||||||
|
#test_slither tests/complex_func.sol "complex-function" |
||||||
|
test_slither tests/controlled_delegatecall.sol "controlled-delegatecall" |
||||||
|
test_slither tests/constant-0.5.1.sol "constant-function-asm" |
||||||
|
test_slither tests/constant-0.5.1.sol "constant-function-state" |
||||||
|
test_slither tests/unused_return.sol "unused-return" |
||||||
|
test_slither tests/timestamp.sol "timestamp" |
||||||
|
test_slither tests/incorrect_equality.sol "incorrect-equality" |
||||||
|
test_slither tests/too_many_digits.sol "too-many-digits" |
||||||
|
|
||||||
|
|
||||||
|
### Test scripts |
||||||
|
|
||||||
|
if ! python examples/scripts/functions_called.py examples/scripts/functions_called.sol; then |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
if ! python examples/scripts/functions_writing.py examples/scripts/functions_writing.sol; then |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
if ! python examples/scripts/variable_in_condition.py examples/scripts/variable_in_condition.sol; then |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
exit 0 |
@ -0,0 +1,7 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
source "$(dirname "$0")""/ci_test.sh" |
||||||
|
|
||||||
|
solc use "0.6.11" |
||||||
|
|
||||||
|
# test_slither tests/filename.sol "detector_name" |
@ -0,0 +1,7 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
source "$(dirname "$0")""/ci_test.sh" |
||||||
|
|
||||||
|
solc use "0.7.0" |
||||||
|
|
||||||
|
# test_slither tests/filename.sol "detector_name" |
@ -0,0 +1,23 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
### Test etherscan integration |
||||||
|
|
||||||
|
mkdir etherscan |
||||||
|
cd etherscan || exit 255 |
||||||
|
|
||||||
|
slither 0x7F37f78cBD74481E593F9C737776F7113d76B315 --etherscan-apikey "$GITHUB_ETHERSCAN" |
||||||
|
|
||||||
|
if [ $? -ne 5 ] |
||||||
|
then |
||||||
|
echo "Etherscan test failed" |
||||||
|
exit 255 |
||||||
|
fi |
||||||
|
|
||||||
|
slither rinkeby:0xFe05820C5A92D9bc906D4A46F662dbeba794d3b7 --etherscan-apikey "$GITHUB_ETHERSCAN" |
||||||
|
|
||||||
|
if [ $? -ne 70 ] |
||||||
|
then |
||||||
|
echo "Etherscan test failed" |
||||||
|
exit 255 |
||||||
|
fi |
||||||
|
|
@ -1,8 +1,8 @@ |
|||||||
#!/usr/bin/env bash |
#!/usr/bin/env bash |
||||||
|
|
||||||
### Test slither-prop |
### Test slither-prop |
||||||
|
|
||||||
cd examples/slither-prop |
cd examples/slither-prop || exit 1 |
||||||
slither-prop . --contract ERC20Buggy |
slither-prop . --contract ERC20Buggy |
||||||
if [ ! -f contracts/crytic/TestERC20BuggyTransferable.sol ]; then |
if [ ! -f contracts/crytic/TestERC20BuggyTransferable.sol ]; then |
||||||
echo "slither-prop failed" |
echo "slither-prop failed" |
@ -0,0 +1,9 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
### Test |
||||||
|
|
||||||
|
if ! slither "tests/*.json" --config "tests/config/slither.config.json"; then |
||||||
|
echo "Config failed" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
@ -1,5 +0,0 @@ |
|||||||
CURRENT_PATH=$(pwd) |
|
||||||
TRAVIS_PATH='/home/travis/build/crytic/slither' |
|
||||||
for f in tests/expected_json/*json; do |
|
||||||
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$f" -i |
|
||||||
done |
|
@ -1,42 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "$0")" && pwd)" |
|
||||||
CURRENT_PATH=$(pwd) |
|
||||||
TRAVIS_PATH='/home/travis/build/crytic/slither' |
|
||||||
|
|
||||||
|
|
||||||
# generate_expected_json file.sol detectors |
|
||||||
generate_expected_json(){ |
|
||||||
# generate output filename |
|
||||||
# e.g. file: uninitialized.sol detector: uninitialized-state |
|
||||||
# ---> uninitialized.uninitialized-state.json |
|
||||||
output_filename="$DIR/../tests/expected_json/$(basename $1 .sol).$2.json" |
|
||||||
output_filename_txt="$DIR/../tests/expected_json/$(basename $1 .sol).$2.txt" |
|
||||||
|
|
||||||
# run slither detector on input file and save output as json |
|
||||||
slither "$1" --solc-disable-warnings --detect "$2" --json "$output_filename" --solc solc-0.5.1 > $output_filename_txt 2>&1 |
|
||||||
|
|
||||||
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$output_filename" -i |
|
||||||
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$output_filename_txt" -i |
|
||||||
} |
|
||||||
|
|
||||||
generate_expected_json tests/void-cst.sol "void-cst" |
|
||||||
generate_expected_json tests/solc_version_incorrect_05.ast.json "solc-version" |
|
||||||
generate_expected_json tests/uninitialized-0.5.1.sol "uninitialized-state" |
|
||||||
generate_expected_json tests/backdoor.sol "backdoor" |
|
||||||
generate_expected_json tests/backdoor.sol "suicidal" |
|
||||||
generate_expected_json tests/old_solc.sol.json "solc-version" |
|
||||||
generate_expected_json tests/reentrancy-0.5.1.sol "reentrancy-eth" |
|
||||||
generate_expected_json tests/reentrancy-0.5.1-events.sol "reentrancy-events" |
|
||||||
generate_expected_json tests/tx_origin-0.5.1.sol "tx-origin" |
|
||||||
generate_expected_json tests/locked_ether-0.5.1.sol "locked-ether" |
|
||||||
generate_expected_json tests/arbitrary_send-0.5.1.sol "arbitrary-send" |
|
||||||
generate_expected_json tests/inline_assembly_contract-0.5.1.sol "assembly" |
|
||||||
generate_expected_json tests/inline_assembly_library-0.5.1.sol "assembly" |
|
||||||
generate_expected_json tests/constant-0.5.1.sol "constant-function-asm" |
|
||||||
generate_expected_json tests/constant-0.5.1.sol "constant-function-state" |
|
||||||
generate_expected_json tests/incorrect_equality.sol "incorrect-equality" |
|
||||||
generate_expected_json tests/too_many_digits.sol "too-many-digits" |
|
||||||
generate_expected_json tests/unchecked_lowlevel-0.5.1.sol "unchecked-lowlevel" |
|
||||||
generate_expected_json tests/unchecked_send-0.5.1.sol "unchecked-send" |
|
||||||
|
|
@ -1,119 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
### Test Detectors |
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "$0")" && pwd)" |
|
||||||
|
|
||||||
CURRENT_PATH=$(pwd) |
|
||||||
TRAVIS_PATH='/home/travis/build/crytic/slither' |
|
||||||
|
|
||||||
# test_slither file.sol detectors |
|
||||||
test_slither(){ |
|
||||||
|
|
||||||
expected="$DIR/../tests/expected_json/$(basename $1 .sol).$2.json" |
|
||||||
|
|
||||||
# run slither detector on input file and save output as json |
|
||||||
slither "$1" --solc-disable-warnings --detect "$2" --json "$DIR/tmp-test.json" --solc solc-0.5.1 |
|
||||||
if [ $? -eq 255 ] |
|
||||||
then |
|
||||||
echo "Slither crashed" |
|
||||||
exit -1 |
|
||||||
fi |
|
||||||
|
|
||||||
if [ ! -f "$DIR/tmp-test.json" ]; then |
|
||||||
echo "" |
|
||||||
echo "Missing generated file" |
|
||||||
echo "" |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$DIR/tmp-test.json" -i |
|
||||||
result=$(python "$DIR/json_diff.py" "$expected" "$DIR/tmp-test.json") |
|
||||||
|
|
||||||
rm "$DIR/tmp-test.json" |
|
||||||
if [ "$result" != "{}" ]; then |
|
||||||
echo "" |
|
||||||
echo "failed test of file: $1, detector: $2" |
|
||||||
echo "" |
|
||||||
echo "$result" |
|
||||||
echo "" |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
# run slither detector on input file and save output as json |
|
||||||
slither "$1" --solc-disable-warnings --detect "$2" --legacy-ast --json "$DIR/tmp-test.json" --solc solc-0.5.1 |
|
||||||
if [ $? -eq 255 ] |
|
||||||
then |
|
||||||
echo "Slither crashed" |
|
||||||
exit -1 |
|
||||||
fi |
|
||||||
|
|
||||||
if [ ! -f "$DIR/tmp-test.json" ]; then |
|
||||||
echo "" |
|
||||||
echo "Missing generated file" |
|
||||||
echo "" |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$DIR/tmp-test.json" -i |
|
||||||
result=$(python "$DIR/json_diff.py" "$expected" "$DIR/tmp-test.json") |
|
||||||
|
|
||||||
rm "$DIR/tmp-test.json" |
|
||||||
if [ "$result" != "{}" ]; then |
|
||||||
echo "" |
|
||||||
echo "failed test of file: $1, detector: $2" |
|
||||||
echo "" |
|
||||||
echo "$result" |
|
||||||
echo "" |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
test_slither tests/void-cst.sol "void-cst" |
|
||||||
test_slither tests/solc_version_incorrect_05.ast.json "solc-version" |
|
||||||
test_slither tests/unchecked_lowlevel-0.5.1.sol "unchecked-lowlevel" |
|
||||||
test_slither tests/unchecked_send-0.5.1.sol "unchecked-send" |
|
||||||
test_slither tests/uninitialized-0.5.1.sol "uninitialized-state" |
|
||||||
test_slither tests/backdoor.sol "backdoor" |
|
||||||
test_slither tests/backdoor.sol "suicidal" |
|
||||||
test_slither tests/old_solc.sol.json "solc-version" |
|
||||||
test_slither tests/reentrancy-0.5.1.sol "reentrancy-eth" |
|
||||||
test_slither tests/reentrancy-0.5.1-events.sol "reentrancy-events" |
|
||||||
test_slither tests/tx_origin-0.5.1.sol "tx-origin" |
|
||||||
test_slither tests/unused_state.sol "unused-state" |
|
||||||
test_slither tests/locked_ether-0.5.1.sol "locked-ether" |
|
||||||
test_slither tests/arbitrary_send-0.5.1.sol "arbitrary-send" |
|
||||||
test_slither tests/inline_assembly_contract-0.5.1.sol "assembly" |
|
||||||
test_slither tests/inline_assembly_library-0.5.1.sol "assembly" |
|
||||||
test_slither tests/low_level_calls.sol "low-level-calls" |
|
||||||
test_slither tests/const_state_variables.sol "constable-states" |
|
||||||
test_slither tests/external_function.sol "external-function" |
|
||||||
test_slither tests/external_function_2.sol "external-function" |
|
||||||
test_slither tests/naming_convention.sol "naming-convention" |
|
||||||
#test_slither tests/complex_func.sol "complex-function" |
|
||||||
test_slither tests/controlled_delegatecall.sol "controlled-delegatecall" |
|
||||||
test_slither tests/constant-0.5.1.sol "constant-function-asm" |
|
||||||
test_slither tests/constant-0.5.1.sol "constant-function-state" |
|
||||||
test_slither tests/unused_return.sol "unused-return" |
|
||||||
test_slither tests/timestamp.sol "timestamp" |
|
||||||
test_slither tests/incorrect_equality.sol "incorrect-equality" |
|
||||||
test_slither tests/too_many_digits.sol "too-many-digits" |
|
||||||
|
|
||||||
|
|
||||||
### Test scripts |
|
||||||
|
|
||||||
python examples/scripts/functions_called.py examples/scripts/functions_called.sol |
|
||||||
if [ $? -ne 0 ]; then |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
python examples/scripts/functions_writing.py examples/scripts/functions_writing.sol |
|
||||||
if [ $? -ne 0 ]; then |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
python examples/scripts/variable_in_condition.py examples/scripts/variable_in_condition.sol |
|
||||||
if [ $? -ne 0 ]; then |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
exit 0 |
|
@ -1,24 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
### Test |
|
||||||
|
|
||||||
slither "tests/*.json" --solc-ast --ignore-return-value |
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then |
|
||||||
echo "--solc-ast failed" |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
slither "tests/*0.5*.sol" --solc-disable-warnings --ignore-return-value |
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then |
|
||||||
echo "--solc-disable-warnings failed" |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
slither "tests/*0.5*.sol" --disable-color --ignore-return-value |
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then |
|
||||||
echo "--disable-color failed" |
|
||||||
exit 1 |
|
||||||
fi |
|
@ -1,11 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
### Test data dependecy |
|
||||||
|
|
||||||
python ./examples/scripts/data_dependency.py ./examples/scripts/data_dependency.sol |
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then |
|
||||||
echo "data dependency failed" |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
exit 0 |
|
@ -1,26 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
### Test etherscan integration |
|
||||||
|
|
||||||
mkdir etherscan |
|
||||||
cd etherscan |
|
||||||
|
|
||||||
wget -O solc-0.4.25 https://github.com/ethereum/solidity/releases/download/v0.4.25/solc-static-linux |
|
||||||
chmod +x solc-0.4.25 |
|
||||||
|
|
||||||
slither 0x7F37f78cBD74481E593F9C737776F7113d76B315 --solc "./solc-0.4.25" --etherscan-apikey $GITHUB_ETHERSCAN |
|
||||||
|
|
||||||
if [ $? -ne 5 ] |
|
||||||
then |
|
||||||
echo "Etherscan test failed" |
|
||||||
exit -1 |
|
||||||
fi |
|
||||||
|
|
||||||
slither rinkeby:0xFe05820C5A92D9bc906D4A46F662dbeba794d3b7 --solc "./solc-0.4.25" --etherscan-apikey $GITHUB_ETHERSCAN |
|
||||||
|
|
||||||
if [ $? -ne 70 ] |
|
||||||
then |
|
||||||
echo "Etherscan test failed" |
|
||||||
exit -1 |
|
||||||
fi |
|
||||||
|
|
@ -1,11 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
### Test |
|
||||||
|
|
||||||
slither "tests/*.json" --config "tests/config/slither.config.json" |
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then |
|
||||||
echo "Config failed" |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
@ -1,5 +1,16 @@ |
|||||||
|
import abc |
||||||
|
from typing import Tuple |
||||||
|
|
||||||
from slither.core.source_mapping.source_mapping import SourceMapping |
from slither.core.source_mapping.source_mapping import SourceMapping |
||||||
|
|
||||||
|
|
||||||
class Type(SourceMapping): |
class Type(SourceMapping, metaclass=abc.ABCMeta): |
||||||
pass |
@property |
||||||
|
@abc.abstractmethod |
||||||
|
def storage_size(self) -> Tuple[int, bool]: |
||||||
|
""" |
||||||
|
Computes and returns storage layout related metadata |
||||||
|
|
||||||
|
:return: (int, bool) - the number of bytes this type will require, and whether it must start in |
||||||
|
a new slot regardless of whether the current slot can still fit it |
||||||
|
""" |
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue