mirror of https://github.com/crytic/slither
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.0 KiB
107 lines
3.0 KiB
6 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
6 years ago
|
### Test Detectors
|
||
|
|
||
6 years ago
|
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||
|
|
||
6 years ago
|
# test_slither file.sol detectors
|
||
6 years ago
|
test_slither(){
|
||
6 years ago
|
|
||
6 years ago
|
expected="$DIR/../tests/expected_json/$(basename $1 .sol).$2.json"
|
||
|
|
||
|
# run slither detector on input file and save output as json
|
||
6 years ago
|
slither "$1" --disable-solc-warnings --detect "$2" --json "$DIR/tmp-test.json" --solc solc-0.5.1
|
||
6 years ago
|
if [ $? -eq 255 ]
|
||
|
then
|
||
|
echo "Slither crashed"
|
||
|
exit -1
|
||
|
fi
|
||
6 years ago
|
|
||
6 years ago
|
if [ ! -f "$DIR/tmp-test.json" ]; then
|
||
6 years ago
|
echo ""
|
||
6 years ago
|
echo "Missing generated file"
|
||
6 years ago
|
echo ""
|
||
6 years ago
|
exit 1
|
||
6 years ago
|
fi
|
||
6 years ago
|
|
||
6 years ago
|
result=$(python "$DIR/json_diff.py" "$expected" "$DIR/tmp-test.json")
|
||
6 years ago
|
|
||
6 years ago
|
rm "$DIR/tmp-test.json"
|
||
|
if [ "$result" != "{}" ]; then
|
||
6 years ago
|
echo ""
|
||
|
echo "failed test of file: $1, detector: $2"
|
||
|
echo ""
|
||
|
echo "$result"
|
||
|
echo ""
|
||
6 years ago
|
exit 1
|
||
6 years ago
|
fi
|
||
|
|
||
6 years ago
|
# run slither detector on input file and save output as json
|
||
6 years ago
|
slither "$1" --disable-solc-warnings --detect "$2" --compact-ast --json "$DIR/tmp-test.json" --solc solc-0.5.1
|
||
6 years ago
|
if [ $? -eq 255 ]
|
||
|
then
|
||
|
echo "Slither crashed"
|
||
|
exit -1
|
||
|
fi
|
||
6 years ago
|
|
||
6 years ago
|
if [ ! -f "$DIR/tmp-test.json" ]; then
|
||
|
echo ""
|
||
|
echo "Missing generated file"
|
||
|
echo ""
|
||
|
exit 1
|
||
|
fi
|
||
6 years ago
|
|
||
6 years ago
|
result=$(python "$DIR/json_diff.py" "$expected" "$DIR/tmp-test.json")
|
||
6 years ago
|
|
||
6 years ago
|
rm "$DIR/tmp-test.json"
|
||
|
if [ "$result" != "{}" ]; then
|
||
6 years ago
|
echo ""
|
||
|
echo "failed test of file: $1, detector: $2"
|
||
|
echo ""
|
||
|
echo "$result"
|
||
|
echo ""
|
||
6 years ago
|
exit 1
|
||
6 years ago
|
fi
|
||
|
}
|
||
|
|
||
6 years ago
|
|
||
6 years ago
|
test_slither tests/uninitialized-0.5.1.sol "uninitialized-state"
|
||
6 years ago
|
test_slither tests/backdoor.sol "backdoor"
|
||
|
test_slither tests/backdoor.sol "suicidal"
|
||
|
test_slither tests/old_solc.sol.json "solc-version"
|
||
6 years ago
|
test_slither tests/reentrancy-0.5.1.sol "reentrancy"
|
||
6 years ago
|
test_slither tests/uninitialized_storage_pointer.sol "uninitialized-storage"
|
||
|
test_slither tests/tx_origin.sol "tx-origin"
|
||
|
test_slither tests/unused_state.sol "unused-state"
|
||
|
test_slither tests/locked_ether.sol "locked-ether"
|
||
|
test_slither tests/arbitrary_send.sol "arbitrary-send"
|
||
|
test_slither tests/inline_assembly_contract.sol "assembly"
|
||
|
test_slither tests/inline_assembly_library.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/naming_convention.sol "naming-convention"
|
||
6 years ago
|
#test_slither tests/complex_func.sol "complex-function"
|
||
6 years ago
|
test_slither tests/controlled_delegatecall.sol "controlled-delegatecall"
|
||
6 years ago
|
test_slither tests/constant.sol "constant-function"
|
||
|
test_slither tests/unused_return.sol "unused-return"
|
||
6 years ago
|
|
||
6 years ago
|
|
||
6 years ago
|
### 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
|
||
6 years ago
|
exit 0
|