Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Migrate from argparse to Typer #2452

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test_slither(){
expected="$DIR/../tests/expected_json/$(basename "$1" .sol).$2.json"

# run slither detector on input file and save output as json
if ! slither "$1" --solc-disable-warnings --detect "$2" --json "$DIR/tmp-test.json";
if ! slither --json "$DIR/tmp-test.json" detect "$1" --solc-disable-warnings --detect "$2";
then
echo "Slither crashed"
exit 255
Expand All @@ -39,7 +39,7 @@ test_slither(){
fi

# run slither detector on input file and save output as json
if ! slither "$1" --solc-disable-warnings --detect "$2" --legacy-ast --json "$DIR/tmp-test.json";
if ! slither --json "$DIR/tmp-test.json" detect "$1" --solc-disable-warnings --detect "$2" --legacy-ast;
then
echo "Slither crashed"
exit 255
Expand Down Expand Up @@ -75,7 +75,7 @@ generate_expected_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
slither --json "$output_filename" detect "$1" --solc-disable-warnings --detect "$2" > "$output_filename_txt" 2>&1


sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$output_filename" -i
Expand Down
6 changes: 3 additions & 3 deletions scripts/ci_test_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

solc-select use 0.7.0

if ! slither "tests/e2e/config/test_json_config/test.sol" --solc-ast --no-fail-pedantic; then
if ! slither detect "tests/e2e/config/test_json_config/test.sol" --solc-ast --no-fail-pedantic; then
echo "--solc-ast failed"
exit 1
fi

if ! slither "tests/e2e/config/test_json_config/test.sol" --solc-disable-warnings --no-fail-pedantic; then
if ! slither detect "tests/e2e/config/test_json_config/test.sol" --solc-disable-warnings --no-fail-pedantic; then
echo "--solc-disable-warnings failed"
exit 1
fi

if ! slither "tests/e2e/config/test_json_config/test.sol" --disable-color --no-fail-pedantic; then
if ! slither detect "tests/e2e/config/test_json_config/test.sol" --disable-color --no-fail-pedantic; then
echo "--disable-color failed"
exit 1
fi
2 changes: 1 addition & 1 deletion scripts/ci_test_dapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ nix-env -f "$HOME/.dapp/dapptools" -iA dapp seth solc hevm ethsign

dapp init

if ! slither . --detect external-function; then
if ! slither detect . --detect external-function; then
echo "Dapp test failed"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_test_embark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ embark demo
cd embark_demo || exit 255
npm install

if ! slither . --embark-overwrite-config; then
if ! slither detect . --embark-overwrite-config; then
echo "Embark test failed"
exit 255
fi
Expand Down
6 changes: 3 additions & 3 deletions scripts/ci_test_erc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

### Test slither-check-erc

DIR_TESTS="tests/tools/check-erc"
DIR_TESTS="tests/tools/check_erc"

solc-select use 0.5.0
slither-check-erc "$DIR_TESTS/erc20.sol" ERC20 > test_1.txt 2>&1
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
echo "slither-check-erc 1 failed"
echo "slither check-erc 1 failed"
cat test_1.txt
echo ""
cat "$DIR_TESTS/test_1.txt"
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_test_etherlime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nvm use 10.17.0
npm i -g etherlime
etherlime init

if ! slither .; then
if ! slither detect .; then
echo "Etherlime test failed"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_test_etherscan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mkdir etherscan
cd etherscan || exit 255

echo "::group::Etherscan mainnet"
if ! slither 0x7F37f78cBD74481E593F9C737776F7113d76B315 --etherscan-apikey "$GITHUB_ETHERSCAN" --no-fail-pedantic; then
if ! slither detect 0x7F37f78cBD74481E593F9C737776F7113d76B315 --etherscan-apikey "$GITHUB_ETHERSCAN" --no-fail-pedantic; then
echo "Etherscan mainnet test failed"
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci_test_find_paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
DIR_TESTS="tests/possible_paths"

solc-select use "0.5.0"
slither-find-paths "$DIR_TESTS/paths.sol" A.destination > test_possible_paths.txt 2>&1
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
echo "slither-find-paths failed"
echo "slither find-paths failed"
cat test_possible_paths.txt
cat "$DIR_TESTS/paths.txt"
exit 255
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci_test_flat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ solc-select use 0.8.19 --always-install

cd examples/flat || exit 1

if ! slither-flat b.sol; then
echo "slither-flat failed"
if ! slither flat b.sol; then
echo "slither flat failed"
exit 1
fi

Expand Down
28 changes: 14 additions & 14 deletions scripts/ci_test_interface.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ DIR_TESTS="tests/tools/interface"
solc-select use 0.8.19 --always-install

#Test 1 - Etherscan target
slither-interface WETH9 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
slither interface WETH9 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
DIFF=$(diff crytic-export/interfaces/IWETH9.sol "$DIR_TESTS/test_1.sol" --strip-trailing-cr)
if [ "$DIFF" != "" ]
then
echo "slither-interface test 1 failed"
echo "slither interface test 1 failed"
cat "crytic-export/interfaces/IWETH9.sol"
echo ""
cat "$DIR_TESTS/test_1.sol"
Expand All @@ -20,11 +20,11 @@ fi


#Test 2 - Local file target
slither-interface Mock tests/tools/interface/ContractMock.sol
slither interface Mock tests/tools/interface/ContractMock.sol
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_2.sol" --strip-trailing-cr)
if [ "$DIFF" != "" ]
then
echo "slither-interface test 2 failed"
echo "slither interface test 2 failed"
cat "crytic-export/interfaces/IMock.sol"
echo ""
cat "$DIR_TESTS/test_2.sol"
Expand All @@ -33,59 +33,59 @@ fi


#Test 3 - unroll structs
slither-interface Mock tests/tools/interface/ContractMock.sol --unroll-structs
slither interface Mock tests/tools/interface/ContractMock.sol --unroll-structs
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_3.sol" --strip-trailing-cr)
if [ "$DIFF" != "" ]
then
echo "slither-interface test 3 failed"
echo "slither interface test 3 failed"
cat "crytic-export/interfaces/IMock.sol"
echo ""
cat "$DIR_TESTS/test_3.sol"
exit 255
fi

#Test 4 - exclude structs
slither-interface Mock tests/tools/interface/ContractMock.sol --exclude-structs
slither interface Mock tests/tools/interface/ContractMock.sol --exclude-structs
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_4.sol" --strip-trailing-cr)
if [ "$DIFF" != "" ]
then
echo "slither-interface test 4 failed"
echo "slither interface test 4 failed"
cat "crytic-export/interfaces/IMock.sol"
echo ""
cat "$DIR_TESTS/test_4.sol"
exit 255
fi

#Test 5 - exclude errors
slither-interface Mock tests/tools/interface/ContractMock.sol --exclude-errors
slither interface Mock tests/tools/interface/ContractMock.sol --exclude-errors
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_5.sol" --strip-trailing-cr)
if [ "$DIFF" != "" ]
then
echo "slither-interface test 5 failed"
echo "slither interface test 5 failed"
cat "crytic-export/interfaces/IMock.sol"
echo ""
cat "$DIR_TESTS/test_5.sol"
exit 255
fi

#Test 6 - exclude enums
slither-interface Mock tests/tools/interface/ContractMock.sol --exclude-enums
slither interface Mock tests/tools/interface/ContractMock.sol --exclude-enums
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_6.sol" --strip-trailing-cr)
if [ "$DIFF" != "" ]
then
echo "slither-interface test 6 failed"
echo "slither interface test 6 failed"
cat "crytic-export/interfaces/IMock.sol"
echo ""
cat "$DIR_TESTS/test_6.sol"
exit 255
fi

#Test 7 - exclude events
slither-interface Mock tests/tools/interface/ContractMock.sol --exclude-events
slither interface Mock tests/tools/interface/ContractMock.sol --exclude-events
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_7.sol" --strip-trailing-cr)
if [ "$DIFF" != "" ]
then
echo "slither-interface test 7 failed"
echo "slither interface test 7 failed"
cat "crytic-export/interfaces/IMock.sol"
echo ""
cat "$DIR_TESTS/test_7.sol"
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci_test_kspec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
DIR_TESTS="tests/check-kspec"

solc-select use "0.5.0"
slither-check-kspec "$DIR_TESTS/safeAdd/safeAdd.sol" "$DIR_TESTS/safeAdd/spec.md" > test_1.txt 2>&1
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
echo "slither-check-kspec 1 failed"
echo "slither check-kspec 1 failed"
cat test_1.txt
echo ""
cat "$DIR_TESTS/test_1.txt"
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_test_path_filtering.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Test path filtering across POSIX and Windows

solc-select use 0.8.0
slither "tests/e2e/config/test_path_filtering/test_path_filtering.sol" --config "tests/e2e/config/test_path_filtering/slither.config.json" > "output.txt" 2>&1
slither detect "tests/e2e/config/test_path_filtering/test_path_filtering.sol" --config "tests/e2e/config/test_path_filtering/slither.config.json" > "output.txt" 2>&1

if ! grep -q "0 result(s) found" "output.txt"
then
Expand Down
6 changes: 3 additions & 3 deletions scripts/ci_test_printers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ALL_PRINTERS="cfg,constructor-calls,contract-summary,data-dependency,echidna,fun

# Only test 0.5.17 to limit test time
for file in *0.5.17-compact.zip; do
if ! slither "$file" --print "$ALL_PRINTERS" ; then
if ! slither print "$file" --print "$ALL_PRINTERS" ; then
echo "Printer failed"
echo "$file"
exit 1
Expand All @@ -18,7 +18,7 @@ done

# Only test 0.8.12 to limit test time
for file in *0.8.12-compact.zip; do
if ! slither "$file" --print "declaration" ; then
if ! slither print "$file" --print "declaration" ; then
echo "Printer failed"
echo "$file"
exit 1
Expand All @@ -29,6 +29,6 @@ cd ../../.. || exit
# Needed for evm printer
pip install evm-cfg-builder
solc-select use "0.5.1"
if ! slither examples/scripts/test_evm_api.sol --print evm; then
if ! slither print examples/scripts/test_evm_api.sol --print evm; then
echo "EVM printer failed"
fi
4 changes: 2 additions & 2 deletions scripts/ci_test_prop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
### Test slither-prop

cd examples/slither-prop || exit 1
slither-prop . --contract ERC20Buggy
slither prop . --contract ERC20Buggy
if [ ! -f contracts/crytic/TestERC20BuggyTransferable.sol ]; then
echo "slither-prop failed"
echo "slither prop failed"
return 1
fi
6 changes: 3 additions & 3 deletions scripts/ci_test_simil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
pip3.8 install pybind11
pip3.8 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip

### Test slither-simil
### Test slither simil

solc-select use "0.4.25"

DIR_TESTS="tests/simil"
slither-simil info "" --filename $DIR_TESTS/../complex_func.sol --fname Complex.complexExternalWrites > 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
echo "slither-simil failed"
echo "slither simil failed"
cat test_1.txt
cat "$DIR_TESTS/test_1.txt"
exit 255
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_test_slither_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Test

if ! slither "tests/*.json" --config "tests/config/slither.config.json"; then
if ! slither --config-file "tests/config/slither.config.json" detect "tests/*.json"; then
echo "Config failed"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci_test_truffle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nvm use --lts
npm install -g truffle
truffle unbox metacoin

if ! slither . --no-fail-pedantic; then
if ! slither detect . --no-fail-pedantic; then
echo "Truffle test failed"
exit 1
fi
Expand Down
Loading