mirror of https://github.com/crytic/slither
commit
4524bd958d
@ -0,0 +1,44 @@ |
|||||||
|
--- |
||||||
|
name: Detectors tests |
||||||
|
|
||||||
|
defaults: |
||||||
|
run: |
||||||
|
# To load bashrc |
||||||
|
shell: bash -ieo pipefail {0} |
||||||
|
|
||||||
|
on: |
||||||
|
pull_request: |
||||||
|
branches: [master, dev] |
||||||
|
schedule: |
||||||
|
# run CI every day even if no PRs/merges occur |
||||||
|
- cron: '0 12 * * *' |
||||||
|
|
||||||
|
jobs: |
||||||
|
build: |
||||||
|
name: Detectors tests |
||||||
|
runs-on: ubuntu-latest |
||||||
|
|
||||||
|
steps: |
||||||
|
- name: Checkout Code |
||||||
|
uses: actions/checkout@v2 |
||||||
|
|
||||||
|
- name: Set up Python 3.6 |
||||||
|
uses: actions/setup-python@v2 |
||||||
|
with: |
||||||
|
python-version: 3.6 |
||||||
|
|
||||||
|
- name: Install dependencies |
||||||
|
run: | |
||||||
|
python setup.py install |
||||||
|
pip install deepdiff |
||||||
|
pip install pytest |
||||||
|
|
||||||
|
git clone https://github.com/crytic/solc-select.git |
||||||
|
./solc-select/scripts/install.sh |
||||||
|
export PATH=/home/runner/.solc-select:$PATH |
||||||
|
echo "export PATH=/home/runner/.solc-select:$PATH" >> ~/.bashrc |
||||||
|
|
||||||
|
- name: Test with pytest |
||||||
|
run: | |
||||||
|
pytest tests/test_detectors.py |
||||||
|
|
@ -0,0 +1,44 @@ |
|||||||
|
--- |
||||||
|
name: Parser tests |
||||||
|
|
||||||
|
defaults: |
||||||
|
run: |
||||||
|
# To load bashrc |
||||||
|
shell: bash -ieo pipefail {0} |
||||||
|
|
||||||
|
on: |
||||||
|
pull_request: |
||||||
|
branches: [master, dev] |
||||||
|
schedule: |
||||||
|
# run CI every day even if no PRs/merges occur |
||||||
|
- cron: '0 12 * * *' |
||||||
|
|
||||||
|
jobs: |
||||||
|
build: |
||||||
|
name: Parser tests |
||||||
|
runs-on: ubuntu-latest |
||||||
|
|
||||||
|
steps: |
||||||
|
- name: Checkout Code |
||||||
|
uses: actions/checkout@v2 |
||||||
|
|
||||||
|
- name: Set up Python 3.6 |
||||||
|
uses: actions/setup-python@v2 |
||||||
|
with: |
||||||
|
python-version: 3.6 |
||||||
|
|
||||||
|
- name: Install dependencies |
||||||
|
run: | |
||||||
|
python setup.py install |
||||||
|
pip install deepdiff |
||||||
|
pip install pytest |
||||||
|
|
||||||
|
git clone https://github.com/crytic/solc-select.git |
||||||
|
./solc-select/scripts/install.sh |
||||||
|
export PATH=/home/runner/.solc-select:$PATH |
||||||
|
echo "export PATH=/home/runner/.solc-select:$PATH" >> ~/.bashrc |
||||||
|
|
||||||
|
- name: Test with pytest |
||||||
|
run: | |
||||||
|
pytest tests/test_ast_parsing.py |
||||||
|
|
@ -1,47 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
source "$(dirname "$0")""/ci_test.sh" |
|
||||||
|
|
||||||
solc use "0.4.25" |
|
||||||
|
|
||||||
# Be sure that only one of the following line is uncommented before running the script |
|
||||||
|
|
||||||
|
|
||||||
#generate_expected_json tests/deprecated_calls.sol "deprecated-standards" |
|
||||||
#generate_expected_json tests/erc20_indexed.sol "erc20-indexed" |
|
||||||
#generate_expected_json tests/incorrect_erc20_interface.sol "erc20-interface" |
|
||||||
#generate_expected_json tests/incorrect_erc721_interface.sol "erc721-interface" |
|
||||||
#generate_expected_json tests/uninitialized.sol "uninitialized-state" |
|
||||||
#generate_expected_json tests/backdoor.sol "backdoor" |
|
||||||
#generate_expected_json tests/backdoor.sol "suicidal" |
|
||||||
#generate_expected_json tests/pragma.0.4.24.sol "pragma" |
|
||||||
#generate_expected_json tests/old_solc.sol.json "solc-version" |
|
||||||
#generate_expected_json tests/reentrancy.sol "reentrancy-eth" |
|
||||||
#generate_expected_json tests/reentrancy.sol "reentrancy-unlimited-gas" |
|
||||||
#generate_expected_json tests/uninitialized_storage_pointer.sol "uninitialized-storage" |
|
||||||
#generate_expected_json tests/tx_origin.sol "tx-origin" |
|
||||||
#generate_expected_json tests/unused_state.sol "unused-state" |
|
||||||
#generate_expected_json tests/locked_ether.sol "locked-ether" |
|
||||||
#generate_expected_json tests/arbitrary_send.sol "arbitrary-send" |
|
||||||
#generate_expected_json tests/inline_assembly_contract.sol "assembly" |
|
||||||
#generate_expected_json tests/inline_assembly_library.sol "assembly" |
|
||||||
#generate_expected_json tests/low_level_calls.sol "low-level-calls" |
|
||||||
#generate_expected_json tests/const_state_variables.sol "constable-states" |
|
||||||
#generate_expected_json tests/external_function.sol "external-function" |
|
||||||
#generate_expected_json tests/external_function_2.sol "external-function" |
|
||||||
#generate_expected_json tests/naming_convention.sol "naming-convention" |
|
||||||
#generate_expected_json tests/uninitialized_local_variable.sol "uninitialized-local" |
|
||||||
#generate_expected_json tests/controlled_delegatecall.sol "controlled-delegatecall" |
|
||||||
#generate_expected_json tests/constant.sol "constant-function-asm" |
|
||||||
#generate_expected_json tests/constant.sol "constant-function-state" |
|
||||||
#generate_expected_json tests/unused_return.sol "unused-return" |
|
||||||
#generate_expected_json tests/shadowing_state_variable.sol "shadowing-state" |
|
||||||
#generate_expected_json tests/shadowing_abstract.sol "shadowing-abstract" |
|
||||||
#generate_expected_json tests/timestamp.sol "timestamp" |
|
||||||
#generate_expected_json tests/multiple_calls_in_loop.sol "calls-loop" |
|
||||||
#generate_expected_json tests/shadowing_builtin_symbols.sol "shadowing-builtin" |
|
||||||
#generate_expected_json tests/shadowing_local_variable.sol "shadowing-local" |
|
||||||
#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" |
|
||||||
|
|
@ -1,28 +0,0 @@ |
|||||||
#!/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" |
|
||||||
|
|
@ -1,11 +0,0 @@ |
|||||||
#!/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" |
|
||||||
|
|
@ -1,11 +0,0 @@ |
|||||||
#!/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" |
|
||||||
|
|
@ -1,42 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
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" |
|
||||||
test_slither tests/erc20_indexed.sol "erc20-indexed" |
|
||||||
test_slither tests/incorrect_erc20_interface.sol "erc20-interface" |
|
||||||
test_slither tests/incorrect_erc721_interface.sol "erc721-interface" |
|
||||||
test_slither tests/uninitialized.sol "uninitialized-state" |
|
||||||
test_slither tests/backdoor.sol "backdoor" |
|
||||||
test_slither tests/backdoor.sol "suicidal" |
|
||||||
test_slither tests/pragma.0.4.24.sol "pragma" |
|
||||||
test_slither tests/old_solc.sol.json "solc-version" |
|
||||||
test_slither tests/reentrancy.sol "reentrancy-eth" |
|
||||||
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/external_function_2.sol "external-function" |
|
||||||
test_slither tests/naming_convention.sol "naming-convention" |
|
||||||
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" |
|
||||||
test_slither tests/constant.sol "constant-function-state" |
|
||||||
test_slither tests/unused_return.sol "unused-return" |
|
||||||
test_slither tests/shadowing_abstract.sol "shadowing-abstract" |
|
||||||
test_slither tests/shadowing_state_variable.sol "shadowing-state" |
|
||||||
test_slither tests/timestamp.sol "timestamp" |
|
||||||
test_slither tests/multiple_calls_in_loop.sol "calls-loop" |
|
||||||
test_slither tests/shadowing_builtin_symbols.sol "shadowing-builtin" |
|
||||||
test_slither tests/shadowing_local_variable.sol "shadowing-local" |
|
||||||
test_slither tests/solc_version_incorrect.sol "solc-version" |
|
||||||
test_slither tests/right_to_left_override.sol "rtlo" |
|
@ -1,51 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
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" |
|
||||||
test_slither tests/unchecked_lowlevel-0.5.1.sol "unchecked-lowlevel" |
|
||||||
test_slither tests/unchecked_send-0.5.1.sol "unchecked-send" |
|
||||||
test_slither tests/uninitialized-0.5.1.sol "uninitialized-state" |
|
||||||
test_slither tests/backdoor.sol "backdoor" |
|
||||||
test_slither tests/backdoor.sol "suicidal" |
|
||||||
test_slither tests/old_solc.sol.json "solc-version" |
|
||||||
test_slither tests/reentrancy-0.5.1.sol "reentrancy-eth" |
|
||||||
test_slither tests/reentrancy-0.5.1-events.sol "reentrancy-events" |
|
||||||
test_slither tests/tx_origin-0.5.1.sol "tx-origin" |
|
||||||
test_slither tests/unused_state.sol "unused-state" |
|
||||||
test_slither tests/locked_ether-0.5.1.sol "locked-ether" |
|
||||||
test_slither tests/arbitrary_send-0.5.1.sol "arbitrary-send" |
|
||||||
test_slither tests/inline_assembly_contract-0.5.1.sol "assembly" |
|
||||||
test_slither tests/inline_assembly_library-0.5.1.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/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/constant-0.5.1.sol "constant-function-asm" |
|
||||||
test_slither tests/constant-0.5.1.sol "constant-function-state" |
|
||||||
test_slither tests/unused_return.sol "unused-return" |
|
||||||
test_slither tests/timestamp.sol "timestamp" |
|
||||||
test_slither tests/incorrect_equality.sol "incorrect-equality" |
|
||||||
test_slither tests/too_many_digits.sol "too-many-digits" |
|
||||||
|
|
||||||
|
|
||||||
### Test scripts |
|
||||||
|
|
||||||
if ! python examples/scripts/functions_called.py examples/scripts/functions_called.sol; then |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
if ! python examples/scripts/functions_writing.py examples/scripts/functions_writing.sol; then |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
|
|
||||||
if ! python examples/scripts/variable_in_condition.py examples/scripts/variable_in_condition.sol; then |
|
||||||
exit 1 |
|
||||||
fi |
|
||||||
exit 0 |
|
@ -1,7 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
|
|
||||||
source "$(dirname "$0")""/ci_test.sh" |
|
||||||
|
|
||||||
solc use "0.6.11" |
|
||||||
|
|
||||||
# test_slither tests/filename.sol "detector_name" |
|
@ -1,7 +0,0 @@ |
|||||||
#!/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,26 @@ |
|||||||
|
from enum import Enum |
||||||
|
|
||||||
|
# pylint: disable=comparison-with-callable |
||||||
|
|
||||||
|
|
||||||
|
class ComparableEnum(Enum): |
||||||
|
def __eq__(self, other): |
||||||
|
if isinstance(other, ComparableEnum): |
||||||
|
return self.value == other.value |
||||||
|
return False |
||||||
|
|
||||||
|
def __ne__(self, other): |
||||||
|
if isinstance(other, ComparableEnum): |
||||||
|
return self.value != other.value |
||||||
|
return False |
||||||
|
|
||||||
|
def __lt__(self, other): |
||||||
|
if isinstance(other, ComparableEnum): |
||||||
|
return self.value < other.value |
||||||
|
return False |
||||||
|
|
||||||
|
def __repr__(self): |
||||||
|
return "%s" % (str(self.value)) |
||||||
|
|
||||||
|
def __hash__(self): |
||||||
|
return hash(self.value) |
@ -0,0 +1,11 @@ |
|||||||
|
contract C { |
||||||
|
function f() public { |
||||||
|
assembly { |
||||||
|
let x := 0 |
||||||
|
} |
||||||
|
|
||||||
|
assembly "evmasm" { |
||||||
|
let x := 0 |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
contract C { |
||||||
|
function f() public { |
||||||
|
uint assign; |
||||||
|
assign = 10; |
||||||
|
|
||||||
|
assign |= 10; |
||||||
|
assign ^= 10; |
||||||
|
assign &= 10; |
||||||
|
assign += 10; |
||||||
|
assign -= 10; |
||||||
|
assign *= 10; |
||||||
|
assign /= 10; |
||||||
|
assign %= 10; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
contract C { |
||||||
|
function f() public { |
||||||
|
uint assign; |
||||||
|
assign = 10; |
||||||
|
|
||||||
|
assign |= 10; |
||||||
|
assign ^= 10; |
||||||
|
assign &= 10; |
||||||
|
assign <<= 10; |
||||||
|
assign >>= 10; |
||||||
|
assign += 10; |
||||||
|
assign -= 10; |
||||||
|
assign *= 10; |
||||||
|
assign /= 10; |
||||||
|
assign %= 10; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
contract C { |
||||||
|
function f() public { |
||||||
|
1**2; |
||||||
|
1*2; |
||||||
|
1/2; |
||||||
|
1&2; |
||||||
|
1+2; |
||||||
|
1-2; |
||||||
|
1 & 2; |
||||||
|
1 ^ 2; |
||||||
|
1 | 2; |
||||||
|
1 < 2; |
||||||
|
1 > 2; |
||||||
|
1 <= 2; |
||||||
|
1 >= 2; |
||||||
|
1 == 2; |
||||||
|
1 != 2; |
||||||
|
true && false; |
||||||
|
true || false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
contract C { |
||||||
|
function f() public { |
||||||
|
1**2; |
||||||
|
1*2; |
||||||
|
1/2; |
||||||
|
1&2; |
||||||
|
1+2; |
||||||
|
1-2; |
||||||
|
1 << 2; |
||||||
|
1 >> 2; |
||||||
|
1 & 2; |
||||||
|
1 ^ 2; |
||||||
|
1 | 2; |
||||||
|
1 < 2; |
||||||
|
1 > 2; |
||||||
|
1 <= 2; |
||||||
|
1 >= 2; |
||||||
|
1 == 2; |
||||||
|
1 != 2; |
||||||
|
true && false; |
||||||
|
true || false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
contract C { |
||||||
|
function f() public { |
||||||
|
uint c; |
||||||
|
|
||||||
|
for (uint i = 0; i < 10; i++) { |
||||||
|
if (i % 2 == 0) { |
||||||
|
break; |
||||||
|
} |
||||||
|
c++; |
||||||
|
} |
||||||
|
|
||||||
|
for (uint j = 0; j < 10; j++) { |
||||||
|
for (uint k = 0; k < 10; k++) { |
||||||
|
if (j % 2 == 0 && k % 3 == 0) { |
||||||
|
break; |
||||||
|
} |
||||||
|
c++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
contract C { |
||||||
|
function f() public { |
||||||
|
false ? 1 : 2; |
||||||
|
5 == 6 ? 1 : 2; |
||||||
|
1 + 2 == 3 ? 4 + 5 == 6 ? int8(0) : -1 : -2; |
||||||
|
true ? "a" : "b"; |
||||||
|
false ? (1, 2) : (3, 4); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
contract C { |
||||||
|
function f() public { |
||||||
|
uint c; |
||||||
|
|
||||||
|
for (uint i = 0; i < 10; i++) { |
||||||
|
if (i % 2 == 0) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
c++; |
||||||
|
} |
||||||
|
|
||||||
|
for (uint j = 0; j < 10; j++) { |
||||||
|
for (uint k = 0; k < 10; k++) { |
||||||
|
if (j % 2 == 0 && k % 3 == 0) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
c++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
|
||||||
|
// a simple contract |
||||||
|
contract A { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// inheritance, no constructor |
||||||
|
contract B is A { |
||||||
|
function B(uint a) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// inheritance, init in inheritance |
||||||
|
contract C is B(4) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// inheritance, init in constructor |
||||||
|
contract D is B { |
||||||
|
function D() B(2) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// abstract contract |
||||||
|
contract E is B { |
||||||
|
} |
||||||
|
|
||||||
|
// diamond inheritance |
||||||
|
contract F is A {} |
||||||
|
contract G is A {} |
||||||
|
contract H is F, G { |
||||||
|
|
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue