mirror of https://github.com/crytic/slither
Merge pull request #102 from trailofbits/dev-solidity-05
Improve support for Solidity > 0.5pull/108/head
commit
fed11e9cf6
@ -1,38 +0,0 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)" |
||||
|
||||
# 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="$(basename $1 .sol).$2.json" |
||||
|
||||
# run slither detector on input file and save output as json |
||||
slither "$1" --disable-solc-warnings --detect "$2" --json "$DIR/../tests/expected_json/$output_filename" |
||||
|
||||
} |
||||
|
||||
#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" |
||||
#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/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" |
||||
|
||||
#generate_expected_json tests/unused_return.sol "unused-return" |
@ -0,0 +1,38 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)" |
||||
|
||||
# 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="$(basename $1 .sol).$2.json" |
||||
|
||||
# run slither detector on input file and save output as json |
||||
slither "$1" --disable-solc-warnings --detect "$2" --json "$DIR/../tests/expected_json/$output_filename" --solc solc-0.4.25 |
||||
|
||||
} |
||||
|
||||
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" |
||||
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/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" |
||||
|
||||
generate_expected_json tests/unused_return.sol "unused-return" |
@ -0,0 +1,29 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)" |
||||
|
||||
# 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="$(basename $1 .sol).$2.json" |
||||
|
||||
# run slither detector on input file and save output as json |
||||
slither "$1" --disable-solc-warnings --detect "$2" --json "$DIR/../tests/expected_json/$output_filename" --solc solc-0.5.1 |
||||
|
||||
} |
||||
|
||||
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/pragma.0.4.24.sol "pragma" |
||||
#generate_expected_json tests/old_solc.sol.json "solc-version" |
||||
generate_expected_json tests/reentrancy-0.5.1.sol "reentrancy" |
||||
#generate_expected_json tests/uninitialized_storage_pointer.sol "uninitialized-storage" |
||||
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" |
@ -0,0 +1,105 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
### Test Detectors |
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)" |
||||
|
||||
# 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" --disable-solc-warnings --detect "$2" --json "$DIR/tmp-test.json" --solc solc-0.5.1 |
||||
if [ $? -eq 255 ] |
||||
then |
||||
echo "Slither crashed" |
||||
exit -1 |
||||
fi |
||||
|
||||
if [ ! -f "$DIR/tmp-test.json" ]; then |
||||
echo "" |
||||
echo "Missing generated file" |
||||
echo "" |
||||
exit 1 |
||||
fi |
||||
|
||||
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" --disable-solc-warnings --detect "$2" --compact-ast --json "$DIR/tmp-test.json" --solc solc-0.5.1 |
||||
if [ $? -eq 255 ] |
||||
then |
||||
echo "Slither crashed" |
||||
exit -1 |
||||
fi |
||||
|
||||
if [ ! -f "$DIR/tmp-test.json" ]; then |
||||
echo "" |
||||
echo "Missing generated file" |
||||
echo "" |
||||
exit 1 |
||||
fi |
||||
|
||||
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 |
||||
} |
||||
|
||||
|
||||
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" |
||||
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/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" |
||||
test_slither tests/unused_return.sol "unused-return" |
||||
|
||||
|
||||
### 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 |
||||
exit 0 |
@ -0,0 +1,41 @@ |
||||
contract Test{ |
||||
|
||||
address payable destination; |
||||
|
||||
mapping (address => uint) balances; |
||||
|
||||
constructor() public{ |
||||
balances[msg.sender] = 0; |
||||
} |
||||
|
||||
function direct() public{ |
||||
msg.sender.send(address(this).balance); |
||||
} |
||||
|
||||
function init() public{ |
||||
destination = msg.sender; |
||||
} |
||||
|
||||
function indirect() public{ |
||||
destination.send(address(this).balance); |
||||
} |
||||
|
||||
// these are legitimate calls |
||||
// and should not be detected |
||||
function repay() payable public{ |
||||
msg.sender.transfer(msg.value); |
||||
} |
||||
|
||||
function withdraw() public{ |
||||
uint val = balances[msg.sender]; |
||||
msg.sender.send(val); |
||||
} |
||||
|
||||
function buy() payable public{ |
||||
uint value_send = msg.value; |
||||
uint value_spent = 0 ; // simulate a buy of tokens |
||||
uint remaining = value_send - value_spent; |
||||
msg.sender.send(remaining); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
contract Constant { |
||||
|
||||
uint a; |
||||
|
||||
|
||||
function test_view_shadow() public view{ |
||||
uint a; |
||||
a = 0; |
||||
} |
||||
|
||||
function test_view() public view{ |
||||
a; |
||||
} |
||||
|
||||
function test_assembly_bug() public view{ |
||||
assembly{} |
||||
} |
||||
} |
@ -1,25 +1,25 @@ |
||||
contract C{ |
||||
|
||||
address addr_good = 0x41; |
||||
address addr_good = address(0x41); |
||||
address addr_bad ; |
||||
|
||||
bytes4 func_id; |
||||
|
||||
function bad_delegate_call(bytes data){ |
||||
function bad_delegate_call(bytes memory data) public{ |
||||
addr_good.delegatecall(data); |
||||
addr_bad.delegatecall(data); |
||||
} |
||||
|
||||
function set(bytes4 id){ |
||||
function set(bytes4 id) public{ |
||||
func_id = id; |
||||
addr_bad = msg.sender; |
||||
} |
||||
|
||||
function bad_delegate_call2(bytes data){ |
||||
addr_bad.delegatecall(func_id, data); |
||||
function bad_delegate_call2(bytes memory data) public{ |
||||
addr_bad.delegatecall(abi.encode(func_id, data)); |
||||
} |
||||
|
||||
function good_delegate_call(bytes data){ |
||||
addr_good.delegatecall(bytes4(0x41), data); |
||||
function good_delegate_call(bytes memory data) public{ |
||||
addr_good.delegatecall(abi.encode(bytes4(""), data)); |
||||
} |
||||
} |
||||
|
@ -0,0 +1 @@ |
||||
[{"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "description": "Test.direct (tests/arbitrary_send-0.5.1.sol#11-13) sends eth to arbirary user\n\tDangerous calls:\n\t- msg.sender.send(address(this).balance) (tests/arbitrary_send-0.5.1.sol#12)\n", "function": {"name": "direct", "source_mapping": {"start": 162, "length": 79, "filename": "tests/arbitrary_send-0.5.1.sol", "lines": [11, 12, 13]}, "contract": {"name": "Test", "source_mapping": {"start": 0, "length": 884, "filename": "tests/arbitrary_send-0.5.1.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]}}}, "expressions": [{"expression": "msg.sender.send(address(this).balance)", "source_mapping": {"start": 196, "length": 38, "filename": "tests/arbitrary_send-0.5.1.sol", "lines": [12]}}]}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "description": "Test.indirect (tests/arbitrary_send-0.5.1.sol#19-21) sends eth to arbirary user\n\tDangerous calls:\n\t- destination.send(address(this).balance) (tests/arbitrary_send-0.5.1.sol#20)\n", "function": {"name": "indirect", "source_mapping": {"start": 316, "length": 82, "filename": "tests/arbitrary_send-0.5.1.sol", "lines": [19, 20, 21]}, "contract": {"name": "Test", "source_mapping": {"start": 0, "length": 884, "filename": "tests/arbitrary_send-0.5.1.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]}}}, "expressions": [{"expression": "destination.send(address(this).balance)", "source_mapping": {"start": 352, "length": 39, "filename": "tests/arbitrary_send-0.5.1.sol", "lines": [20]}}]}] |
@ -1 +1 @@ |
||||
[{"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "description": "Test.direct (tests/arbitrary_send.sol#11-13) sends eth to arbirary user\n\tDangerous calls:\n\t- msg.sender.send(this.balance) (tests/arbitrary_send.sol#12)\n", "function": {"name": "direct", "source_mapping": {"start": 147, "length": 63, "filename": "tests/arbitrary_send.sol", "lines": [11, 12, 13]}, "contract": {"name": "Test", "source_mapping": {"start": 0, "length": 809, "filename": "tests/arbitrary_send.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]}}}, "expressions": [{"expression": "msg.sender.send(this.balance)", "source_mapping": {"start": 174, "length": 29, "filename": "tests/arbitrary_send.sol", "lines": [12]}}]}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "description": "Test.indirect (tests/arbitrary_send.sol#19-21) sends eth to arbirary user\n\tDangerous calls:\n\t- destination.send(this.balance) (tests/arbitrary_send.sol#20)\n", "function": {"name": "indirect", "source_mapping": {"start": 278, "length": 66, "filename": "tests/arbitrary_send.sol", "lines": [19, 20, 21]}, "contract": {"name": "Test", "source_mapping": {"start": 0, "length": 809, "filename": "tests/arbitrary_send.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]}}}, "expressions": [{"expression": "destination.send(this.balance)", "source_mapping": {"start": 307, "length": 30, "filename": "tests/arbitrary_send.sol", "lines": [20]}}]}] |
||||
[{"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "description": "Test.direct (tests/arbitrary_send.sol#11-13) sends eth to arbirary user\n\tDangerous calls:\n\t- msg.sender.send(address(this).balance) (tests/arbitrary_send.sol#12)\n", "function": {"name": "direct", "source_mapping": {"start": 147, "length": 79, "filename": "tests/arbitrary_send.sol", "lines": [11, 12, 13]}, "contract": {"name": "Test", "source_mapping": {"start": 0, "length": 869, "filename": "tests/arbitrary_send.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]}}}, "expressions": [{"expression": "msg.sender.send(address(this).balance)", "source_mapping": {"start": 181, "length": 38, "filename": "tests/arbitrary_send.sol", "lines": [12]}}]}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "description": "Test.indirect (tests/arbitrary_send.sol#19-21) sends eth to arbirary user\n\tDangerous calls:\n\t- destination.send(address(this).balance) (tests/arbitrary_send.sol#20)\n", "function": {"name": "indirect", "source_mapping": {"start": 301, "length": 82, "filename": "tests/arbitrary_send.sol", "lines": [19, 20, 21]}, "contract": {"name": "Test", "source_mapping": {"start": 0, "length": 869, "filename": "tests/arbitrary_send.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]}}}, "expressions": [{"expression": "destination.send(address(this).balance)", "source_mapping": {"start": 337, "length": 39, "filename": "tests/arbitrary_send.sol", "lines": [20]}}]}] |
@ -1 +1 @@ |
||||
[{"check": "backdoor", "impact": "High", "confidence": "High", "description": "Backdoor function found in C.i_am_a_backdoor (tests/backdoor.sol#5-7)\n", "function": {"name": "i_am_a_backdoor", "source_mapping": {"start": 43, "length": 74, "filename": "tests/backdoor.sol", "lines": [5, 6, 7]}, "contract": {"name": "C", "source_mapping": {"start": 26, "length": 94, "filename": "tests/backdoor.sol", "lines": [3, 4, 5, 6, 7, 8, 9]}}}}] |
||||
[{"check": "backdoor", "impact": "High", "confidence": "High", "description": "Backdoor function found in C.i_am_a_backdoor (tests/backdoor.sol#4-6)\n", "function": {"name": "i_am_a_backdoor", "source_mapping": {"start": 18, "length": 74, "filename": "tests/backdoor.sol", "lines": [4, 5, 6]}, "contract": {"name": "C", "source_mapping": {"start": 1, "length": 94, "filename": "tests/backdoor.sol", "lines": [2, 3, 4, 5, 6, 7, 8]}}}}] |
@ -1 +1 @@ |
||||
[{"check": "suicidal", "impact": "High", "confidence": "High", "description": "C.i_am_a_backdoor (tests/backdoor.sol#5-7) allows anyone to destruct the contract\n", "function": {"name": "i_am_a_backdoor", "source_mapping": {"start": 43, "length": 74, "filename": "tests/backdoor.sol", "lines": [5, 6, 7]}, "contract": {"name": "C", "source_mapping": {"start": 26, "length": 94, "filename": "tests/backdoor.sol", "lines": [3, 4, 5, 6, 7, 8, 9]}}}}] |
||||
[{"check": "suicidal", "impact": "High", "confidence": "High", "description": "C.i_am_a_backdoor (tests/backdoor.sol#4-6) allows anyone to destruct the contract\n", "function": {"name": "i_am_a_backdoor", "source_mapping": {"start": 18, "length": 74, "filename": "tests/backdoor.sol", "lines": [4, 5, 6]}, "contract": {"name": "C", "source_mapping": {"start": 1, "length": 94, "filename": "tests/backdoor.sol", "lines": [2, 3, 4, 5, 6, 7, 8]}}}}] |
@ -1 +1 @@ |
||||
[{"check": "constable-states", "impact": "Informational", "confidence": "High", "description": "A.myFriendsAddress should be constant (tests/const_state_variables.sol#7)\nA.test should be constant (tests/const_state_variables.sol#10)\nA.text2 should be constant (tests/const_state_variables.sol#14)\n", "variables": [{"name": "myFriendsAddress", "source_mapping": {"start": 130, "length": 76, "filename": "tests/const_state_variables.sol", "lines": [7]}}, {"name": "test", "source_mapping": {"start": 235, "length": 20, "filename": "tests/const_state_variables.sol", "lines": [10]}}, {"name": "text2", "source_mapping": {"start": 331, "length": 20, "filename": "tests/const_state_variables.sol", "lines": [14]}}]}, {"check": "constable-states", "impact": "Informational", "confidence": "High", "description": "B.mySistersAddress should be constant (tests/const_state_variables.sol#26)\n", "variables": [{"name": "mySistersAddress", "source_mapping": {"start": 494, "length": 76, "filename": "tests/const_state_variables.sol", "lines": [26]}}]}] |
||||
[{"check": "constable-states", "impact": "Informational", "confidence": "High", "description": "A.myFriendsAddress should be constant (tests/const_state_variables.sol#7)\nA.test should be constant (tests/const_state_variables.sol#10)\nA.text2 should be constant (tests/const_state_variables.sol#14)\n", "variables": [{"name": "myFriendsAddress", "source_mapping": {"start": 132, "length": 76, "filename": "tests/const_state_variables.sol", "lines": [7]}}, {"name": "test", "source_mapping": {"start": 237, "length": 20, "filename": "tests/const_state_variables.sol", "lines": [10]}}, {"name": "text2", "source_mapping": {"start": 333, "length": 20, "filename": "tests/const_state_variables.sol", "lines": [14]}}]}, {"check": "constable-states", "impact": "Informational", "confidence": "High", "description": "B.mySistersAddress should be constant (tests/const_state_variables.sol#26)\n", "variables": [{"name": "mySistersAddress", "source_mapping": {"start": 496, "length": 76, "filename": "tests/const_state_variables.sol", "lines": [26]}}]}] |
@ -0,0 +1 @@ |
||||
[{"check": "constant-function", "impact": "Medium", "confidence": "Medium", "description": "Constant.test_assembly_bug (tests/constant-0.5.1.sol#15-17) is declared view but contains assembly code\n", "function": {"name": "test_assembly_bug", "source_mapping": {"start": 185, "length": 66, "filename": "tests/constant-0.5.1.sol", "lines": [15, 16, 17]}, "contract": {"name": "Constant", "source_mapping": {"start": 0, "length": 253, "filename": "tests/constant-0.5.1.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]}}}, "variables": [], "contains_assembly": true}] |
@ -1 +1 @@ |
||||
[{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium", "description": "C.bad_delegate_call (tests/controlled_delegatecall.sol#8-11) uses delegatecall to a input-controlled function id\n\taddr_bad.delegatecall(data) (tests/controlled_delegatecall.sol#10)\n", "function": {"name": "bad_delegate_call", "source_mapping": {"start": 92, "length": 120, "filename": "tests/controlled_delegatecall.sol", "lines": [8, 9, 10, 11]}, "contract": {"name": "C", "source_mapping": {"start": 0, "length": 505, "filename": "tests/controlled_delegatecall.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}}}, "expressions": [{"expression": "addr_bad.delegatecall(data)", "source_mapping": {"start": 178, "length": 27, "filename": "tests/controlled_delegatecall.sol", "lines": [10]}}]}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium", "description": "C.bad_delegate_call2 (tests/controlled_delegatecall.sol#18-20) uses delegatecall to a input-controlled function id\n\taddr_bad.delegatecall(func_id,data) (tests/controlled_delegatecall.sol#19)\n", "function": {"name": "bad_delegate_call2", "source_mapping": {"start": 307, "length": 92, "filename": "tests/controlled_delegatecall.sol", "lines": [18, 19, 20]}, "contract": {"name": "C", "source_mapping": {"start": 0, "length": 505, "filename": "tests/controlled_delegatecall.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}}}, "expressions": [{"expression": "addr_bad.delegatecall(func_id,data)", "source_mapping": {"start": 356, "length": 36, "filename": "tests/controlled_delegatecall.sol", "lines": [19]}}]}] |
||||
[{"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium", "description": "C.bad_delegate_call (tests/controlled_delegatecall.sol#8-11) uses delegatecall to a input-controlled function id\n\taddr_bad.delegatecall(data) (tests/controlled_delegatecall.sol#10)\n", "function": {"name": "bad_delegate_call", "source_mapping": {"start": 101, "length": 134, "filename": "tests/controlled_delegatecall.sol", "lines": [8, 9, 10, 11]}, "contract": {"name": "C", "source_mapping": {"start": 0, "length": 585, "filename": "tests/controlled_delegatecall.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}}}, "expressions": [{"expression": "addr_bad.delegatecall(data)", "source_mapping": {"start": 201, "length": 27, "filename": "tests/controlled_delegatecall.sol", "lines": [10]}}]}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium", "description": "C.bad_delegate_call2 (tests/controlled_delegatecall.sol#18-20) uses delegatecall to a input-controlled function id\n\taddr_bad.delegatecall(abi.encode(func_id,data)) (tests/controlled_delegatecall.sol#19)\n", "function": {"name": "bad_delegate_call2", "source_mapping": {"start": 337, "length": 118, "filename": "tests/controlled_delegatecall.sol", "lines": [18, 19, 20]}, "contract": {"name": "C", "source_mapping": {"start": 0, "length": 585, "filename": "tests/controlled_delegatecall.sol", "lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}}}, "expressions": [{"expression": "addr_bad.delegatecall(abi.encode(func_id,data))", "source_mapping": {"start": 400, "length": 48, "filename": "tests/controlled_delegatecall.sol", "lines": [19]}}]}] |
@ -1 +1 @@ |
||||
[{"check": "external-function", "impact": "Informational", "confidence": "High", "description": "ContractWithFunctionNotCalled.funcNotCalled3 (tests/external_function.sol#13-15) should be declared external\n", "function": {"name": "funcNotCalled3", "source_mapping": {"start": 257, "length": 41, "filename": "tests/external_function.sol", "lines": [13, 14, 15]}, "contract": {"name": "ContractWithFunctionNotCalled", "source_mapping": {"start": 211, "length": 258, "filename": "tests/external_function.sol", "lines": [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]}}}}, {"check": "external-function", "impact": "Informational", "confidence": "High", "description": "ContractWithFunctionNotCalled.funcNotCalled2 (tests/external_function.sol#17-19) should be declared external\n", "function": {"name": "funcNotCalled2", "source_mapping": {"start": 304, "length": 41, "filename": "tests/external_function.sol", "lines": [17, 18, 19]}, "contract": {"name": "ContractWithFunctionNotCalled", "source_mapping": {"start": 211, "length": 258, "filename": "tests/external_function.sol", "lines": [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]}}}}, {"check": "external-function", "impact": "Informational", "confidence": "High", "description": "ContractWithFunctionNotCalled.funcNotCalled (tests/external_function.sol#21-23) should be declared external\n", "function": {"name": "funcNotCalled", "source_mapping": {"start": 351, "length": 40, "filename": "tests/external_function.sol", "lines": [21, 22, 23]}, "contract": {"name": "ContractWithFunctionNotCalled", "source_mapping": {"start": 211, "length": 258, "filename": "tests/external_function.sol", "lines": [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]}}}}, {"check": "external-function", "impact": "Informational", "confidence": "High", "description": "ContractWithFunctionNotCalled2.funcNotCalled (tests/external_function.sol#32-39) should be declared external\n", "function": {"name": "funcNotCalled", "source_mapping": {"start": 552, "length": 304, "filename": "tests/external_function.sol", "lines": [32, 33, 34, 35, 36, 37, 38, 39]}, "contract": {"name": "ContractWithFunctionNotCalled2", "source_mapping": {"start": 471, "length": 387, "filename": "tests/external_function.sol", "lines": [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]}}}}] |
||||
[{"check": "external-function", "impact": "Informational", "confidence": "High", "description": "ContractWithFunctionNotCalled.funcNotCalled3 (tests/external_function.sol#13-15) should be declared external\n", "function": {"name": "funcNotCalled3", "source_mapping": {"start": 259, "length": 41, "filename": "tests/external_function.sol", "lines": [13, 14, 15]}, "contract": {"name": "ContractWithFunctionNotCalled", "source_mapping": {"start": 213, "length": 258, "filename": "tests/external_function.sol", "lines": [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]}}}}, {"check": "external-function", "impact": "Informational", "confidence": "High", "description": "ContractWithFunctionNotCalled.funcNotCalled2 (tests/external_function.sol#17-19) should be declared external\n", "function": {"name": "funcNotCalled2", "source_mapping": {"start": 306, "length": 41, "filename": "tests/external_function.sol", "lines": [17, 18, 19]}, "contract": {"name": "ContractWithFunctionNotCalled", "source_mapping": {"start": 213, "length": 258, "filename": "tests/external_function.sol", "lines": [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]}}}}, {"check": "external-function", "impact": "Informational", "confidence": "High", "description": "ContractWithFunctionNotCalled.funcNotCalled (tests/external_function.sol#21-23) should be declared external\n", "function": {"name": "funcNotCalled", "source_mapping": {"start": 353, "length": 40, "filename": "tests/external_function.sol", "lines": [21, 22, 23]}, "contract": {"name": "ContractWithFunctionNotCalled", "source_mapping": {"start": 213, "length": 258, "filename": "tests/external_function.sol", "lines": [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]}}}}, {"check": "external-function", "impact": "Informational", "confidence": "High", "description": "ContractWithFunctionNotCalled2.funcNotCalled (tests/external_function.sol#32-39) should be declared external\n", "function": {"name": "funcNotCalled", "source_mapping": {"start": 554, "length": 325, "filename": "tests/external_function.sol", "lines": [32, 33, 34, 35, 36, 37, 38, 39]}, "contract": {"name": "ContractWithFunctionNotCalled2", "source_mapping": {"start": 473, "length": 408, "filename": "tests/external_function.sol", "lines": [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]}}}}] |
@ -0,0 +1 @@ |
||||
[{"check": "assembly", "impact": "Informational", "confidence": "High", "description": "GetCode.at uses assembly (tests/inline_assembly_contract-0.5.1.sol#6-20)\n\t- tests/inline_assembly_contract-0.5.1.sol#7-20\n", "function": {"name": "at", "source_mapping": {"start": 119, "length": 707, "filename": "tests/inline_assembly_contract-0.5.1.sol", "lines": [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]}, "contract": {"name": "GetCode", "source_mapping": {"start": 97, "length": 731, "filename": "tests/inline_assembly_contract-0.5.1.sol", "lines": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]}}}, "assembly": [{"source_mapping": {"start": 198, "length": 628, "filename": "tests/inline_assembly_contract-0.5.1.sol", "lines": [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]}}]}] |
@ -0,0 +1 @@ |
||||
[{"check": "assembly", "impact": "Informational", "confidence": "High", "description": "VectorSum.sumAsm uses assembly (tests/inline_assembly_library-0.5.1.sol#16-22)\n\t- tests/inline_assembly_library-0.5.1.sol#18-21\n", "function": {"name": "sumAsm", "source_mapping": {"start": 599, "length": 254, "filename": "tests/inline_assembly_library-0.5.1.sol", "lines": [16, 17, 18, 19, 20, 21, 22]}, "contract": {"name": "VectorSum", "source_mapping": {"start": 97, "length": 1602, "filename": "tests/inline_assembly_library-0.5.1.sol", "lines": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]}}}, "assembly": [{"source_mapping": {"start": 733, "length": 114, "filename": "tests/inline_assembly_library-0.5.1.sol", "lines": [18, 19, 20, 21]}}]}, {"check": "assembly", "impact": "Informational", "confidence": "High", "description": "VectorSum.sumPureAsm uses assembly (tests/inline_assembly_library-0.5.1.sol#25-47)\n\t- tests/inline_assembly_library-0.5.1.sol#26-47\n", "function": {"name": "sumPureAsm", "source_mapping": {"start": 936, "length": 761, "filename": "tests/inline_assembly_library-0.5.1.sol", "lines": [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]}, "contract": {"name": "VectorSum", "source_mapping": {"start": 97, "length": 1602, "filename": "tests/inline_assembly_library-0.5.1.sol", "lines": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]}}}, "assembly": [{"source_mapping": {"start": 1020, "length": 677, "filename": "tests/inline_assembly_library-0.5.1.sol", "lines": [26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]}}]}] |
@ -0,0 +1 @@ |
||||
[{"check": "locked-ether", "impact": "Medium", "confidence": "High", "description": "Contract locking ether found in tests/locked_ether-0.5.1.sol:\n\tContract OnlyLocked has payable functions:\n\t - receive (tests/locked_ether-0.5.1.sol#4-6)\n\tBut has not function to withdraw the ether\n", "functions": [{"name": "receive", "source_mapping": {"start": 46, "length": 72, "filename": "tests/locked_ether-0.5.1.sol", "lines": [4, 5, 6]}, "contract": {"name": "Locked", "source_mapping": {"start": 24, "length": 97, "filename": "tests/locked_ether-0.5.1.sol", "lines": [2, 3, 4, 5, 6, 7, 8]}}}], "contract": {"name": "OnlyLocked", "source_mapping": {"start": 375, "length": 32, "filename": "tests/locked_ether-0.5.1.sol", "lines": [26]}}}] |
@ -1 +1 @@ |
||||
[{"check": "low-level-calls", "impact": "Informational", "confidence": "High", "description": "Low level call in Sender.send (tests/low_level_calls.sol#5-7):\n\t-_receiver.call.value(msg.value).gas(7777)() tests/low_level_calls.sol#6\n", "function": {"name": "send", "source_mapping": {"start": 49, "length": 101, "filename": "tests/low_level_calls.sol", "lines": [5, 6, 7]}, "contract": {"name": "Sender", "source_mapping": {"start": 27, "length": 125, "filename": "tests/low_level_calls.sol", "lines": [4, 5, 6, 7, 8]}}}, "expressions": [{"expression": "_receiver.call.value(msg.value).gas(7777)()", "source_mapping": {"start": 100, "length": 43, "filename": "tests/low_level_calls.sol", "lines": [6]}}]}] |
||||
[{"check": "low-level-calls", "impact": "Informational", "confidence": "High", "description": "Low level call in Sender.send (tests/low_level_calls.sol#5-7):\n\t-_receiver.call.value(msg.value).gas(7777)() tests/low_level_calls.sol#6\n", "function": {"name": "send", "source_mapping": {"start": 51, "length": 112, "filename": "tests/low_level_calls.sol", "lines": [5, 6, 7]}, "contract": {"name": "Sender", "source_mapping": {"start": 29, "length": 136, "filename": "tests/low_level_calls.sol", "lines": [4, 5, 6, 7, 8]}}}, "expressions": [{"expression": "_receiver.call.value(msg.value).gas(7777)()", "source_mapping": {"start": 111, "length": 45, "filename": "tests/low_level_calls.sol", "lines": [6]}}]}] |
@ -1 +1 @@ |
||||
[{"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Contract 'naming' (tests/naming_convention.sol#3-48) is not in CapWords\n", "type": "contract", "convention": "CapWords", "name": {"name": "naming", "source_mapping": {"start": 26, "length": 598, "filename": "tests/naming_convention.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Struct 'naming.test' (tests/naming_convention.sol#14-16) is not in CapWords\n", "type": "structure", "convention": "CapWords", "name": {"name": "test", "source_mapping": {"start": 227, "length": 20, "filename": "tests/naming_convention.sol", "lines": [14, 15, 16]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Event 'naming.event_' (tests/naming_convention.sol#23) is not in CapWords\n", "type": "event", "convention": "CapWords", "name": {"name": "event_", "source_mapping": {"start": 303, "length": 19, "filename": "tests/naming_convention.sol", "lines": [23]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Function 'naming.GetOne' (tests/naming_convention.sol#30-33) is not in mixedCase\n", "type": "function", "convention": "mixedCase", "name": {"name": "GetOne", "source_mapping": {"start": 405, "length": 71, "filename": "tests/naming_convention.sol", "lines": [30, 31, 32, 33]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Parameter 'Number2' of naming.setInt (tests/naming_convention.sol#35) is not in mixedCase\n", "type": "parameter", "convention": "mixedCase", "name": {"name": "Number2", "source_mapping": {"start": 512, "length": 12, "filename": "tests/naming_convention.sol", "lines": [35]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Constant 'naming.MY_other_CONSTANT' (tests/naming_convention.sol#9) is not in UPPER_CASE_WITH_UNDERSCORES\n", "type": "variable_constant", "convention": "UPPER_CASE_WITH_UNDERSCORES", "name": {"name": "MY_other_CONSTANT", "source_mapping": {"start": 141, "length": 35, "filename": "tests/naming_convention.sol", "lines": [9]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Variable 'naming.Var_One' (tests/naming_convention.sol#11) is not in mixedCase\n", "type": "variable", "convention": "mixedCase", "name": {"name": "Var_One", "source_mapping": {"start": 183, "length": 16, "filename": "tests/naming_convention.sol", "lines": [11]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Enum 'naming.numbers' (tests/naming_convention.sol#6) is not in CapWords\n", "type": "enum", "convention": "CapWords", "name": {"name": "numbers", "source_mapping": {"start": 77, "length": 23, "filename": "tests/naming_convention.sol", "lines": [6]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Modifier 'naming.CantDo' (tests/naming_convention.sol#41-43) is not in mixedCase\n", "type": "modifier", "convention": "mixedCase", "name": {"name": "CantDo", "source_mapping": {"start": 545, "length": 36, "filename": "tests/naming_convention.sol", "lines": [41, 42, 43]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Parameter '_used' of T.test (tests/naming_convention.sol#59) is not in mixedCase\n", "type": "parameter", "convention": "mixedCase", "name": {"name": "_used", "source_mapping": {"start": 748, "length": 10, "filename": "tests/naming_convention.sol", "lines": [59]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Variable 'T._myPublicVar' (tests/naming_convention.sol#56) is not in mixedCase\n", "type": "variable", "convention": "mixedCase", "name": {"name": "_myPublicVar", "source_mapping": {"start": 695, "length": 17, "filename": "tests/naming_convention.sol", "lines": [56]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Variable 'T.l' (tests/naming_convention.sol#67) used l, O, I, which should not be used\n", "type": "variable", "convention": "l_O_I_should_not_be_used", "name": {"name": "l", "source_mapping": {"start": 847, "length": 10, "filename": "tests/naming_convention.sol", "lines": [67]}}}] |
||||
[{"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Contract 'naming' (tests/naming_convention.sol#3-48) is not in CapWords\n", "type": "contract", "convention": "CapWords", "name": {"name": "naming", "source_mapping": {"start": 28, "length": 642, "filename": "tests/naming_convention.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Struct 'naming.test' (tests/naming_convention.sol#14-16) is not in CapWords\n", "type": "structure", "convention": "CapWords", "name": {"name": "test", "source_mapping": {"start": 229, "length": 35, "filename": "tests/naming_convention.sol", "lines": [14, 15, 16]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Event 'naming.event_' (tests/naming_convention.sol#23) is not in CapWords\n", "type": "event", "convention": "CapWords", "name": {"name": "event_", "source_mapping": {"start": 335, "length": 19, "filename": "tests/naming_convention.sol", "lines": [23]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Function 'naming.GetOne' (tests/naming_convention.sol#30-33) is not in mixedCase\n", "type": "function", "convention": "mixedCase", "name": {"name": "GetOne", "source_mapping": {"start": 440, "length": 75, "filename": "tests/naming_convention.sol", "lines": [30, 31, 32, 33]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Parameter 'Number2' of naming.setInt (tests/naming_convention.sol#35) is not in mixedCase\n", "type": "parameter", "convention": "mixedCase", "name": {"name": "Number2", "source_mapping": {"start": 551, "length": 12, "filename": "tests/naming_convention.sol", "lines": [35]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Constant 'naming.MY_other_CONSTANT' (tests/naming_convention.sol#9) is not in UPPER_CASE_WITH_UNDERSCORES\n", "type": "variable_constant", "convention": "UPPER_CASE_WITH_UNDERSCORES", "name": {"name": "MY_other_CONSTANT", "source_mapping": {"start": 143, "length": 35, "filename": "tests/naming_convention.sol", "lines": [9]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Variable 'naming.Var_One' (tests/naming_convention.sol#11) is not in mixedCase\n", "type": "variable", "convention": "mixedCase", "name": {"name": "Var_One", "source_mapping": {"start": 185, "length": 16, "filename": "tests/naming_convention.sol", "lines": [11]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Enum 'naming.numbers' (tests/naming_convention.sol#6) is not in CapWords\n", "type": "enum", "convention": "CapWords", "name": {"name": "numbers", "source_mapping": {"start": 79, "length": 23, "filename": "tests/naming_convention.sol", "lines": [6]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Modifier 'naming.CantDo' (tests/naming_convention.sol#41-43) is not in mixedCase\n", "type": "modifier", "convention": "mixedCase", "name": {"name": "CantDo", "source_mapping": {"start": 591, "length": 36, "filename": "tests/naming_convention.sol", "lines": [41, 42, 43]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Parameter '_used' of T.test (tests/naming_convention.sol#59) is not in mixedCase\n", "type": "parameter", "convention": "mixedCase", "name": {"name": "_used", "source_mapping": {"start": 794, "length": 10, "filename": "tests/naming_convention.sol", "lines": [59]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Variable 'T._myPublicVar' (tests/naming_convention.sol#56) is not in mixedCase\n", "type": "variable", "convention": "mixedCase", "name": {"name": "_myPublicVar", "source_mapping": {"start": 741, "length": 17, "filename": "tests/naming_convention.sol", "lines": [56]}}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "description": "Variable 'T.l' (tests/naming_convention.sol#67) used l, O, I, which should not be used\n", "type": "variable", "convention": "l_O_I_should_not_be_used", "name": {"name": "l", "source_mapping": {"start": 900, "length": 10, "filename": "tests/naming_convention.sol", "lines": [67]}}}] |
@ -0,0 +1 @@ |
||||
[{"check": "reentrancy", "impact": "High", "confidence": "Medium", "description": "Reentrancy in Reentrancy.withdrawBalance (tests/reentrancy-0.5.1.sol#14-22):\n\tExternal calls:\n\t- (ret,mem) = msg.sender.call.value(userBalance[msg.sender])() (tests/reentrancy-0.5.1.sol#17)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy-0.5.1.sol#21)\n", "function": {"name": "withdrawBalance", "source_mapping": {"start": 298, "length": 357, "filename": "tests/reentrancy-0.5.1.sol", "lines": [14, 15, 16, 17, 18, 19, 20, 21, 22]}, "contract": {"name": "Reentrancy", "source_mapping": {"start": 25, "length": 1807, "filename": "tests/reentrancy-0.5.1.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54]}}}, "external_calls": [{"expression": "(ret,mem) = msg.sender.call.value(userBalance[msg.sender])()", "source_mapping": {"start": 477, "length": 81, "filename": "tests/reentrancy-0.5.1.sol", "lines": [17]}}], "external_calls_sending_eth": [], "variables_written": [{"name": "userBalance", "expression": "userBalance[msg.sender] = 0", "source_mapping": {"start": 621, "length": 27, "filename": "tests/reentrancy-0.5.1.sol", "lines": [21]}}]}, {"check": "reentrancy", "impact": "High", "confidence": "Medium", "description": "Reentrancy in Reentrancy.withdrawBalance_fixed_3 (tests/reentrancy-0.5.1.sol#44-53):\n\tExternal calls:\n\t- (ret,mem) = msg.sender.call.value(amount)() (tests/reentrancy-0.5.1.sol#49)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy-0.5.1.sol#51)\n", "function": {"name": "withdrawBalance_fixed_3", "source_mapping": {"start": 1434, "length": 393, "filename": "tests/reentrancy-0.5.1.sol", "lines": [44, 45, 46, 47, 48, 49, 50, 51, 52, 53]}, "contract": {"name": "Reentrancy", "source_mapping": {"start": 25, "length": 1807, "filename": "tests/reentrancy-0.5.1.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54]}}}, "external_calls": [{"expression": "(ret,mem) = msg.sender.call.value(amount)()", "source_mapping": {"start": 1679, "length": 64, "filename": "tests/reentrancy-0.5.1.sol", "lines": [49]}}], "external_calls_sending_eth": [], "variables_written": [{"name": "userBalance", "expression": "userBalance[msg.sender] = amount", "source_mapping": {"start": 1778, "length": 32, "filename": "tests/reentrancy-0.5.1.sol", "lines": [51]}}]}] |
@ -0,0 +1 @@ |
||||
[{"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "description": "TxOrigin.bug0 uses tx.origin for authorization:\n\t- require(bool)(tx.origin == owner) (tests/tx_origin-0.5.1.sol#10)\n", "function": {"name": "bug0", "source_mapping": {"start": 127, "length": 66, "filename": "tests/tx_origin-0.5.1.sol", "lines": [9, 10, 11]}, "contract": {"name": "TxOrigin", "source_mapping": {"start": 25, "length": 442, "filename": "tests/tx_origin-0.5.1.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}}, "expressions": [{"expression": "require(bool)(tx.origin == owner)", "source_mapping": {"start": 159, "length": 27, "filename": "tests/tx_origin-0.5.1.sol", "lines": [10]}}]}, {"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "description": "TxOrigin.bug2 uses tx.origin for authorization:\n\t- tx.origin != owner (tests/tx_origin-0.5.1.sol#14-16)\n", "function": {"name": "bug2", "source_mapping": {"start": 199, "length": 95, "filename": "tests/tx_origin-0.5.1.sol", "lines": [13, 14, 15, 16, 17]}, "contract": {"name": "TxOrigin", "source_mapping": {"start": 25, "length": 442, "filename": "tests/tx_origin-0.5.1.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}}, "expressions": [{"expression": "tx.origin != owner", "source_mapping": {"start": 231, "length": 57, "filename": "tests/tx_origin-0.5.1.sol", "lines": [14, 15, 16]}}]}] |
@ -1 +1 @@ |
||||
[{"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "description": "TxOrigin.bug0 uses tx.origin for authorization:\n\t- require(bool)(tx.origin == owner) (tests/tx_origin.sol#10)\n", "function": {"name": "bug0", "source_mapping": {"start": 114, "length": 60, "filename": "tests/tx_origin.sol", "lines": [9, 10, 11]}, "contract": {"name": "TxOrigin", "source_mapping": {"start": 26, "length": 393, "filename": "tests/tx_origin.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}}, "expressions": [{"expression": "require(bool)(tx.origin == owner)", "source_mapping": {"start": 140, "length": 27, "filename": "tests/tx_origin.sol", "lines": [10]}}]}, {"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "description": "TxOrigin.bug2 uses tx.origin for authorization:\n\t- tx.origin != owner (tests/tx_origin.sol#14-16)\n", "function": {"name": "bug2", "source_mapping": {"start": 180, "length": 89, "filename": "tests/tx_origin.sol", "lines": [13, 14, 15, 16, 17]}, "contract": {"name": "TxOrigin", "source_mapping": {"start": 26, "length": 393, "filename": "tests/tx_origin.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}}, "expressions": [{"expression": "tx.origin != owner", "source_mapping": {"start": 206, "length": 57, "filename": "tests/tx_origin.sol", "lines": [14, 15, 16]}}]}] |
||||
[{"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "description": "TxOrigin.bug0 uses tx.origin for authorization:\n\t- require(bool)(tx.origin == owner) (tests/tx_origin.sol#10)\n", "function": {"name": "bug0", "source_mapping": {"start": 116, "length": 60, "filename": "tests/tx_origin.sol", "lines": [9, 10, 11]}, "contract": {"name": "TxOrigin", "source_mapping": {"start": 28, "length": 393, "filename": "tests/tx_origin.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}}, "expressions": [{"expression": "require(bool)(tx.origin == owner)", "source_mapping": {"start": 142, "length": 27, "filename": "tests/tx_origin.sol", "lines": [10]}}]}, {"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "description": "TxOrigin.bug2 uses tx.origin for authorization:\n\t- tx.origin != owner (tests/tx_origin.sol#14-16)\n", "function": {"name": "bug2", "source_mapping": {"start": 182, "length": 89, "filename": "tests/tx_origin.sol", "lines": [13, 14, 15, 16, 17]}, "contract": {"name": "TxOrigin", "source_mapping": {"start": 28, "length": 393, "filename": "tests/tx_origin.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}}, "expressions": [{"expression": "tx.origin != owner", "source_mapping": {"start": 208, "length": 57, "filename": "tests/tx_origin.sol", "lines": [14, 15, 16]}}]}] |
@ -0,0 +1 @@ |
||||
[{"check": "uninitialized-state", "impact": "High", "confidence": "High", "description": "Uninitialized.destination (tests/uninitialized-0.5.1.sol#5) is never initialized. It is used in:\n\t- transfer (tests/uninitialized-0.5.1.sol#7-9)\n", "variable": {"name": "destination", "source_mapping": {"start": 54, "length": 27, "filename": "tests/uninitialized-0.5.1.sol", "lines": [5]}}, "functions": [{"name": "transfer", "source_mapping": {"start": 88, "length": 82, "filename": "tests/uninitialized-0.5.1.sol", "lines": [7, 8, 9]}, "contract": {"name": "Uninitialized", "source_mapping": {"start": 25, "length": 148, "filename": "tests/uninitialized-0.5.1.sol", "lines": [3, 4, 5, 6, 7, 8, 9, 10, 11]}}}]}, {"check": "uninitialized-state", "impact": "High", "confidence": "High", "description": "Test.balances (tests/uninitialized-0.5.1.sol#15) is never initialized. It is used in:\n\t- use (tests/uninitialized-0.5.1.sol#23-26)\n", "variable": {"name": "balances", "source_mapping": {"start": 196, "length": 34, "filename": "tests/uninitialized-0.5.1.sol", "lines": [15]}}, "functions": [{"name": "use", "source_mapping": {"start": 369, "length": 154, "filename": "tests/uninitialized-0.5.1.sol", "lines": [23, 24, 25, 26]}, "contract": {"name": "Test", "source_mapping": {"start": 176, "length": 349, "filename": "tests/uninitialized-0.5.1.sol", "lines": [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]}}}]}, {"check": "uninitialized-state", "impact": "High", "confidence": "High", "description": "Test2.st (tests/uninitialized-0.5.1.sol#45) is never initialized. It is used in:\n\t- use (tests/uninitialized-0.5.1.sol#53-56)\n", "variable": {"name": "st", "source_mapping": {"start": 726, "length": 15, "filename": "tests/uninitialized-0.5.1.sol", "lines": [45]}}, "functions": [{"name": "use", "source_mapping": {"start": 913, "length": 129, "filename": "tests/uninitialized-0.5.1.sol", "lines": [53, 54, 55, 56]}, "contract": {"name": "Test2", "source_mapping": {"start": 672, "length": 373, "filename": "tests/uninitialized-0.5.1.sol", "lines": [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58]}}}]}, {"check": "uninitialized-state", "impact": "High", "confidence": "High", "description": "Test2.v (tests/uninitialized-0.5.1.sol#47) is never initialized. It is used in:\n\t- init (tests/uninitialized-0.5.1.sol#49-51)\n", "variable": {"name": "v", "source_mapping": {"start": 779, "length": 6, "filename": "tests/uninitialized-0.5.1.sol", "lines": [47]}}, "functions": [{"name": "init", "source_mapping": {"start": 848, "length": 59, "filename": "tests/uninitialized-0.5.1.sol", "lines": [49, 50, 51]}, "contract": {"name": "Test2", "source_mapping": {"start": 672, "length": 373, "filename": "tests/uninitialized-0.5.1.sol", "lines": [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58]}}}]}] |
@ -1 +1 @@ |
||||
[{"check": "unused-return", "impact": "Medium", "confidence": "Medium", "description": "User.test (tests/unused_return.sol#17-29) does not use the value returned by external calls:\n\t-t.f() (tests/unused_return.sol#18)\n\t-a.add(0) (tests/unused_return.sol#22)\n", "function": {"name": "test", "source_mapping": {"start": 230, "length": 347, "filename": "tests/unused_return.sol", "lines": [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]}, "contract": {"name": "User", "source_mapping": {"start": 180, "length": 399, "filename": "tests/unused_return.sol", "lines": [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]}}}, "expressions": [{"expression": "t.f()", "source_mapping": {"start": 263, "length": 5, "filename": "tests/unused_return.sol", "lines": [18]}}, {"expression": "a.add(0)", "source_mapping": {"start": 337, "length": 8, "filename": "tests/unused_return.sol", "lines": [22]}}]}] |
||||
[{"check": "unused-return", "impact": "Medium", "confidence": "Medium", "description": "User.test (tests/unused_return.sol#17-29) does not use the value returned by external calls:\n\t-t.f() (tests/unused_return.sol#18)\n\t-a.add(0) (tests/unused_return.sol#22)\n", "function": {"name": "test", "source_mapping": {"start": 239, "length": 354, "filename": "tests/unused_return.sol", "lines": [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]}, "contract": {"name": "User", "source_mapping": {"start": 189, "length": 406, "filename": "tests/unused_return.sol", "lines": [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]}}}, "expressions": [{"expression": "t.f()", "source_mapping": {"start": 279, "length": 5, "filename": "tests/unused_return.sol", "lines": [18]}}, {"expression": "a.add(0)", "source_mapping": {"start": 353, "length": 8, "filename": "tests/unused_return.sol", "lines": [22]}}]}] |
@ -1 +1 @@ |
||||
[{"check": "unused-state", "impact": "Informational", "confidence": "High", "description": "A.unused (tests/unused_state.sol#4) is never used in B\n", "variables": [{"name": "unused", "source_mapping": {"start": 42, "length": 14, "filename": "tests/unused_state.sol", "lines": [4]}}]}] |
||||
[{"check": "unused-state", "impact": "Informational", "confidence": "High", "description": "A.unused (tests/unused_state.sol#4) is never used in B\n", "variables": [{"name": "unused", "source_mapping": {"start": 44, "length": 14, "filename": "tests/unused_state.sol", "lines": [4]}}]}] |
@ -0,0 +1,22 @@ |
||||
pragma solidity ^0.5.1; |
||||
|
||||
// taken from https://solidity.readthedocs.io/en/v0.4.25/assembly.html |
||||
|
||||
library GetCode { |
||||
function at(address _addr) public view returns (bytes memory o_code) { |
||||
assembly { |
||||
// retrieve the size of the code, this needs assembly |
||||
let size := extcodesize(_addr) |
||||
// allocate output byte array - this could also be done without assembly |
||||
// by using o_code = new bytes(size) |
||||
o_code := mload(0x40) |
||||
// new "memory end" including padding |
||||
mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f)))) |
||||
// store length in memory |
||||
mstore(o_code, size) |
||||
// actually retrieve the code, this needs assembly |
||||
extcodecopy(_addr, add(o_code, 0x20), 0, size) |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,49 @@ |
||||
pragma solidity ^0.5.1; |
||||
|
||||
// taken from https://solidity.readthedocs.io/en/v0.4.25/assembly.html |
||||
|
||||
library VectorSum { |
||||
// This function is less efficient because the optimizer currently fails to |
||||
// remove the bounds checks in array access. |
||||
function sumSolidity(uint[] memory _data) public view returns (uint o_sum) { |
||||
for (uint i = 0; i < _data.length; ++i) |
||||
o_sum += _data[i]; |
||||
} |
||||
|
||||
// We know that we only access the array in bounds, so we can avoid the check. |
||||
// 0x20 needs to be added to an array because the first slot contains the |
||||
// array length. |
||||
function sumAsm(uint[] memory _data) public view returns (uint o_sum) { |
||||
for (uint i = 0; i < _data.length; ++i) { |
||||
assembly { |
||||
o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20)))) |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Same as above, but accomplish the entire code within inline assembly. |
||||
function sumPureAsm(uint[] memory _data) public view returns (uint o_sum) { |
||||
assembly { |
||||
// Load the length (first 32 bytes) |
||||
let len := mload(_data) |
||||
|
||||
// Skip over the length field. |
||||
// |
||||
// Keep temporary variable so it can be incremented in place. |
||||
// |
||||
// NOTE: incrementing _data would result in an unusable |
||||
// _data variable after this assembly block |
||||
let data := add(_data, 0x20) |
||||
|
||||
// Iterate until the bound is not met. |
||||
for |
||||
{ let end := add(data, len) } |
||||
lt(data, end) |
||||
{ data := add(data, 0x20) } |
||||
{ |
||||
o_sum := add(o_sum, mload(data)) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,26 @@ |
||||
pragma solidity ^0.5.0; |
||||
contract Locked{ |
||||
|
||||
function receive() payable public{ |
||||
require(msg.value > 0); |
||||
} |
||||
|
||||
} |
||||
|
||||
contract Send{ |
||||
address payable owner = msg.sender; |
||||
|
||||
function withdraw() public{ |
||||
owner.transfer(address(this).balance); |
||||
} |
||||
} |
||||
|
||||
contract Unlocked is Locked, Send{ |
||||
|
||||
function withdraw() public{ |
||||
super.withdraw(); |
||||
} |
||||
|
||||
} |
||||
|
||||
contract OnlyLocked is Locked{ } |
@ -0,0 +1,54 @@ |
||||
pragma solidity ^0.5.0; |
||||
|
||||
contract Reentrancy { |
||||
mapping (address => uint) userBalance; |
||||
|
||||
function getBalance(address u) view public returns(uint){ |
||||
return userBalance[u]; |
||||
} |
||||
|
||||
function addToBalance() payable public{ |
||||
userBalance[msg.sender] += msg.value; |
||||
} |
||||
|
||||
function withdrawBalance() public{ |
||||
// send userBalance[msg.sender] ethers to msg.sender |
||||
// if mgs.sender is a contract, it will call its fallback function |
||||
(bool ret, bytes memory mem) = msg.sender.call.value(userBalance[msg.sender])(""); |
||||
if( ! ret ){ |
||||
revert(); |
||||
} |
||||
userBalance[msg.sender] = 0; |
||||
} |
||||
|
||||
function withdrawBalance_fixed() public{ |
||||
// To protect against re-entrancy, the state variable |
||||
// has to be change before the call |
||||
uint amount = userBalance[msg.sender]; |
||||
userBalance[msg.sender] = 0; |
||||
(bool ret, bytes memory mem) = msg.sender.call.value(amount)(""); |
||||
if( ! ret ){ |
||||
revert(); |
||||
} |
||||
} |
||||
|
||||
function withdrawBalance_fixed_2() public{ |
||||
// send() and transfer() are safe against reentrancy |
||||
// they do not transfer the remaining gas |
||||
// and they give just enough gas to execute few instructions |
||||
// in the fallback function (no further call possible) |
||||
msg.sender.transfer(userBalance[msg.sender]); |
||||
userBalance[msg.sender] = 0; |
||||
} |
||||
|
||||
function withdrawBalance_fixed_3() public{ |
||||
// The state can be changed |
||||
// But it is fine, as it can only occur if the transaction fails |
||||
uint amount = userBalance[msg.sender]; |
||||
userBalance[msg.sender] = 0; |
||||
(bool ret, bytes memory mem) = msg.sender.call.value(amount)(""); |
||||
if( ! ret ){ |
||||
userBalance[msg.sender] = amount; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,26 @@ |
||||
pragma solidity ^0.5.0; |
||||
|
||||
contract TxOrigin { |
||||
|
||||
address payable owner; |
||||
|
||||
constructor() public{ owner = msg.sender; } |
||||
|
||||
function bug0() public{ |
||||
require(tx.origin == owner); |
||||
} |
||||
|
||||
function bug2() public{ |
||||
if (tx.origin != owner) { |
||||
revert(); |
||||
} |
||||
} |
||||
|
||||
function legit0() public{ |
||||
require(tx.origin == msg.sender); |
||||
} |
||||
|
||||
function legit1() public{ |
||||
tx.origin.transfer(address(this).balance); |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
pragma solidity ^0.5.0; |
||||
|
||||
contract Uninitialized{ |
||||
|
||||
address payable destination; |
||||
|
||||
function transfer() payable public{ |
||||
destination.transfer(msg.value); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
contract Test { |
||||
mapping (address => uint) balances; |
||||
mapping (address => uint) balancesInitialized; |
||||
|
||||
|
||||
function init() public{ |
||||
balancesInitialized[msg.sender] = 0; |
||||
} |
||||
|
||||
function use() view public{ |
||||
// random operation to use the mapping |
||||
require(balances[msg.sender] == balancesInitialized[msg.sender]); |
||||
} |
||||
} |
||||
|
||||
library Lib{ |
||||
|
||||
struct MyStruct{ |
||||
uint val; |
||||
} |
||||
|
||||
function set(MyStruct storage st, uint v) public{ |
||||
st.val = v; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
contract Test2 { |
||||
using Lib for Lib.MyStruct; |
||||
|
||||
Lib.MyStruct st; |
||||
Lib.MyStruct stInitiliazed; |
||||
uint v; // v is used as parameter of the lib, but is never init |
||||
|
||||
function init() public{ |
||||
stInitiliazed.set(v); |
||||
} |
||||
|
||||
function use() view public{ |
||||
// random operation to use the structure |
||||
require(st.val == stInitiliazed.val); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue