mirror of https://github.com/crytic/slither
- 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 guidelinespull/610/head
parent
2452037f8e
commit
351de6bd31
@ -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 |
||||
} |
||||
|
@ -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" |
@ -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,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 |
@ -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,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 |
||||
|
Loading…
Reference in new issue