linting: Solve shell linting errors

pull/555/head
Emilio López 4 years ago
parent e9f4283323
commit 3f2527f227
  1. 1
      scripts/fix_travis_relative_paths.sh
  2. 6
      scripts/tests_generate_expected_json_4.sh
  3. 6
      scripts/tests_generate_expected_json_5.sh
  4. 6
      scripts/travis_test_4.sh
  5. 15
      scripts/travis_test_5.sh
  6. 14
      scripts/travis_test_cli.sh
  7. 9
      scripts/travis_test_dapp.sh
  8. 4
      scripts/travis_test_data_dependency.sh
  9. 9
      scripts/travis_test_embark.sh
  10. 5
      scripts/travis_test_erc.sh
  11. 7
      scripts/travis_test_etherlime.sh
  12. 10
      scripts/travis_test_etherscan.sh
  13. 4
      scripts/travis_test_find_paths.sh
  14. 4
      scripts/travis_test_kspec.sh
  15. 4
      scripts/travis_test_printers.sh
  16. 4
      scripts/travis_test_prop.sh
  17. 4
      scripts/travis_test_simil.sh
  18. 6
      scripts/travis_test_slither_config.sh
  19. 7
      scripts/travis_test_truffle.sh
  20. 34
      scripts/travis_test_upgradability.sh

