From 351de6bd31c1220480aa802a70292a00a53de2ef Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 31 Aug 2020 11:06:35 +0200 Subject: [PATCH] Refactor regression tests: - Rename travis_ to ci_ - Move shared code to scripts/ci_tests.sh - Rename _4 /_5 to detectors_4 / detectors_5 - Rename generation scripts - Create solidity 6 / 7 scripts (but there is no test for now) - Use solc-select - Update CONTRIBUTING.md guidelines --- .github/workflows/ci.yml | 33 ++++--- CONTRIBUTING.md | 13 +++ ...n_4.sh => ci_generate_test_detectors_4.sh} | 21 +---- scripts/ci_generate_test_detectors_5.sh | 28 ++++++ scripts/ci_generate_test_detectors_6.sh | 11 +++ scripts/ci_generate_test_detectors_7.sh | 11 +++ scripts/ci_test.sh | 86 +++++++++++++++++++ .../{travis_test_cli.sh => ci_test_cli.sh} | 0 .../{travis_test_dapp.sh => ci_test_dapp.sh} | 0 ...pendency.sh => ci_test_data_dependency.sh} | 0 ...ravis_test_4.sh => ci_test_detectors_4.sh} | 70 +-------------- ...ravis_test_5.sh => ci_test_detectors_5.sh} | 71 +-------------- scripts/ci_test_detectors_6.sh | 7 ++ scripts/ci_test_detectors_7.sh | 7 ++ ...ravis_test_embark.sh => ci_test_embark.sh} | 0 .../{travis_test_erc.sh => ci_test_erc.sh} | 3 +- ...test_etherlime.sh => ci_test_etherlime.sh} | 0 scripts/ci_test_etherscan.sh | 23 +++++ ...st_find_paths.sh => ci_test_find_paths.sh} | 3 +- ...{travis_test_kspec.sh => ci_test_kspec.sh} | 3 +- ...s_test_printers.sh => ci_test_printers.sh} | 4 +- .../{travis_test_prop.sh => ci_test_prop.sh} | 0 ...{travis_test_simil.sh => ci_test_simil.sh} | 4 +- ...er_config.sh => ci_test_slither_config.sh} | 0 ...vis_test_truffle.sh => ci_test_truffle.sh} | 0 ...radability.sh => ci_test_upgradability.sh} | 25 +++--- scripts/fix_travis_relative_paths.sh | 6 -- scripts/tests_generate_expected_json_5.sh | 42 --------- scripts/travis_test_etherscan.sh | 26 ------ 29 files changed, 243 insertions(+), 254 deletions(-) rename scripts/{tests_generate_expected_json_4.sh => ci_generate_test_detectors_4.sh} (76%) create mode 100755 scripts/ci_generate_test_detectors_5.sh create mode 100755 scripts/ci_generate_test_detectors_6.sh create mode 100755 scripts/ci_generate_test_detectors_7.sh create mode 100755 scripts/ci_test.sh rename scripts/{travis_test_cli.sh => ci_test_cli.sh} (100%) rename scripts/{travis_test_dapp.sh => ci_test_dapp.sh} (100%) rename scripts/{travis_test_data_dependency.sh => ci_test_data_dependency.sh} (100%) rename scripts/{travis_test_4.sh => ci_test_detectors_4.sh} (54%) rename scripts/{travis_test_5.sh => ci_test_detectors_5.sh} (54%) create mode 100755 scripts/ci_test_detectors_6.sh create mode 100755 scripts/ci_test_detectors_7.sh rename scripts/{travis_test_embark.sh => ci_test_embark.sh} (100%) rename scripts/{travis_test_erc.sh => ci_test_erc.sh} (77%) rename scripts/{travis_test_etherlime.sh => ci_test_etherlime.sh} (100%) create mode 100755 scripts/ci_test_etherscan.sh rename scripts/{travis_test_find_paths.sh => ci_test_find_paths.sh} (75%) rename scripts/{travis_test_kspec.sh => ci_test_kspec.sh} (85%) rename scripts/{travis_test_printers.sh => ci_test_printers.sh} (72%) rename scripts/{travis_test_prop.sh => ci_test_prop.sh} (100%) rename scripts/{travis_test_simil.sh => ci_test_simil.sh} (85%) rename scripts/{travis_test_slither_config.sh => ci_test_slither_config.sh} (100%) rename scripts/{travis_test_truffle.sh => ci_test_truffle.sh} (100%) rename scripts/{travis_test_upgradability.sh => ci_test_upgradability.sh} (79%) delete mode 100755 scripts/fix_travis_relative_paths.sh delete mode 100755 scripts/tests_generate_expected_json_5.sh delete mode 100755 scripts/travis_test_etherscan.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4f079c8d..875c91a89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,23 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - type: ["4", "5", "cli", "data_dependency", "embark", "erc", "etherlime", "find_paths", "kspec", "printers", "simil", "slither_config", "truffle", "upgradability", "prop"] + type: ["detectors_4", + "detectors_5", + "detectors_6", + "detectors_7", + "cli", + "data_dependency", + "embark", + "erc", + "etherlime", + "find_paths", + "kspec", + "printers", + "simil", + "slither_config", + "truffle", + "upgradability", + "prop"] steps: - uses: actions/checkout@v1 - name: Set up Python 3.6 @@ -25,19 +41,16 @@ jobs: - name: Install dependencies run: | python setup.py install - # Used by travis_test.sh + # Used by ci_test.sh pip install deepdiff - sudo wget -O /usr/bin/solc-0.4.25 https://github.com/ethereum/solidity/releases/download/v0.4.25/solc-static-linux - sudo chmod +x /usr/bin/solc-0.4.25 - sudo wget -O /usr/bin/solc-0.5.1 https://github.com/ethereum/solidity/releases/download/v0.5.1/solc-static-linux - sudo chmod +x /usr/bin/solc-0.5.1 - sudo wget -O /usr/bin/solc-0.5.0 https://github.com/ethereum/solidity/releases/download/v0.5.0/solc-static-linux - sudo chmod +x /usr/bin/solc-0.5.0 - sudo cp /usr/bin/solc-0.5.1 /usr/bin/solc + git clone https://github.com/crytic/solc-select.git + ./solc-select/scripts/install.sh + solc use 0.5.1 + - name: Run Tests env: TEST_TYPE: ${{ matrix.type }} GITHUB_ETHERSCAN: ${{ secrets.GITHUB_ETHERSCAN }} run: | - bash scripts/travis_test_${TEST_TYPE}.sh + bash scripts/ci_test_${TEST_TYPE}.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 13bdc5859..ec72c9e65 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,3 +22,16 @@ Some pull request guidelines: ## Development Environment 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. + + diff --git a/scripts/tests_generate_expected_json_4.sh b/scripts/ci_generate_test_detectors_4.sh similarity index 76% rename from scripts/tests_generate_expected_json_4.sh rename to scripts/ci_generate_test_detectors_4.sh index 4e4750cde..a5349ca70 100755 --- a/scripts/tests_generate_expected_json_4.sh +++ b/scripts/ci_generate_test_detectors_4.sh @@ -1,24 +1,10 @@ #!/usr/bin/env bash -DIR="$(cd "$(dirname "$0")" && pwd)" -CURRENT_PATH=$(pwd) -TRAVIS_PATH='/home/travis/build/crytic/slither' +source "$(dirname "$0")""/ci_test.sh" -# 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" +solc use "0.4.25" - # run slither detector on input file and save output as json - slither "$1" --solc-disable-warnings --detect "$2" --json "$output_filename" --solc solc-0.4.25 > "$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 -} +# Be sure that only one of the following line is uncommented before running the script #generate_expected_json tests/deprecated_calls.sol "deprecated-standards" @@ -58,3 +44,4 @@ generate_expected_json(){ #generate_expected_json tests/solc_version_incorrect.sol "solc-version" #generate_expected_json tests/right_to_left_override.sol "rtlo" #generate_expected_json tests/unchecked_lowlevel.sol "unchecked-lowlevel" + diff --git a/scripts/ci_generate_test_detectors_5.sh b/scripts/ci_generate_test_detectors_5.sh new file mode 100755 index 000000000..e7e027154 --- /dev/null +++ b/scripts/ci_generate_test_detectors_5.sh @@ -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" + diff --git a/scripts/ci_generate_test_detectors_6.sh b/scripts/ci_generate_test_detectors_6.sh new file mode 100755 index 000000000..0d1cc46ab --- /dev/null +++ b/scripts/ci_generate_test_detectors_6.sh @@ -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" + diff --git a/scripts/ci_generate_test_detectors_7.sh b/scripts/ci_generate_test_detectors_7.sh new file mode 100755 index 000000000..cbc6500a9 --- /dev/null +++ b/scripts/ci_generate_test_detectors_7.sh @@ -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" + diff --git a/scripts/ci_test.sh b/scripts/ci_test.sh new file mode 100755 index 000000000..2ef5b0357 --- /dev/null +++ b/scripts/ci_test.sh @@ -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 +} + diff --git a/scripts/travis_test_cli.sh b/scripts/ci_test_cli.sh similarity index 100% rename from scripts/travis_test_cli.sh rename to scripts/ci_test_cli.sh diff --git a/scripts/travis_test_dapp.sh b/scripts/ci_test_dapp.sh similarity index 100% rename from scripts/travis_test_dapp.sh rename to scripts/ci_test_dapp.sh diff --git a/scripts/travis_test_data_dependency.sh b/scripts/ci_test_data_dependency.sh similarity index 100% rename from scripts/travis_test_data_dependency.sh rename to scripts/ci_test_data_dependency.sh diff --git a/scripts/travis_test_4.sh b/scripts/ci_test_detectors_4.sh similarity index 54% rename from scripts/travis_test_4.sh rename to scripts/ci_test_detectors_4.sh index 35059d08b..c147ba406 100755 --- a/scripts/travis_test_4.sh +++ b/scripts/ci_test_detectors_4.sh @@ -1,73 +1,8 @@ #!/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.4.25 - 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" --solc solc-0.4.25 - 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 -} +source "$(dirname "$0")""/ci_test.sh" +solc use "0.4.25" test_slither tests/unchecked_lowlevel.sol "unchecked-lowlevel" test_slither tests/deprecated_calls.sol "deprecated-standards" @@ -92,7 +27,6 @@ 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/uninitialized_local_variable.sol "uninitialized-local" test_slither tests/constant.sol "constant-function-asm" diff --git a/scripts/travis_test_5.sh b/scripts/ci_test_detectors_5.sh similarity index 54% rename from scripts/travis_test_5.sh rename to scripts/ci_test_detectors_5.sh index cada6804a..ac75177bd 100755 --- a/scripts/travis_test_5.sh +++ b/scripts/ci_test_detectors_5.sh @@ -1,73 +1,8 @@ #!/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 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" --solc solc-0.5.1 - 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 -} - +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" diff --git a/scripts/ci_test_detectors_6.sh b/scripts/ci_test_detectors_6.sh new file mode 100755 index 000000000..6af1b8486 --- /dev/null +++ b/scripts/ci_test_detectors_6.sh @@ -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" diff --git a/scripts/ci_test_detectors_7.sh b/scripts/ci_test_detectors_7.sh new file mode 100755 index 000000000..6ad291bb6 --- /dev/null +++ b/scripts/ci_test_detectors_7.sh @@ -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" diff --git a/scripts/travis_test_embark.sh b/scripts/ci_test_embark.sh similarity index 100% rename from scripts/travis_test_embark.sh rename to scripts/ci_test_embark.sh diff --git a/scripts/travis_test_erc.sh b/scripts/ci_test_erc.sh similarity index 77% rename from scripts/travis_test_erc.sh rename to scripts/ci_test_erc.sh index 12e973137..a96a414e1 100755 --- a/scripts/travis_test_erc.sh +++ b/scripts/ci_test_erc.sh @@ -4,7 +4,8 @@ DIR_TESTS="tests/check-erc" -slither-check-erc "$DIR_TESTS/erc20.sol" ERC20 --solc solc-0.5.0 > test_1.txt 2>&1 +solc use 0.5.0 +slither-check-erc "$DIR_TESTS/erc20.sol" ERC20 > test_1.txt 2>&1 DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt") if [ "$DIFF" != "" ] then diff --git a/scripts/travis_test_etherlime.sh b/scripts/ci_test_etherlime.sh similarity index 100% rename from scripts/travis_test_etherlime.sh rename to scripts/ci_test_etherlime.sh diff --git a/scripts/ci_test_etherscan.sh b/scripts/ci_test_etherscan.sh new file mode 100755 index 000000000..08a160f50 --- /dev/null +++ b/scripts/ci_test_etherscan.sh @@ -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 + diff --git a/scripts/travis_test_find_paths.sh b/scripts/ci_test_find_paths.sh similarity index 75% rename from scripts/travis_test_find_paths.sh rename to scripts/ci_test_find_paths.sh index 088d02e65..2707aaa07 100755 --- a/scripts/travis_test_find_paths.sh +++ b/scripts/ci_test_find_paths.sh @@ -4,7 +4,8 @@ DIR_TESTS="tests/possible_paths" -slither-find-paths "$DIR_TESTS/paths.sol" A.destination --solc solc-0.5.0 > test_possible_paths.txt 2>&1 +solc use "0.5.0" +slither-find-paths "$DIR_TESTS/paths.sol" A.destination > test_possible_paths.txt 2>&1 DIFF=$(diff test_possible_paths.txt "$DIR_TESTS/paths.txt") if [ "$DIFF" != "" ] then diff --git a/scripts/travis_test_kspec.sh b/scripts/ci_test_kspec.sh similarity index 85% rename from scripts/travis_test_kspec.sh rename to scripts/ci_test_kspec.sh index 7fa36858b..c80df54e0 100755 --- a/scripts/travis_test_kspec.sh +++ b/scripts/ci_test_kspec.sh @@ -2,7 +2,8 @@ DIR_TESTS="tests/check-kspec" -slither-check-kspec "$DIR_TESTS/safeAdd/safeAdd.sol" "$DIR_TESTS/safeAdd/spec.md" --solc solc-0.5.0 > test_1.txt 2>&1 +solc use "0.5.0" +slither-check-kspec "$DIR_TESTS/safeAdd/safeAdd.sol" "$DIR_TESTS/safeAdd/spec.md" > test_1.txt 2>&1 DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt") if [ "$DIFF" != "" ] then diff --git a/scripts/travis_test_printers.sh b/scripts/ci_test_printers.sh similarity index 72% rename from scripts/travis_test_printers.sh rename to scripts/ci_test_printers.sh index 9ff51b0aa..209f4329e 100755 --- a/scripts/travis_test_printers.sh +++ b/scripts/ci_test_printers.sh @@ -10,4 +10,6 @@ if ! slither "tests/*.json" --print all --json -; then exit 1 fi -slither examples/scripts/test_evm_api.sol --print evm --solc solc-0.5.1 +solc use "0.5.1" + +slither examples/scripts/test_evm_api.sol --print evm diff --git a/scripts/travis_test_prop.sh b/scripts/ci_test_prop.sh similarity index 100% rename from scripts/travis_test_prop.sh rename to scripts/ci_test_prop.sh diff --git a/scripts/travis_test_simil.sh b/scripts/ci_test_simil.sh similarity index 85% rename from scripts/travis_test_simil.sh rename to scripts/ci_test_simil.sh index 349f3eca9..5c8a8f70d 100755 --- a/scripts/travis_test_simil.sh +++ b/scripts/ci_test_simil.sh @@ -7,8 +7,10 @@ pip3.6 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip ### Test slither-simil +solc use "0.4.25" + DIR_TESTS="tests/simil" -slither-simil info "" --filename $DIR_TESTS/../complex_func.sol --fname Complex.complexExternalWrites --solc solc-0.4.25 > test_1.txt 2>&1 +slither-simil info "" --filename $DIR_TESTS/../complex_func.sol --fname Complex.complexExternalWrites > test_1.txt 2>&1 DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt") if [ "$DIFF" != "" ] then diff --git a/scripts/travis_test_slither_config.sh b/scripts/ci_test_slither_config.sh similarity index 100% rename from scripts/travis_test_slither_config.sh rename to scripts/ci_test_slither_config.sh diff --git a/scripts/travis_test_truffle.sh b/scripts/ci_test_truffle.sh similarity index 100% rename from scripts/travis_test_truffle.sh rename to scripts/ci_test_truffle.sh diff --git a/scripts/travis_test_upgradability.sh b/scripts/ci_test_upgradability.sh similarity index 79% rename from scripts/travis_test_upgradability.sh rename to scripts/ci_test_upgradability.sh index cfb30bebe..2dd8f7a52 100755 --- a/scripts/travis_test_upgradability.sh +++ b/scripts/ci_test_upgradability.sh @@ -3,8 +3,9 @@ ### Test slither-check-upgradeability DIR_TESTS="tests/check-upgradeability" +solc use "0.5.0" -slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 > test_1.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy > test_1.txt 2>&1 DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt") if [ "$DIFF" != "" ] then @@ -15,7 +16,7 @@ then exit 255 fi -slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 --new-contract-filename "$DIR_TESTS/contractV2.sol" --new-contract-name ContractV2 > test_2.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --new-contract-filename "$DIR_TESTS/contractV2.sol" --new-contract-name ContractV2 > test_2.txt 2>&1 DIFF=$(diff test_2.txt "$DIR_TESTS/test_2.txt") if [ "$DIFF" != "" ] then @@ -26,7 +27,7 @@ then exit 255 fi -slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 --new-contract-filename "$DIR_TESTS/contractV2_bug.sol" --new-contract-name ContractV2 > test_3.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --new-contract-filename "$DIR_TESTS/contractV2_bug.sol" --new-contract-name ContractV2 > test_3.txt 2>&1 DIFF=$(diff test_3.txt "$DIR_TESTS/test_3.txt") if [ "$DIFF" != "" ] then @@ -37,7 +38,7 @@ then exit 255 fi -slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 --new-contract-filename "$DIR_TESTS/contractV2_bug2.sol" --new-contract-name ContractV2 > test_4.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --new-contract-filename "$DIR_TESTS/contractV2_bug2.sol" --new-contract-name ContractV2 > test_4.txt 2>&1 DIFF=$(diff test_4.txt "$DIR_TESTS/test_4.txt") if [ "$DIFF" != "" ] then @@ -48,7 +49,7 @@ then exit 255 fi -slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_no_bug --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 > test_5.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_no_bug --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy > test_5.txt 2>&1 DIFF=$(diff test_5.txt "$DIR_TESTS/test_5.txt") if [ "$DIFF" != "" ] then @@ -61,7 +62,7 @@ then exit 255 fi -slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_no_bug --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 > test_5.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_no_bug --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy > test_5.txt 2>&1 DIFF=$(diff test_5.txt "$DIR_TESTS/test_5.txt") if [ "$DIFF" != "" ] then @@ -75,7 +76,7 @@ then fi -slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_lack_to_call_modifier --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 > test_6.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_lack_to_call_modifier --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy > test_6.txt 2>&1 DIFF=$(diff test_6.txt "$DIR_TESTS/test_6.txt") if [ "$DIFF" != "" ] then @@ -89,7 +90,7 @@ then fi -slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_not_called_super_init --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 > test_7.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_not_called_super_init --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy > test_7.txt 2>&1 DIFF=$(diff test_7.txt "$DIR_TESTS/test_7.txt") if [ "$DIFF" != "" ] then @@ -102,7 +103,7 @@ then exit 255 fi -slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_no_bug_inherits --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 > test_8.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_no_bug_inherits --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy > test_8.txt 2>&1 DIFF=$(diff test_8.txt "$DIR_TESTS/test_8.txt") if [ "$DIFF" != "" ] then @@ -115,7 +116,7 @@ then exit 255 fi -slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_double_call --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy --solc solc-0.5.0 > test_9.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contract_initialization.sol" Contract_double_call --proxy-filename "$DIR_TESTS/proxy.sol" --proxy-name Proxy > test_9.txt 2>&1 DIFF=$(diff test_9.txt "$DIR_TESTS/test_9.txt") if [ "$DIFF" != "" ] then @@ -128,7 +129,7 @@ then exit 255 fi -slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --solc solc-0.5.0 --new-contract-filename "$DIR_TESTS/contract_v2_constant.sol" --new-contract-name ContractV2 > test_10.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contractV1.sol" ContractV1 --new-contract-filename "$DIR_TESTS/contract_v2_constant.sol" --new-contract-name ContractV2 > test_10.txt 2>&1 DIFF=$(diff test_10.txt "$DIR_TESTS/test_10.txt") if [ "$DIFF" != "" ] then @@ -141,7 +142,7 @@ then exit 255 fi -slither-check-upgradeability "$DIR_TESTS/contract_v1_var_init.sol" ContractV1 --solc solc-0.5.0 > test_11.txt 2>&1 +slither-check-upgradeability "$DIR_TESTS/contract_v1_var_init.sol" ContractV1 > test_11.txt 2>&1 DIFF=$(diff test_11.txt "$DIR_TESTS/test_11.txt") if [ "$DIFF" != "" ] then diff --git a/scripts/fix_travis_relative_paths.sh b/scripts/fix_travis_relative_paths.sh deleted file mode 100755 index 76de85ed9..000000000 --- a/scripts/fix_travis_relative_paths.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -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 diff --git a/scripts/tests_generate_expected_json_5.sh b/scripts/tests_generate_expected_json_5.sh deleted file mode 100755 index b4f70bbbe..000000000 --- a/scripts/tests_generate_expected_json_5.sh +++ /dev/null @@ -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" - diff --git a/scripts/travis_test_etherscan.sh b/scripts/travis_test_etherscan.sh deleted file mode 100755 index 0398fa48f..000000000 --- a/scripts/travis_test_etherscan.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -### Test etherscan integration - -mkdir etherscan -cd etherscan || exit 255 - -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 255 -fi - -slither rinkeby:0xFe05820C5A92D9bc906D4A46F662dbeba794d3b7 --solc "./solc-0.4.25" --etherscan-apikey "$GITHUB_ETHERSCAN" - -if [ $? -ne 70 ] -then - echo "Etherscan test failed" - exit 255 -fi -