mirror of https://github.com/crytic/slither
commit
e3c69e12aa
@ -0,0 +1,60 @@ |
||||
from typing import List |
||||
from slither.core.cfg.node import Node |
||||
from slither.core.declarations import Function, SolidityVariable |
||||
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification |
||||
from slither.slithir.operations.high_level_call import HighLevelCall |
||||
|
||||
|
||||
class VarReadUsingThis(AbstractDetector): |
||||
ARGUMENT = "var-read-using-this" |
||||
HELP = "Contract reads its own variable using `this`" |
||||
IMPACT = DetectorClassification.OPTIMIZATION |
||||
CONFIDENCE = DetectorClassification.HIGH |
||||
|
||||
WIKI = "https://github.com/crytic/slither/wiki/Vulnerabilities-Description#public-variable-read-in-external-context" |
||||
|
||||
WIKI_TITLE = "Public variable read in external context" |
||||
WIKI_DESCRIPTION = "The contract reads its own variable using `this`, adding overhead of an unnecessary STATICCALL." |
||||
WIKI_EXPLOIT_SCENARIO = """ |
||||
```solidity |
||||
contract C { |
||||
mapping(uint => address) public myMap; |
||||
function test(uint x) external returns(address) { |
||||
return this.myMap(x); |
||||
} |
||||
} |
||||
``` |
||||
""" |
||||
|
||||
WIKI_RECOMMENDATION = "Read the variable directly from storage instead of calling the contract." |
||||
|
||||
def _detect(self): |
||||
results = [] |
||||
for c in self.contracts: |
||||
for func in c.functions: |
||||
for node in self._detect_var_read_using_this(func): |
||||
info = [ |
||||
"The function ", |
||||
func, |
||||
" reads ", |
||||
node, |
||||
" with `this` which adds an extra STATICCALL.\n", |
||||
] |
||||
json = self.generate_result(info) |
||||
results.append(json) |
||||
|
||||
return results |
||||
|
||||
@staticmethod |
||||
def _detect_var_read_using_this(func: Function) -> List[Node]: |
||||
results: List[Node] = [] |
||||
for node in func.nodes: |
||||
for ir in node.irs: |
||||
if isinstance(ir, HighLevelCall): |
||||
if ( |
||||
ir.destination == SolidityVariable("this") |
||||
and ir.is_static_call() |
||||
and ir.function.visibility == "public" |
||||
): |
||||
results.append(node) |
||||
return sorted(results, key=lambda x: x.node_id) |
@ -1,27 +0,0 @@ |
||||
from slither.core.declarations import Function |
||||
from slither.slithir.operations.lvalue import OperationWithLValue |
||||
from slither.slithir.utils.utils import is_valid_lvalue, is_valid_rvalue |
||||
|
||||
|
||||
class Push(OperationWithLValue): |
||||
def __init__(self, array, value): |
||||
super().__init__() |
||||
assert is_valid_rvalue(value) or isinstance(value, Function) |
||||
assert is_valid_lvalue(array) |
||||
self._value = value |
||||
self._lvalue = array |
||||
|
||||
@property |
||||
def read(self): |
||||
return [self._value] |
||||
|
||||
@property |
||||
def array(self): |
||||
return self._lvalue |
||||
|
||||
@property |
||||
def value(self): |
||||
return self._value |
||||
|
||||
def __str__(self): |
||||
return f"PUSH {self.value} in {self.lvalue}" |
@ -0,0 +1,16 @@ |
||||
/// @custom:security isDelegatecallProxy |
||||
contract Proxy{ |
||||
|
||||
} |
||||
|
||||
/// @custom:security isUpgradeable |
||||
/// @custom:version name=version-0 |
||||
contract V0{ |
||||
|
||||
} |
||||
|
||||
/// @custom:security isUpgradeable |
||||
/// @custom:version name=version_1 |
||||
contract V1{ |
||||
|
||||
} |
@ -0,0 +1,33 @@ |
||||
|
||||
contract VarReadUsingThis { |
||||
address public erc20; |
||||
mapping(uint => address) public myMap; |
||||
function bad1(uint x) external returns(address) { |
||||
return this.myMap(x); |
||||
} |
||||
function bad2() external returns(address) { |
||||
return this.erc20(); |
||||
} |
||||
function bad3() external returns(address) { |
||||
if (this.erc20() == address(0)) revert(); |
||||
} |
||||
function bad4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = this.erc20(); |
||||
} |
||||
} |
||||
function good1(uint x) external returns(address) { |
||||
return myMap[x]; |
||||
} |
||||
function good2() external returns(address) { |
||||
return erc20; |
||||
} |
||||
function good3() external returns(address) { |
||||
if (erc20 == address(0)) revert(); |
||||
} |
||||
function good4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = erc20; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@ |
||||
[ |
||||
[] |
||||
] |
@ -0,0 +1,39 @@ |
||||
|
||||
contract VarReadUsingThis { |
||||
address public erc20; |
||||
mapping(uint => address) public myMap; |
||||
function bad1(uint x) external returns(address) { |
||||
return this.myMap(x); |
||||
} |
||||
function bad2() external returns(address) { |
||||
return this.erc20(); |
||||
} |
||||
function bad3() external returns(address) { |
||||
if (this.erc20() == address(0)) revert(); |
||||
} |
||||
function bad4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = this.erc20(); |
||||
} |
||||
} |
||||
function good1(uint x) external returns(address) { |
||||
return myMap[x]; |
||||
} |
||||
function good2() external returns(address) { |
||||
return erc20; |
||||
} |
||||
function good3() external returns(address) { |
||||
if (erc20 == address(0)) revert(); |
||||
} |
||||
function good4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = erc20; |
||||
} |
||||
} |
||||
function mapExternal(uint x) external view returns(address) { |
||||
return myMap[x]; |
||||
} |
||||
function good5(uint x) external returns(address) { |
||||
this.mapExternal(x); |
||||
} |
||||
} |
@ -0,0 +1,736 @@ |
||||
[ |
||||
[ |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad3", |
||||
"source_mapping": { |
||||
"start": 275, |
||||
"length": 99, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
11, |
||||
12, |
||||
13 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1107, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad3()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.erc20() == address(0)", |
||||
"source_mapping": { |
||||
"start": 331, |
||||
"length": 26, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
12 |
||||
], |
||||
"starting_column": 13, |
||||
"ending_column": 39 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad3", |
||||
"source_mapping": { |
||||
"start": 275, |
||||
"length": 99, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
11, |
||||
12, |
||||
13 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1107, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad3()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad3() (tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#11-13) reads this.erc20() == address(0) (tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#12) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad3()](tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L11-L13) reads [this.erc20() == address(0)](tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L12) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L11-L13", |
||||
"id": "5556888563fa21301c242d57fbd8e08a35fc5d67171a88b9a2737c14be9c6f7f", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad2", |
||||
"source_mapping": { |
||||
"start": 192, |
||||
"length": 78, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
8, |
||||
9, |
||||
10 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1107, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad2()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.erc20()", |
||||
"source_mapping": { |
||||
"start": 244, |
||||
"length": 19, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
9 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 28 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad2", |
||||
"source_mapping": { |
||||
"start": 192, |
||||
"length": 78, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
8, |
||||
9, |
||||
10 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1107, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad2()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad2() (tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#8-10) reads this.erc20() (tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#9) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad2()](tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L8-L10) reads [this.erc20()](tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L9) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L8-L10", |
||||
"id": "a55229af8750117389299ed9f759d5036882a2396a52087bb2a42c5ed8abaec1", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad1", |
||||
"source_mapping": { |
||||
"start": 102, |
||||
"length": 85, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
5, |
||||
6, |
||||
7 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1107, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad1(uint256)" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.myMap(x)", |
||||
"source_mapping": { |
||||
"start": 160, |
||||
"length": 20, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
6 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 29 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad1", |
||||
"source_mapping": { |
||||
"start": 102, |
||||
"length": 85, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
5, |
||||
6, |
||||
7 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1107, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad1(uint256)" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad1(uint256) (tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#5-7) reads this.myMap(x) (tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#6) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad1(uint256)](tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L5-L7) reads [this.myMap(x)](tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L6) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L5-L7", |
||||
"id": "e810f17bcfdf391a48e66ef70c4aafcc205c882b28d0588b26f1d45742580df6", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad4", |
||||
"source_mapping": { |
||||
"start": 379, |
||||
"length": 138, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
14, |
||||
15, |
||||
16, |
||||
17, |
||||
18 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1107, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad4()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "local = this.erc20()", |
||||
"source_mapping": { |
||||
"start": 471, |
||||
"length": 28, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
16 |
||||
], |
||||
"starting_column": 13, |
||||
"ending_column": 41 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad4", |
||||
"source_mapping": { |
||||
"start": 379, |
||||
"length": 138, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
14, |
||||
15, |
||||
16, |
||||
17, |
||||
18 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1107, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad4()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad4() (tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#14-18) reads local = this.erc20() (tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#16) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad4()](tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L14-L18) reads [local = this.erc20()](tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L16) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L14-L18", |
||||
"id": "fe997df3fdea17b13139a239ecdcdb64a2f6482aa9dacc62f845ef30591c8e4c", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
} |
||||
] |
||||
] |
@ -0,0 +1,39 @@ |
||||
|
||||
contract VarReadUsingThis { |
||||
address public erc20; |
||||
mapping(uint => address) public myMap; |
||||
function bad1(uint x) external returns(address) { |
||||
return this.myMap(x); |
||||
} |
||||
function bad2() external returns(address) { |
||||
return this.erc20(); |
||||
} |
||||
function bad3() external returns(address) { |
||||
if (this.erc20() == address(0)) revert(); |
||||
} |
||||
function bad4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = this.erc20(); |
||||
} |
||||
} |
||||
function good1(uint x) external returns(address) { |
||||
return myMap[x]; |
||||
} |
||||
function good2() external returns(address) { |
||||
return erc20; |
||||
} |
||||
function good3() external returns(address) { |
||||
if (erc20 == address(0)) revert(); |
||||
} |
||||
function good4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = erc20; |
||||
} |
||||
} |
||||
function mapExternal(uint x) external view returns(address) { |
||||
return myMap[x]; |
||||
} |
||||
function good5(uint x) external returns(address) { |
||||
this.mapExternal(x); |
||||
} |
||||
} |
@ -0,0 +1,736 @@ |
||||
[ |
||||
[ |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad3", |
||||
"source_mapping": { |
||||
"start": 275, |
||||
"length": 99, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
11, |
||||
12, |
||||
13 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad3()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.erc20() == address(0)", |
||||
"source_mapping": { |
||||
"start": 331, |
||||
"length": 26, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
12 |
||||
], |
||||
"starting_column": 13, |
||||
"ending_column": 39 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad3", |
||||
"source_mapping": { |
||||
"start": 275, |
||||
"length": 99, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
11, |
||||
12, |
||||
13 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad3()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad3() (tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#11-13) reads this.erc20() == address(0) (tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#12) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad3()](tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L11-L13) reads [this.erc20() == address(0)](tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L12) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L11-L13", |
||||
"id": "314f90a4989ea75cc274e1f5f46036968c2ecdaaf8fa84913e7db4ef1ffe5bb8", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad4", |
||||
"source_mapping": { |
||||
"start": 379, |
||||
"length": 138, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
14, |
||||
15, |
||||
16, |
||||
17, |
||||
18 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad4()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "local = this.erc20()", |
||||
"source_mapping": { |
||||
"start": 471, |
||||
"length": 28, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
16 |
||||
], |
||||
"starting_column": 13, |
||||
"ending_column": 41 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad4", |
||||
"source_mapping": { |
||||
"start": 379, |
||||
"length": 138, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
14, |
||||
15, |
||||
16, |
||||
17, |
||||
18 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad4()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad4() (tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#14-18) reads local = this.erc20() (tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#16) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad4()](tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L14-L18) reads [local = this.erc20()](tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L16) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L14-L18", |
||||
"id": "5fd3f1f78f3532107d7e111d84310f3a0fa374fa407e43951d70fd00a752f76f", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad1", |
||||
"source_mapping": { |
||||
"start": 102, |
||||
"length": 85, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
5, |
||||
6, |
||||
7 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad1(uint256)" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.myMap(x)", |
||||
"source_mapping": { |
||||
"start": 160, |
||||
"length": 20, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
6 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 29 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad1", |
||||
"source_mapping": { |
||||
"start": 102, |
||||
"length": 85, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
5, |
||||
6, |
||||
7 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad1(uint256)" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad1(uint256) (tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#5-7) reads this.myMap(x) (tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#6) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad1(uint256)](tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L5-L7) reads [this.myMap(x)](tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L6) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L5-L7", |
||||
"id": "a30c3d8ddb468d865fa69afe5b7b83164fc1a332933d4661765cc3781896c7cf", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad2", |
||||
"source_mapping": { |
||||
"start": 192, |
||||
"length": 78, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
8, |
||||
9, |
||||
10 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad2()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.erc20()", |
||||
"source_mapping": { |
||||
"start": 244, |
||||
"length": 19, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
9 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 28 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad2", |
||||
"source_mapping": { |
||||
"start": 192, |
||||
"length": 78, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
8, |
||||
9, |
||||
10 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad2()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad2() (tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#8-10) reads this.erc20() (tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#9) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad2()](tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L8-L10) reads [this.erc20()](tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L9) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L8-L10", |
||||
"id": "ccc77ba655d341c0461ca4f4040afe19c379b2333e52648b12f793aaf7f0ead8", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
} |
||||
] |
||||
] |
@ -0,0 +1,39 @@ |
||||
|
||||
contract VarReadUsingThis { |
||||
address public erc20; |
||||
mapping(uint => address) public myMap; |
||||
function bad1(uint x) external returns(address) { |
||||
return this.myMap(x); |
||||
} |
||||
function bad2() external returns(address) { |
||||
return this.erc20(); |
||||
} |
||||
function bad3() external returns(address) { |
||||
if (this.erc20() == address(0)) revert(); |
||||
} |
||||
function bad4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = this.erc20(); |
||||
} |
||||
} |
||||
function good1(uint x) external returns(address) { |
||||
return myMap[x]; |
||||
} |
||||
function good2() external returns(address) { |
||||
return erc20; |
||||
} |
||||
function good3() external returns(address) { |
||||
if (erc20 == address(0)) revert(); |
||||
} |
||||
function good4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = erc20; |
||||
} |
||||
} |
||||
function mapExternal(uint x) external view returns(address) { |
||||
return myMap[x]; |
||||
} |
||||
function good5(uint x) external returns(address) { |
||||
this.mapExternal(x); |
||||
} |
||||
} |
@ -0,0 +1,736 @@ |
||||
[ |
||||
[ |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad3", |
||||
"source_mapping": { |
||||
"start": 275, |
||||
"length": 99, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
11, |
||||
12, |
||||
13 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad3()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.erc20() == address(0)", |
||||
"source_mapping": { |
||||
"start": 331, |
||||
"length": 26, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
12 |
||||
], |
||||
"starting_column": 13, |
||||
"ending_column": 39 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad3", |
||||
"source_mapping": { |
||||
"start": 275, |
||||
"length": 99, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
11, |
||||
12, |
||||
13 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad3()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad3() (tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#11-13) reads this.erc20() == address(0) (tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#12) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad3()](tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L11-L13) reads [this.erc20() == address(0)](tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L12) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L11-L13", |
||||
"id": "1a8ed403cb8c6104a99c9dabdfb64e55282eaedf2c2d8b20fd3b366c49443639", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad2", |
||||
"source_mapping": { |
||||
"start": 192, |
||||
"length": 78, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
8, |
||||
9, |
||||
10 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad2()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.erc20()", |
||||
"source_mapping": { |
||||
"start": 244, |
||||
"length": 19, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
9 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 28 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad2", |
||||
"source_mapping": { |
||||
"start": 192, |
||||
"length": 78, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
8, |
||||
9, |
||||
10 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad2()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad2() (tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#8-10) reads this.erc20() (tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#9) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad2()](tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L8-L10) reads [this.erc20()](tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L9) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L8-L10", |
||||
"id": "5bddf45a7f968094e163217be36e0cf17b7455740755eec53a1e7b0a44fe63ac", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad1", |
||||
"source_mapping": { |
||||
"start": 102, |
||||
"length": 85, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
5, |
||||
6, |
||||
7 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad1(uint256)" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.myMap(x)", |
||||
"source_mapping": { |
||||
"start": 160, |
||||
"length": 20, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
6 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 29 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad1", |
||||
"source_mapping": { |
||||
"start": 102, |
||||
"length": 85, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
5, |
||||
6, |
||||
7 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad1(uint256)" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad1(uint256) (tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#5-7) reads this.myMap(x) (tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#6) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad1(uint256)](tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L5-L7) reads [this.myMap(x)](tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L6) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L5-L7", |
||||
"id": "924c227bf74e70dda261578563193b90b60b70a1ad043716e1d98cbc49b87ceb", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad4", |
||||
"source_mapping": { |
||||
"start": 379, |
||||
"length": 138, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
14, |
||||
15, |
||||
16, |
||||
17, |
||||
18 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad4()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "local = this.erc20()", |
||||
"source_mapping": { |
||||
"start": 471, |
||||
"length": 28, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
16 |
||||
], |
||||
"starting_column": 13, |
||||
"ending_column": 41 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad4", |
||||
"source_mapping": { |
||||
"start": 379, |
||||
"length": 138, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
14, |
||||
15, |
||||
16, |
||||
17, |
||||
18 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad4()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad4() (tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#14-18) reads local = this.erc20() (tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#16) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad4()](tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L14-L18) reads [local = this.erc20()](tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L16) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L14-L18", |
||||
"id": "e9b34de7b565a0e63e55b9c74eaf9a265c7f4c8ef866d7b7db17b815393f0477", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
} |
||||
] |
||||
] |
@ -0,0 +1,39 @@ |
||||
|
||||
contract VarReadUsingThis { |
||||
address public erc20; |
||||
mapping(uint => address) public myMap; |
||||
function bad1(uint x) external returns(address) { |
||||
return this.myMap(x); |
||||
} |
||||
function bad2() external returns(address) { |
||||
return this.erc20(); |
||||
} |
||||
function bad3() external returns(address) { |
||||
if (this.erc20() == address(0)) revert(); |
||||
} |
||||
function bad4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = this.erc20(); |
||||
} |
||||
} |
||||
function good1(uint x) external returns(address) { |
||||
return myMap[x]; |
||||
} |
||||
function good2() external returns(address) { |
||||
return erc20; |
||||
} |
||||
function good3() external returns(address) { |
||||
if (erc20 == address(0)) revert(); |
||||
} |
||||
function good4() internal returns(address) { |
||||
for (uint x; x < 10; x++) { |
||||
address local = erc20; |
||||
} |
||||
} |
||||
function mapExternal(uint x) external view returns(address) { |
||||
return myMap[x]; |
||||
} |
||||
function good5(uint x) external returns(address) { |
||||
this.mapExternal(x); |
||||
} |
||||
} |
@ -0,0 +1,736 @@ |
||||
[ |
||||
[ |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad2", |
||||
"source_mapping": { |
||||
"start": 192, |
||||
"length": 78, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
8, |
||||
9, |
||||
10 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad2()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.erc20()", |
||||
"source_mapping": { |
||||
"start": 244, |
||||
"length": 19, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
9 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 28 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad2", |
||||
"source_mapping": { |
||||
"start": 192, |
||||
"length": 78, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
8, |
||||
9, |
||||
10 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad2()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad2() (tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#8-10) reads this.erc20() (tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#9) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad2()](tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L8-L10) reads [this.erc20()](tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L9) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L8-L10", |
||||
"id": "4e297ea309b8865f782db6a53fdaf5aaf37f768158deb69d2ec6106a8e7b8afd", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad1", |
||||
"source_mapping": { |
||||
"start": 102, |
||||
"length": 85, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
5, |
||||
6, |
||||
7 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad1(uint256)" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.myMap(x)", |
||||
"source_mapping": { |
||||
"start": 160, |
||||
"length": 20, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
6 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 29 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad1", |
||||
"source_mapping": { |
||||
"start": 102, |
||||
"length": 85, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
5, |
||||
6, |
||||
7 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad1(uint256)" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad1(uint256) (tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#5-7) reads this.myMap(x) (tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#6) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad1(uint256)](tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L5-L7) reads [this.myMap(x)](tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L6) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L5-L7", |
||||
"id": "ce4d740b2da0b9b71f2dd3dd1c0903124f7be34009ede12a43dc33c6f28b9d28", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad3", |
||||
"source_mapping": { |
||||
"start": 275, |
||||
"length": 99, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
11, |
||||
12, |
||||
13 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad3()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "this.erc20() == address(0)", |
||||
"source_mapping": { |
||||
"start": 331, |
||||
"length": 26, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
12 |
||||
], |
||||
"starting_column": 13, |
||||
"ending_column": 39 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad3", |
||||
"source_mapping": { |
||||
"start": 275, |
||||
"length": 99, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
11, |
||||
12, |
||||
13 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad3()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad3() (tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#11-13) reads this.erc20() == address(0) (tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#12) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad3()](tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L11-L13) reads [this.erc20() == address(0)](tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L12) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L11-L13", |
||||
"id": "d4602ee9be1e60f8ae80e6d0a867b532cb2ddef0ba44b25af8808a0ac5a6b828", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
}, |
||||
{ |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "bad4", |
||||
"source_mapping": { |
||||
"start": 379, |
||||
"length": 138, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
14, |
||||
15, |
||||
16, |
||||
17, |
||||
18 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad4()" |
||||
} |
||||
}, |
||||
{ |
||||
"type": "node", |
||||
"name": "local = this.erc20()", |
||||
"source_mapping": { |
||||
"start": 471, |
||||
"length": 28, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
16 |
||||
], |
||||
"starting_column": 13, |
||||
"ending_column": 41 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "function", |
||||
"name": "bad4", |
||||
"source_mapping": { |
||||
"start": 379, |
||||
"length": 138, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
14, |
||||
15, |
||||
16, |
||||
17, |
||||
18 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 6 |
||||
}, |
||||
"type_specific_fields": { |
||||
"parent": { |
||||
"type": "contract", |
||||
"name": "VarReadUsingThis", |
||||
"source_mapping": { |
||||
"start": 1, |
||||
"length": 1103, |
||||
"filename_relative": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"filename_absolute": "/GENERIC_PATH", |
||||
"filename_short": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol", |
||||
"is_dependency": false, |
||||
"lines": [ |
||||
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 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
}, |
||||
"signature": "bad4()" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
], |
||||
"description": "The function VarReadUsingThis.bad4() (tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#14-18) reads local = this.erc20() (tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#16) with `this` which adds an extra STATICCALL.\n", |
||||
"markdown": "The function [VarReadUsingThis.bad4()](tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L14-L18) reads [local = this.erc20()](tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L16) with `this` which adds an extra STATICCALL.\n", |
||||
"first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L14-L18", |
||||
"id": "fec10ba084a6322d0fbb895e6c7ca6bca380b48a54d2ecae92a017b8b41242bf", |
||||
"check": "var-read-using-this", |
||||
"impact": "Optimization", |
||||
"confidence": "High" |
||||
} |
||||
] |
||||
] |
Loading…
Reference in new issue