@ -1,3 +1,4 @@
#!/bin/sh
CURRENT_PATH=$(pwd)
TRAVIS_PATH='/home/travis/build/crytic/slither'
for f in tests/expected_json/*json; do

@ -9,11 +9,11 @@ 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"
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.4.25 > $output_filename_txt 2>&1
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

@ -10,11 +10,11 @@ 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"
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
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

@ -9,14 +9,14 @@ TRAVIS_PATH='/home/travis/build/crytic/slither'
# test_slither file.sol detectors
test_slither(){
expected="$DIR/../tests/expected_json/$(basename $1 .sol).$2.json"
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 -1
exit 255
fi
if [ ! -f "$DIR/tmp-test.json" ]; then
@ -44,7 +44,7 @@ test_slither(){
if [ $? -eq 255 ]
then
echo "Slither crashed"
exit -1
exit 255
fi
if [ ! -f "$DIR/tmp-test.json" ]; then

@ -10,14 +10,14 @@ TRAVIS_PATH='/home/travis/build/crytic/slither'
# test_slither file.sol detectors
test_slither(){
expected="$DIR/../tests/expected_json/$(basename $1 .sol).$2.json"
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
exit 255
fi
if [ ! -f "$DIR/tmp-test.json" ]; then
@ -44,7 +44,7 @@ test_slither(){
if [ $? -eq 255 ]
then
echo "Slither crashed"
exit -1
exit 255
fi
if [ ! -f "$DIR/tmp-test.json" ]; then
@ -102,18 +102,15 @@ 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
if ! python examples/scripts/functions_called.py examples/scripts/functions_called.sol; then
exit 1
fi
python examples/scripts/functions_writing.py examples/scripts/functions_writing.sol
if [ $? -ne 0 ]; then
if ! python examples/scripts/functions_writing.py examples/scripts/functions_writing.sol; then
exit 1
fi
python examples/scripts/variable_in_condition.py examples/scripts/variable_in_condition.sol
if [ $? -ne 0 ]; then
if ! python examples/scripts/variable_in_condition.py examples/scripts/variable_in_condition.sol; then
exit 1
fi
exit 0

@ -1,24 +1,18 @@
#!/usr/bin/env bash
### Test
### Test
slither "tests/*.json" --solc-ast --ignore-return-value
if [ $? -ne 0 ]; then
if ! slither "tests/*.json" --solc-ast --ignore-return-value; then
echo "--solc-ast failed"
exit 1
fi
slither "tests/*0.5*.sol" --solc-disable-warnings --ignore-return-value
if [ $? -ne 0 ]; then
if ! slither "tests/*0.5*.sol" --solc-disable-warnings --ignore-return-value; then
echo "--solc-disable-warnings failed"
exit 1
fi
slither "tests/*0.5*.sol" --disable-color --ignore-return-value
if [ $? -ne 0 ]; then
if ! slither "tests/*0.5*.sol" --disable-color --ignore-return-value; then
echo "--disable-color failed"
exit 1
fi

@ -3,18 +3,19 @@
### Test Dapp integration
mkdir test_dapp
cd test_dapp
cd test_dapp || exit 255
# The dapp init process makes a temporary local git repo and needs certain values to be set
git config --global user.email "ci@trailofbits.com"
git config --global user.name "CI User"
curl https://nixos.org/nix/install | sh
# shellcheck disable=SC1090
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
nix-env -iA nixpkgs.cachix
cachix use dapp
git clone --recursive https://github.com/dapphub/dapptools $HOME/.dapp/dapptools
nix-env -f $HOME/.dapp/dapptools -iA dapp seth solc hevm ethsign
git clone --recursive https://github.com/dapphub/dapptools "$HOME/.dapp/dapptools"
nix-env -f "$HOME/.dapp/dapptools" -iA dapp seth solc hevm ethsign
dapp init
@ -26,4 +27,4 @@ then
fi
echo "Truffle test failed"
exit -1
exit 255

@ -2,9 +2,7 @@
### Test data dependecy
python ./examples/scripts/data_dependency.py ./examples/scripts/data_dependency.sol
if [ $? -ne 0 ]; then
if ! python ./examples/scripts/data_dependency.py ./examples/scripts/data_dependency.sol; then
echo "data dependency failed"
exit 1
fi

@ -3,24 +3,25 @@
### Test embark integration
mkdir test_embark
cd test_embark
cd test_embark || exit 255
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
# shellcheck disable=SC1090
source ~/.nvm/nvm.sh
nvm install 10.17.0
nvm use 10.17.0
npm install -g embark@4.2.0
embark demo
cd embark_demo
cd embark_demo || exit 255
npm install
slither . --embark-overwrite-config
if [ $? -eq 3 ]
then
then
exit 0
fi
echo "Embark test failed"
exit -1
exit 255

@ -6,15 +6,14 @@ DIR_TESTS="tests/check-erc"
slither-check-erc "$DIR_TESTS/erc20.sol" ERC20 --solc solc-0.5.0 > test_1.txt 2>&1
DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt")
if [ "$DIFF" != "" ]
if [ "$DIFF" != "" ]
then
echo "slither-check-erc 1 failed"
cat test_1.txt
echo ""
cat "$DIR_TESTS/test_1.txt"
exit -1
exit 255
fi
rm test_1.txt

@ -3,9 +3,10 @@
### Test etherlime integration
mkdir test_etherlime
cd test_etherlime
cd test_etherlime || exit 255
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
# shellcheck disable=SC1090
source ~/.nvm/nvm.sh
nvm install 10.17.0
nvm use 10.17.0
@ -15,9 +16,9 @@ etherlime init
slither .
if [ $? -eq 6 ]
then
then
exit 0
fi
echo "Etherlime test failed"
exit -1
exit 255

@ -3,24 +3,24 @@
### Test etherscan integration
mkdir etherscan
cd 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
slither 0x7F37f78cBD74481E593F9C737776F7113d76B315 --solc "./solc-0.4.25" --etherscan-apikey "$GITHUB_ETHERSCAN"
if [ $? -ne 5 ]
then
echo "Etherscan test failed"
exit -1
exit 255
fi
slither rinkeby:0xFe05820C5A92D9bc906D4A46F662dbeba794d3b7 --solc "./solc-0.4.25" --etherscan-apikey $GITHUB_ETHERSCAN
slither rinkeby:0xFe05820C5A92D9bc906D4A46F662dbeba794d3b7 --solc "./solc-0.4.25" --etherscan-apikey "$GITHUB_ETHERSCAN"
if [ $? -ne 70 ]
then
echo "Etherscan test failed"
exit -1
exit 255
fi

@ -6,11 +6,11 @@ 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
DIFF=$(diff test_possible_paths.txt "$DIR_TESTS/paths.txt")
if [ "$DIFF" != "" ]
if [ "$DIFF" != "" ]
then
echo "slither-find-paths failed"
cat test_possible_paths.txt
cat "$DIR_TESTS/paths.txt"
exit -1
exit 255
fi
rm test_possible_paths.txt

@ -4,13 +4,13 @@ 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
DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt")
if [ "$DIFF" != "" ]
if [ "$DIFF" != "" ]
then
echo "slither-check-upgradeability 1 failed"
cat test_1.txt
echo ""
cat "$DIR_TESTS/test_1.txt"
exit -1
exit 255
fi
rm test_1.txt

@ -5,9 +5,7 @@
# Needed for evm printer
pip install evm-cfg-builder
slither "tests/*.json" --print all --json -
if [ $? -ne 0 ]; then
if ! slither "tests/*.json" --print all --json -; then
echo "Printer tests failed"
exit 1
fi

@ -1,8 +1,8 @@
#!/usr/bin/env bash
### Test slither-prop
### Test slither-prop
cd examples/slither-prop
cd examples/slither-prop || exit 1
slither-prop . --contract ERC20Buggy
if [ ! -f contracts/crytic/TestERC20BuggyTransferable.sol ]; then
echo "slither-prop failed"

@ -10,12 +10,12 @@ pip3.6 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip
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
DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt")
if [ "$DIFF" != "" ]
if [ "$DIFF" != "" ]
then
echo "slither-simil failed"
cat test_1.txt
cat "$DIR_TESTS/test_1.txt"
exit -1
exit 255
fi
rm test_1.txt

@ -1,10 +1,8 @@
#!/usr/bin/env bash
### Test
### Test
slither "tests/*.json" --config "tests/config/slither.config.json"
if [ $? -ne 0 ]; then
if ! slither "tests/*.json" --config "tests/config/slither.config.json"; then
echo "Config failed"
exit 1
fi

@ -3,9 +3,10 @@
### Test truffle integration
mkdir test_truffle
cd test_truffle
cd test_truffle || exit 255
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
# shellcheck disable=SC1090
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
@ -15,9 +16,9 @@ truffle unbox metacoin
slither .
if [ $? -eq 5 ]
then
then
exit 0
fi
echo "Truffle test failed"
exit -1
exit 255

@ -6,51 +6,51 @@ DIR_TESTS="tests/check-upgradeability"
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
DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt")
if [ "$DIFF" != "" ]
if [ "$DIFF" != "" ]
then
echo "slither-check-upgradeability 1 failed"
cat test_1.txt
echo ""
cat "$DIR_TESTS/test_1.txt"
exit -1
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
DIFF=$(diff test_2.txt "$DIR_TESTS/test_2.txt")
if [ "$DIFF" != "" ]
if [ "$DIFF" != "" ]
then
echo "slither-check-upgradeability 2 failed"
cat test_2.txt
echo ""
cat "$DIR_TESTS/test_2.txt"
exit -1
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
DIFF=$(diff test_3.txt "$DIR_TESTS/test_3.txt")
if [ "$DIFF" != "" ]
if [ "$DIFF" != "" ]
then
echo "slither-check-upgradeability 3 failed"
cat test_3.txt
echo ""
cat "$DIR_TESTS/test_3.txt"
exit -1
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
DIFF=$(diff test_4.txt "$DIR_TESTS/test_4.txt")
if [ "$DIFF" != "" ]
if [ "$DIFF" != "" ]
then
echo "slither-check-upgradeability 4 failed"
cat test_4.txt
echo ""
cat "$DIR_TESTS/test_4.txt"
exit -1
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
DIFF=$(diff test_5.txt "$DIR_TESTS/test_5.txt")
if [ "$DIFF" != "" ]
if [ "$DIFF" != "" ]
then
echo "slither-check-upgradeability 5 failed"
cat test_5.txt
@ -58,7 +58,7 @@ then
cat "$DIR_TESTS/test_5.txt"
echo ""
echo "$DIFF"
exit -1
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
@ -71,7 +71,7 @@ then
cat "$DIR_TESTS/test_5.txt"
echo ""
echo "$DIFF"
exit -1
exit 255
fi
@ -85,7 +85,7 @@ then
cat "$DIR_TESTS/test_6.txt"
echo ""
echo "$DIFF"
exit -1
exit 255
fi
@ -99,7 +99,7 @@ then
cat "$DIR_TESTS/test_7.txt"
echo ""
echo "$DIFF"
exit -1
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
@ -112,7 +112,7 @@ then
cat "$DIR_TESTS/test_8.txt"
echo ""
echo "$DIFF"
exit -1
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
@ -125,7 +125,7 @@ then
cat "$DIR_TESTS/test_9.txt"
echo ""
echo "$DIFF"
exit -1
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
@ -138,7 +138,7 @@ then
cat "$DIR_TESTS/test_10.txt"
echo ""
echo "$DIFF"
exit -1
exit 255
fi
slither-check-upgradeability "$DIR_TESTS/contract_v1_var_init.sol" ContractV1 --solc solc-0.5.0 > test_11.txt 2>&1
@ -151,7 +151,7 @@ then
cat "$DIR_TESTS/test_11.txt"
echo ""
echo "$DIFF"
exit -1
exit 255
fi
rm test_1.txt

Loading…
Cancel
Save