From fd2fb3352ce0ff173c11ad004d8c39c6c9daf999 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 28 Nov 2022 08:49:03 -0600 Subject: [PATCH 1/6] add var-read-using-this detector --- slither/detectors/all_detectors.py | 1 + .../variables/var_read_using_this.py | 54 ++ .../0.4.25/var_read_using_this.sol | 33 + ...sing_this.sol.0.4.25.VarReadUsingThis.json | 3 + .../0.5.16/var_read_using_this.sol | 33 + ...sing_this.sol.0.5.16.VarReadUsingThis.json | 708 ++++++++++++++++++ .../0.6.11/var_read_using_this.sol | 33 + ...sing_this.sol.0.6.11.VarReadUsingThis.json | 708 ++++++++++++++++++ .../0.7.6/var_read_using_this.sol | 33 + ...using_this.sol.0.7.6.VarReadUsingThis.json | 708 ++++++++++++++++++ .../0.8.15/var_read_using_this.sol | 33 + ...sing_this.sol.0.8.15.VarReadUsingThis.json | 708 ++++++++++++++++++ tests/test_detectors.py | 21 + 13 files changed, 3076 insertions(+) create mode 100644 slither/detectors/variables/var_read_using_this.py create mode 100644 tests/detectors/var-read-using-this/0.4.25/var_read_using_this.sol create mode 100644 tests/detectors/var-read-using-this/0.4.25/var_read_using_this.sol.0.4.25.VarReadUsingThis.json create mode 100644 tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol create mode 100644 tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json create mode 100644 tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol create mode 100644 tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json create mode 100644 tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol create mode 100644 tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json create mode 100644 tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol create mode 100644 tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json diff --git a/slither/detectors/all_detectors.py b/slither/detectors/all_detectors.py index 2c8d244281..1169917a67 100644 --- a/slither/detectors/all_detectors.py +++ b/slither/detectors/all_detectors.py @@ -3,6 +3,7 @@ from .variables.uninitialized_state_variables import UninitializedStateVarsDetection from .variables.uninitialized_storage_variables import UninitializedStorageVars from .variables.uninitialized_local_variables import UninitializedLocalVars +from .variables.var_read_using_this import VarReadUsingThis from .attributes.constant_pragma import ConstantPragma from .attributes.incorrect_solc import IncorrectSolc from .attributes.locked_ether import LockedEther diff --git a/slither/detectors/variables/var_read_using_this.py b/slither/detectors/variables/var_read_using_this.py new file mode 100644 index 0000000000..8f62f91111 --- /dev/null +++ b/slither/detectors/variables/var_read_using_this.py @@ -0,0 +1,54 @@ +from typing import List +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.MEDIUM + + WIKI = "https://github.com/trailofbits/slither-private/wiki/Vulnerabilities-Description#var-read-using-this" + + WIKI_TITLE = "Variable read using this" + WIKI_DESCRIPTION = "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 STATICALL.\n", + ] + json = self.generate_result(info) + results.append(json) + + return results + + def _detect_var_read_using_this(self, func: Function) -> List: + results = [] + for node in func.nodes: + for ir in node.irs: + if isinstance(ir, HighLevelCall): + if ir.destination == SolidityVariable("this") and ir.is_static_call(): + results.append(node) + return results diff --git a/tests/detectors/var-read-using-this/0.4.25/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.4.25/var_read_using_this.sol new file mode 100644 index 0000000000..dc0d152be1 --- /dev/null +++ b/tests/detectors/var-read-using-this/0.4.25/var_read_using_this.sol @@ -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; + } + } +} diff --git a/tests/detectors/var-read-using-this/0.4.25/var_read_using_this.sol.0.4.25.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.4.25/var_read_using_this.sol.0.4.25.VarReadUsingThis.json new file mode 100644 index 0000000000..5825bcacc6 --- /dev/null +++ b/tests/detectors/var-read-using-this/0.4.25/var_read_using_this.sol.0.4.25.VarReadUsingThis.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol new file mode 100644 index 0000000000..dc0d152be1 --- /dev/null +++ b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol @@ -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; + } + } +} diff --git a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json new file mode 100644 index 0000000000..556194437b --- /dev/null +++ b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json @@ -0,0 +1,708 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "bad2", + "source_mapping": { + "start": 192, + "length": 78, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" + } + }, + { + "type": "node", + "name": "this.erc20()", + "source_mapping": { + "start": 244, + "length": 19, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L8-L10", + "id": "0178009997f4d2c4d9a3a9e966bc7c3277ba1ce8c8c412b04fbe2cab3eab1b64", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 102, + "length": 85, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1(uint256)" + } + }, + { + "type": "node", + "name": "this.myMap(x)", + "source_mapping": { + "start": 160, + "length": 20, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L5-L7", + "id": "1aeda0f171a714323d2cc886a4569374dcecf4a31bfd07dd341985cb91c1cda4", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad4", + "source_mapping": { + "start": 379, + "length": 138, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad4()" + } + }, + { + "type": "node", + "name": "local = this.erc20()", + "source_mapping": { + "start": 471, + "length": 28, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L14-L18", + "id": "512bc7a6d6d4fc95951dd03634d193a2e29b0162882a8b4be6e27ff899e21b2d", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad3", + "source_mapping": { + "start": 275, + "length": 99, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad3()" + } + }, + { + "type": "node", + "name": "this.erc20() == address(0)", + "source_mapping": { + "start": 331, + "length": 26, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L11-L13", + "id": "e230fb1483c53ad953389bae20f599c95bbb5feb0040a4b9c33da5ec96682eff", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol new file mode 100644 index 0000000000..dc0d152be1 --- /dev/null +++ b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol @@ -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; + } + } +} diff --git a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json new file mode 100644 index 0000000000..8a153fbf83 --- /dev/null +++ b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json @@ -0,0 +1,708 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "bad3", + "source_mapping": { + "start": 275, + "length": 99, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad3()" + } + }, + { + "type": "node", + "name": "this.erc20() == address(0)", + "source_mapping": { + "start": 331, + "length": 26, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L11-L13", + "id": "0207d6c951b693638b81afe89cdee392fd61a671e0a92e1f8c8b4e5824b1d25b", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad2", + "source_mapping": { + "start": 192, + "length": 78, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" + } + }, + { + "type": "node", + "name": "this.erc20()", + "source_mapping": { + "start": 244, + "length": 19, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L8-L10", + "id": "58da220580586bad1af775ff0da07248cea80f98a30f3173c494ce5517d4b041", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad4", + "source_mapping": { + "start": 379, + "length": 138, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad4()" + } + }, + { + "type": "node", + "name": "local = this.erc20()", + "source_mapping": { + "start": 471, + "length": 28, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L14-L18", + "id": "6d5eeb058ec44a05d486b3ee7c2911a7f5306b3d0b619a52ae08efe195c8614c", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 102, + "length": 85, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1(uint256)" + } + }, + { + "type": "node", + "name": "this.myMap(x)", + "source_mapping": { + "start": 160, + "length": 20, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L5-L7", + "id": "b8b557dc26e17f526df0fd98af8c5d06013dd18b163e05a281ea1519e15ca24e", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol new file mode 100644 index 0000000000..dc0d152be1 --- /dev/null +++ b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol @@ -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; + } + } +} diff --git a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json new file mode 100644 index 0000000000..42b3864bbe --- /dev/null +++ b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json @@ -0,0 +1,708 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "bad3", + "source_mapping": { + "start": 275, + "length": 99, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad3()" + } + }, + { + "type": "node", + "name": "this.erc20() == address(0)", + "source_mapping": { + "start": 331, + "length": 26, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L11-L13", + "id": "44eec3d0ad87871981571b3d571f13579272bdabcfebe6bd25ac2880d2bf3c33", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad4", + "source_mapping": { + "start": 379, + "length": 138, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad4()" + } + }, + { + "type": "node", + "name": "local = this.erc20()", + "source_mapping": { + "start": 471, + "length": 28, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L14-L18", + "id": "519caa8ce5e7990c223fd65d827817bb93fe3020efcf9133f204f7a80f6a4e7f", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 102, + "length": 85, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1(uint256)" + } + }, + { + "type": "node", + "name": "this.myMap(x)", + "source_mapping": { + "start": 160, + "length": 20, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L5-L7", + "id": "7f28036af3c8cd6bc29a5a25378629d8f703b655a55f3a5cf36e8b96a11c792a", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad2", + "source_mapping": { + "start": 192, + "length": 78, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" + } + }, + { + "type": "node", + "name": "this.erc20()", + "source_mapping": { + "start": 244, + "length": 19, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L8-L10", + "id": "a19dc63eefbe43a4a7642c957b7b96fad0c42563e18d0b03fb1592c1ad5bad04", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol new file mode 100644 index 0000000000..dc0d152be1 --- /dev/null +++ b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol @@ -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; + } + } +} diff --git a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json new file mode 100644 index 0000000000..f29ea3ff3e --- /dev/null +++ b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json @@ -0,0 +1,708 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "bad4", + "source_mapping": { + "start": 379, + "length": 138, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad4()" + } + }, + { + "type": "node", + "name": "local = this.erc20()", + "source_mapping": { + "start": 471, + "length": 28, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L14-L18", + "id": "1224862cf823193c24ce4a02579e7b9cf0eaded7167e8c9f9ed2861d9a9910cc", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad3", + "source_mapping": { + "start": 275, + "length": 99, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad3()" + } + }, + { + "type": "node", + "name": "this.erc20() == address(0)", + "source_mapping": { + "start": 331, + "length": 26, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L11-L13", + "id": "29d9293adc1046d877a098beb2f9b7757658226e50c6d28228df65dfeeba7fd8", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad2", + "source_mapping": { + "start": 192, + "length": 78, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" + } + }, + { + "type": "node", + "name": "this.erc20()", + "source_mapping": { + "start": 244, + "length": 19, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L8-L10", + "id": "38e0c82eed10e2c79f5d232284f6e0d0b12966f71eaee7a5139a82e927d38005", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + }, + { + "elements": [ + { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 102, + "length": 85, + "filename_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1(uint256)" + } + }, + { + "type": "node", + "name": "this.myMap(x)", + "source_mapping": { + "start": 160, + "length": 20, + "filename_used": "/GENERIC_PATH", + "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_used": "/GENERIC_PATH", + "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": 916, + "filename_used": "/GENERIC_PATH", + "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 + ], + "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 STATICALL.\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 STATICALL.\n", + "first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L5-L7", + "id": "aa84305fa524be189a9e050c79cea81a7bc258614c7563e22738e17a3559615a", + "check": "var-read-using-this", + "impact": "Optimization", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/test_detectors.py b/tests/test_detectors.py index 7a27e2d4b6..46f763ea74 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -1553,6 +1553,27 @@ def id_test(test_item: Test): "permit_domain_state_var_collision.sol", "0.8.0", ), + Test( + all_detectors.VarReadUsingThis, + "var_read_using_this.sol", + "0.4.25", + ), + Test( + all_detectors.VarReadUsingThis, + "var_read_using_this.sol", + "0.5.16", + ), + Test(all_detectors.VarReadUsingThis, "var_read_using_this.sol", "0.6.11"), + Test( + all_detectors.VarReadUsingThis, + "var_read_using_this.sol", + "0.7.6", + ), + Test( + all_detectors.VarReadUsingThis, + "var_read_using_this.sol", + "0.8.15", + ), ] From 72459a90d4ae8b2be7f4164adee7dfe36f959744 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 28 Nov 2022 13:42:02 -0600 Subject: [PATCH 2/6] regenerate artifacts --- ...sing_this.sol.0.5.16.VarReadUsingThis.json | 20 ------------------- ...sing_this.sol.0.6.11.VarReadUsingThis.json | 20 ------------------- ...using_this.sol.0.7.6.VarReadUsingThis.json | 20 ------------------- ...sing_this.sol.0.8.15.VarReadUsingThis.json | 20 ------------------- 4 files changed, 80 deletions(-) diff --git a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json index 556194437b..5034c795c3 100644 --- a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json @@ -8,7 +8,6 @@ "source_mapping": { "start": 192, "length": 78, - "filename_used": "/GENERIC_PATH", "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", @@ -28,7 +27,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -80,7 +78,6 @@ "source_mapping": { "start": 244, "length": 19, - "filename_used": "/GENERIC_PATH", "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", @@ -98,7 +95,6 @@ "source_mapping": { "start": 192, "length": 78, - "filename_used": "/GENERIC_PATH", "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", @@ -118,7 +114,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -183,7 +178,6 @@ "source_mapping": { "start": 102, "length": 85, - "filename_used": "/GENERIC_PATH", "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", @@ -203,7 +197,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -255,7 +248,6 @@ "source_mapping": { "start": 160, "length": 20, - "filename_used": "/GENERIC_PATH", "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", @@ -273,7 +265,6 @@ "source_mapping": { "start": 102, "length": 85, - "filename_used": "/GENERIC_PATH", "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", @@ -293,7 +284,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -358,7 +348,6 @@ "source_mapping": { "start": 379, "length": 138, - "filename_used": "/GENERIC_PATH", "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", @@ -380,7 +369,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -432,7 +420,6 @@ "source_mapping": { "start": 471, "length": 28, - "filename_used": "/GENERIC_PATH", "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", @@ -450,7 +437,6 @@ "source_mapping": { "start": 379, "length": 138, - "filename_used": "/GENERIC_PATH", "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", @@ -472,7 +458,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -537,7 +522,6 @@ "source_mapping": { "start": 275, "length": 99, - "filename_used": "/GENERIC_PATH", "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", @@ -557,7 +541,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -609,7 +592,6 @@ "source_mapping": { "start": 331, "length": 26, - "filename_used": "/GENERIC_PATH", "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", @@ -627,7 +609,6 @@ "source_mapping": { "start": 275, "length": 99, - "filename_used": "/GENERIC_PATH", "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", @@ -647,7 +628,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", diff --git a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json index 8a153fbf83..f865074ca3 100644 --- a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json @@ -8,7 +8,6 @@ "source_mapping": { "start": 275, "length": 99, - "filename_used": "/GENERIC_PATH", "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", @@ -28,7 +27,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -80,7 +78,6 @@ "source_mapping": { "start": 331, "length": 26, - "filename_used": "/GENERIC_PATH", "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", @@ -98,7 +95,6 @@ "source_mapping": { "start": 275, "length": 99, - "filename_used": "/GENERIC_PATH", "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", @@ -118,7 +114,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -183,7 +178,6 @@ "source_mapping": { "start": 192, "length": 78, - "filename_used": "/GENERIC_PATH", "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", @@ -203,7 +197,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -255,7 +248,6 @@ "source_mapping": { "start": 244, "length": 19, - "filename_used": "/GENERIC_PATH", "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", @@ -273,7 +265,6 @@ "source_mapping": { "start": 192, "length": 78, - "filename_used": "/GENERIC_PATH", "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", @@ -293,7 +284,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -358,7 +348,6 @@ "source_mapping": { "start": 379, "length": 138, - "filename_used": "/GENERIC_PATH", "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", @@ -380,7 +369,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -432,7 +420,6 @@ "source_mapping": { "start": 471, "length": 28, - "filename_used": "/GENERIC_PATH", "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", @@ -450,7 +437,6 @@ "source_mapping": { "start": 379, "length": 138, - "filename_used": "/GENERIC_PATH", "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", @@ -472,7 +458,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -537,7 +522,6 @@ "source_mapping": { "start": 102, "length": 85, - "filename_used": "/GENERIC_PATH", "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", @@ -557,7 +541,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -609,7 +592,6 @@ "source_mapping": { "start": 160, "length": 20, - "filename_used": "/GENERIC_PATH", "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", @@ -627,7 +609,6 @@ "source_mapping": { "start": 102, "length": 85, - "filename_used": "/GENERIC_PATH", "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", @@ -647,7 +628,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", diff --git a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json index 42b3864bbe..b43d123cd5 100644 --- a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json @@ -8,7 +8,6 @@ "source_mapping": { "start": 275, "length": 99, - "filename_used": "/GENERIC_PATH", "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", @@ -28,7 +27,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -80,7 +78,6 @@ "source_mapping": { "start": 331, "length": 26, - "filename_used": "/GENERIC_PATH", "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", @@ -98,7 +95,6 @@ "source_mapping": { "start": 275, "length": 99, - "filename_used": "/GENERIC_PATH", "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", @@ -118,7 +114,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -183,7 +178,6 @@ "source_mapping": { "start": 379, "length": 138, - "filename_used": "/GENERIC_PATH", "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", @@ -205,7 +199,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -257,7 +250,6 @@ "source_mapping": { "start": 471, "length": 28, - "filename_used": "/GENERIC_PATH", "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", @@ -275,7 +267,6 @@ "source_mapping": { "start": 379, "length": 138, - "filename_used": "/GENERIC_PATH", "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", @@ -297,7 +288,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -362,7 +352,6 @@ "source_mapping": { "start": 102, "length": 85, - "filename_used": "/GENERIC_PATH", "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", @@ -382,7 +371,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -434,7 +422,6 @@ "source_mapping": { "start": 160, "length": 20, - "filename_used": "/GENERIC_PATH", "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", @@ -452,7 +439,6 @@ "source_mapping": { "start": 102, "length": 85, - "filename_used": "/GENERIC_PATH", "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", @@ -472,7 +458,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -537,7 +522,6 @@ "source_mapping": { "start": 192, "length": 78, - "filename_used": "/GENERIC_PATH", "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", @@ -557,7 +541,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -609,7 +592,6 @@ "source_mapping": { "start": 244, "length": 19, - "filename_used": "/GENERIC_PATH", "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", @@ -627,7 +609,6 @@ "source_mapping": { "start": 192, "length": 78, - "filename_used": "/GENERIC_PATH", "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", @@ -647,7 +628,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", diff --git a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json index f29ea3ff3e..23295ecb2b 100644 --- a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json @@ -8,7 +8,6 @@ "source_mapping": { "start": 379, "length": 138, - "filename_used": "/GENERIC_PATH", "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", @@ -30,7 +29,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -82,7 +80,6 @@ "source_mapping": { "start": 471, "length": 28, - "filename_used": "/GENERIC_PATH", "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", @@ -100,7 +97,6 @@ "source_mapping": { "start": 379, "length": 138, - "filename_used": "/GENERIC_PATH", "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", @@ -122,7 +118,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -187,7 +182,6 @@ "source_mapping": { "start": 275, "length": 99, - "filename_used": "/GENERIC_PATH", "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", @@ -207,7 +201,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -259,7 +252,6 @@ "source_mapping": { "start": 331, "length": 26, - "filename_used": "/GENERIC_PATH", "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", @@ -277,7 +269,6 @@ "source_mapping": { "start": 275, "length": 99, - "filename_used": "/GENERIC_PATH", "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", @@ -297,7 +288,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -362,7 +352,6 @@ "source_mapping": { "start": 192, "length": 78, - "filename_used": "/GENERIC_PATH", "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", @@ -382,7 +371,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -434,7 +422,6 @@ "source_mapping": { "start": 244, "length": 19, - "filename_used": "/GENERIC_PATH", "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", @@ -452,7 +439,6 @@ "source_mapping": { "start": 192, "length": 78, - "filename_used": "/GENERIC_PATH", "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", @@ -472,7 +458,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -537,7 +522,6 @@ "source_mapping": { "start": 102, "length": 85, - "filename_used": "/GENERIC_PATH", "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", @@ -557,7 +541,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", @@ -609,7 +592,6 @@ "source_mapping": { "start": 160, "length": 20, - "filename_used": "/GENERIC_PATH", "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", @@ -627,7 +609,6 @@ "source_mapping": { "start": 102, "length": 85, - "filename_used": "/GENERIC_PATH", "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", @@ -647,7 +628,6 @@ "source_mapping": { "start": 1, "length": 916, - "filename_used": "/GENERIC_PATH", "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", From 83f74f10c9b67f86ef51f9b20f3acae61b53c982 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 28 Nov 2022 13:50:22 -0600 Subject: [PATCH 3/6] appease pylint --- slither/detectors/variables/var_read_using_this.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/slither/detectors/variables/var_read_using_this.py b/slither/detectors/variables/var_read_using_this.py index 8f62f91111..96b413236c 100644 --- a/slither/detectors/variables/var_read_using_this.py +++ b/slither/detectors/variables/var_read_using_this.py @@ -1,4 +1,5 @@ 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 @@ -44,8 +45,9 @@ def _detect(self): return results - def _detect_var_read_using_this(self, func: Function) -> List: - 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): From a6ce9961aa4239088ca05779d9bedd483335ce0b Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 12 Dec 2022 08:48:40 -0600 Subject: [PATCH 4/6] change confidence to high --- slither/detectors/variables/var_read_using_this.py | 2 +- .../var_read_using_this.sol.0.5.16.VarReadUsingThis.json | 8 ++++---- .../var_read_using_this.sol.0.6.11.VarReadUsingThis.json | 8 ++++---- .../var_read_using_this.sol.0.7.6.VarReadUsingThis.json | 8 ++++---- .../var_read_using_this.sol.0.8.15.VarReadUsingThis.json | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/slither/detectors/variables/var_read_using_this.py b/slither/detectors/variables/var_read_using_this.py index 96b413236c..7ba9b87b66 100644 --- a/slither/detectors/variables/var_read_using_this.py +++ b/slither/detectors/variables/var_read_using_this.py @@ -9,7 +9,7 @@ class VarReadUsingThis(AbstractDetector): ARGUMENT = "var-read-using-this" HELP = "Contract reads its own variable using `this`" IMPACT = DetectorClassification.OPTIMIZATION - CONFIDENCE = DetectorClassification.MEDIUM + CONFIDENCE = DetectorClassification.HIGH WIKI = "https://github.com/trailofbits/slither-private/wiki/Vulnerabilities-Description#var-read-using-this" diff --git a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json index 5034c795c3..bdd201bd2e 100644 --- a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json @@ -168,7 +168,7 @@ "id": "0178009997f4d2c4d9a3a9e966bc7c3277ba1ce8c8c412b04fbe2cab3eab1b64", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -338,7 +338,7 @@ "id": "1aeda0f171a714323d2cc886a4569374dcecf4a31bfd07dd341985cb91c1cda4", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -512,7 +512,7 @@ "id": "512bc7a6d6d4fc95951dd03634d193a2e29b0162882a8b4be6e27ff899e21b2d", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -682,7 +682,7 @@ "id": "e230fb1483c53ad953389bae20f599c95bbb5feb0040a4b9c33da5ec96682eff", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" } ] ] \ No newline at end of file diff --git a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json index f865074ca3..df316c390d 100644 --- a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json @@ -168,7 +168,7 @@ "id": "0207d6c951b693638b81afe89cdee392fd61a671e0a92e1f8c8b4e5824b1d25b", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -338,7 +338,7 @@ "id": "58da220580586bad1af775ff0da07248cea80f98a30f3173c494ce5517d4b041", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -512,7 +512,7 @@ "id": "6d5eeb058ec44a05d486b3ee7c2911a7f5306b3d0b619a52ae08efe195c8614c", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -682,7 +682,7 @@ "id": "b8b557dc26e17f526df0fd98af8c5d06013dd18b163e05a281ea1519e15ca24e", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" } ] ] \ No newline at end of file diff --git a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json index b43d123cd5..770276729e 100644 --- a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json @@ -168,7 +168,7 @@ "id": "44eec3d0ad87871981571b3d571f13579272bdabcfebe6bd25ac2880d2bf3c33", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -342,7 +342,7 @@ "id": "519caa8ce5e7990c223fd65d827817bb93fe3020efcf9133f204f7a80f6a4e7f", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -512,7 +512,7 @@ "id": "7f28036af3c8cd6bc29a5a25378629d8f703b655a55f3a5cf36e8b96a11c792a", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -682,7 +682,7 @@ "id": "a19dc63eefbe43a4a7642c957b7b96fad0c42563e18d0b03fb1592c1ad5bad04", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" } ] ] \ No newline at end of file diff --git a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json index 23295ecb2b..4914c3f3b2 100644 --- a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json @@ -172,7 +172,7 @@ "id": "1224862cf823193c24ce4a02579e7b9cf0eaded7167e8c9f9ed2861d9a9910cc", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -342,7 +342,7 @@ "id": "29d9293adc1046d877a098beb2f9b7757658226e50c6d28228df65dfeeba7fd8", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -512,7 +512,7 @@ "id": "38e0c82eed10e2c79f5d232284f6e0d0b12966f71eaee7a5139a82e927d38005", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" }, { "elements": [ @@ -682,7 +682,7 @@ "id": "aa84305fa524be189a9e050c79cea81a7bc258614c7563e22738e17a3559615a", "check": "var-read-using-this", "impact": "Optimization", - "confidence": "Medium" + "confidence": "High" } ] ] \ No newline at end of file From 3c7802f2e9c04a35f8b268b0741ad0500b4dcadf Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Wed, 14 Dec 2022 12:17:17 -0600 Subject: [PATCH 5/6] filter out external visibility and update wiki --- .../variables/var_read_using_this.py | 16 +- .../0.5.16/var_read_using_this.sol | 6 + ...sing_this.sol.0.5.16.VarReadUsingThis.json | 276 ++++++++++------- .../0.6.11/var_read_using_this.sol | 6 + ...sing_this.sol.0.6.11.VarReadUsingThis.json | 236 +++++++++------ .../0.7.6/var_read_using_this.sol | 6 + ...using_this.sol.0.7.6.VarReadUsingThis.json | 196 +++++++----- .../0.8.15/var_read_using_this.sol | 6 + ...sing_this.sol.0.8.15.VarReadUsingThis.json | 280 ++++++++++-------- 9 files changed, 624 insertions(+), 404 deletions(-) diff --git a/slither/detectors/variables/var_read_using_this.py b/slither/detectors/variables/var_read_using_this.py index 7ba9b87b66..3d9f204c26 100644 --- a/slither/detectors/variables/var_read_using_this.py +++ b/slither/detectors/variables/var_read_using_this.py @@ -11,10 +11,10 @@ class VarReadUsingThis(AbstractDetector): IMPACT = DetectorClassification.OPTIMIZATION CONFIDENCE = DetectorClassification.HIGH - WIKI = "https://github.com/trailofbits/slither-private/wiki/Vulnerabilities-Description#var-read-using-this" + WIKI = "https://github.com/crytic/slither/wiki/Vulnerabilities-Description#public-variable-read-in-external-context" - WIKI_TITLE = "Variable read using this" - WIKI_DESCRIPTION = "Contract reads its own variable using `this`, adding overhead of an unnecessary STATICCALL." + 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 { @@ -38,7 +38,7 @@ def _detect(self): func, " reads ", node, - " with `this` which adds an extra STATICALL.\n", + " with `this` which adds an extra STATICCALL.\n", ] json = self.generate_result(info) results.append(json) @@ -51,6 +51,10 @@ def _detect_var_read_using_this(func: Function) -> 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(): + if ( + ir.destination == SolidityVariable("this") + and ir.is_static_call() + and ir.function.visibility == "public" + ): results.append(node) - return results + return sorted(results, key=lambda x: x.node_id) diff --git a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol index dc0d152be1..2382bf91a0 100644 --- a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol +++ b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol @@ -29,5 +29,11 @@ contract VarReadUsingThis { for (uint x; x < 10; x++) { address local = erc20; } + } + function mapExternal(uint x) external returns(address) { + return myMap[x]; + } + function good5(uint x) external returns(address) { + this.mapExternal(x); } } diff --git a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json index bdd201bd2e..4b9a593140 100644 --- a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json @@ -4,18 +4,18 @@ "elements": [ { "type": "function", - "name": "bad2", + "name": "bad3", "source_mapping": { - "start": 192, - "length": 78, + "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": [ - 8, - 9, - 10 + 11, + 12, + 13 ], "starting_column": 5, "ending_column": 6 @@ -26,7 +26,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1102, "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", @@ -63,46 +63,52 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad2()" + "signature": "bad3()" } }, { "type": "node", - "name": "this.erc20()", + "name": "this.erc20() == address(0)", "source_mapping": { - "start": 244, - "length": 19, + "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": [ - 9 + 12 ], - "starting_column": 9, - "ending_column": 28 + "starting_column": 13, + "ending_column": 39 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad2", + "name": "bad3", "source_mapping": { - "start": 192, - "length": 78, + "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": [ - 8, - 9, - 10 + 11, + 12, + 13 ], "starting_column": 5, "ending_column": 6 @@ -113,7 +119,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1102, "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", @@ -150,22 +156,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad2()" + "signature": "bad3()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L8-L10", - "id": "0178009997f4d2c4d9a3a9e966bc7c3277ba1ce8c8c412b04fbe2cab3eab1b64", + "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" @@ -174,18 +186,18 @@ "elements": [ { "type": "function", - "name": "bad1", + "name": "bad2", "source_mapping": { - "start": 102, - "length": 85, + "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": [ - 5, - 6, - 7 + 8, + 9, + 10 ], "starting_column": 5, "ending_column": 6 @@ -196,7 +208,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1102, "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", @@ -233,46 +245,52 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad1(uint256)" + "signature": "bad2()" } }, { "type": "node", - "name": "this.myMap(x)", + "name": "this.erc20()", "source_mapping": { - "start": 160, - "length": 20, + "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": [ - 6 + 9 ], "starting_column": 9, - "ending_column": 29 + "ending_column": 28 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad1", + "name": "bad2", "source_mapping": { - "start": 102, - "length": 85, + "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": [ - 5, - 6, - 7 + 8, + 9, + 10 ], "starting_column": 5, "ending_column": 6 @@ -283,7 +301,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1102, "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", @@ -320,22 +338,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad1(uint256)" + "signature": "bad2()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L5-L7", - "id": "1aeda0f171a714323d2cc886a4569374dcecf4a31bfd07dd341985cb91c1cda4", + "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" @@ -344,20 +368,18 @@ "elements": [ { "type": "function", - "name": "bad4", + "name": "bad1", "source_mapping": { - "start": 379, - "length": 138, + "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": [ - 14, - 15, - 16, - 17, - 18 + 5, + 6, + 7 ], "starting_column": 5, "ending_column": 6 @@ -368,7 +390,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1102, "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", @@ -405,48 +427,52 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad4()" + "signature": "bad1(uint256)" } }, { "type": "node", - "name": "local = this.erc20()", + "name": "this.myMap(x)", "source_mapping": { - "start": 471, - "length": 28, + "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": [ - 16 + 6 ], - "starting_column": 13, - "ending_column": 41 + "starting_column": 9, + "ending_column": 29 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad4", + "name": "bad1", "source_mapping": { - "start": 379, - "length": 138, + "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": [ - 14, - 15, - 16, - 17, - 18 + 5, + 6, + 7 ], "starting_column": 5, "ending_column": 6 @@ -457,7 +483,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1102, "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", @@ -494,22 +520,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad4()" + "signature": "bad1(uint256)" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L14-L18", - "id": "512bc7a6d6d4fc95951dd03634d193a2e29b0162882a8b4be6e27ff899e21b2d", + "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" @@ -518,18 +550,20 @@ "elements": [ { "type": "function", - "name": "bad3", + "name": "bad4", "source_mapping": { - "start": 275, - "length": 99, + "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": [ - 11, - 12, - 13 + 14, + 15, + 16, + 17, + 18 ], "starting_column": 5, "ending_column": 6 @@ -540,7 +574,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1102, "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", @@ -577,46 +611,54 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad3()" + "signature": "bad4()" } }, { "type": "node", - "name": "this.erc20() == address(0)", + "name": "local = this.erc20()", "source_mapping": { - "start": 331, - "length": 26, + "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": [ - 12 + 16 ], "starting_column": 13, - "ending_column": 39 + "ending_column": 41 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad3", + "name": "bad4", "source_mapping": { - "start": 275, - "length": 99, + "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": [ - 11, - 12, - 13 + 14, + 15, + 16, + 17, + 18 ], "starting_column": 5, "ending_column": 6 @@ -627,7 +669,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1102, "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", @@ -664,22 +706,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad3()" + "signature": "bad4()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol#L11-L13", - "id": "e230fb1483c53ad953389bae20f599c95bbb5feb0040a4b9c33da5ec96682eff", + "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" diff --git a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol index dc0d152be1..e252aa8484 100644 --- a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol +++ b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol @@ -30,4 +30,10 @@ contract VarReadUsingThis { address local = erc20; } } + function mapExternal(uint x) external returns(address) { + return myMap[x]; + } + function good5(uint x) external returns(address) { + this.mapExternal(x); + } } diff --git a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json index df316c390d..7961802318 100644 --- a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json @@ -26,7 +26,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -63,7 +63,13 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 @@ -113,7 +119,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -150,7 +156,13 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 @@ -162,10 +174,10 @@ } } ], - "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 STATICALL.\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 STATICALL.\n", + "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": "0207d6c951b693638b81afe89cdee392fd61a671e0a92e1f8c8b4e5824b1d25b", + "id": "314f90a4989ea75cc274e1f5f46036968c2ecdaaf8fa84913e7db4ef1ffe5bb8", "check": "var-read-using-this", "impact": "Optimization", "confidence": "High" @@ -174,18 +186,20 @@ "elements": [ { "type": "function", - "name": "bad2", + "name": "bad4", "source_mapping": { - "start": 192, - "length": 78, + "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": [ - 8, - 9, - 10 + 14, + 15, + 16, + 17, + 18 ], "starting_column": 5, "ending_column": 6 @@ -196,7 +210,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -233,46 +247,54 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad2()" + "signature": "bad4()" } }, { "type": "node", - "name": "this.erc20()", + "name": "local = this.erc20()", "source_mapping": { - "start": 244, - "length": 19, + "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": [ - 9 + 16 ], - "starting_column": 9, - "ending_column": 28 + "starting_column": 13, + "ending_column": 41 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad2", + "name": "bad4", "source_mapping": { - "start": 192, - "length": 78, + "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": [ - 8, - 9, - 10 + 14, + 15, + 16, + 17, + 18 ], "starting_column": 5, "ending_column": 6 @@ -283,7 +305,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -320,22 +342,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad2()" + "signature": "bad4()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L8-L10", - "id": "58da220580586bad1af775ff0da07248cea80f98a30f3173c494ce5517d4b041", + "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" @@ -344,20 +372,18 @@ "elements": [ { "type": "function", - "name": "bad4", + "name": "bad1", "source_mapping": { - "start": 379, - "length": 138, + "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": [ - 14, - 15, - 16, - 17, - 18 + 5, + 6, + 7 ], "starting_column": 5, "ending_column": 6 @@ -368,7 +394,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -405,48 +431,52 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad4()" + "signature": "bad1(uint256)" } }, { "type": "node", - "name": "local = this.erc20()", + "name": "this.myMap(x)", "source_mapping": { - "start": 471, - "length": 28, + "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": [ - 16 + 6 ], - "starting_column": 13, - "ending_column": 41 + "starting_column": 9, + "ending_column": 29 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad4", + "name": "bad1", "source_mapping": { - "start": 379, - "length": 138, + "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": [ - 14, - 15, - 16, - 17, - 18 + 5, + 6, + 7 ], "starting_column": 5, "ending_column": 6 @@ -457,7 +487,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -494,22 +524,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad4()" + "signature": "bad1(uint256)" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L14-L18", - "id": "6d5eeb058ec44a05d486b3ee7c2911a7f5306b3d0b619a52ae08efe195c8614c", + "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" @@ -518,18 +554,18 @@ "elements": [ { "type": "function", - "name": "bad1", + "name": "bad2", "source_mapping": { - "start": 102, - "length": 85, + "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": [ - 5, - 6, - 7 + 8, + 9, + 10 ], "starting_column": 5, "ending_column": 6 @@ -540,7 +576,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -577,46 +613,52 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad1(uint256)" + "signature": "bad2()" } }, { "type": "node", - "name": "this.myMap(x)", + "name": "this.erc20()", "source_mapping": { - "start": 160, - "length": 20, + "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": [ - 6 + 9 ], "starting_column": 9, - "ending_column": 29 + "ending_column": 28 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad1", + "name": "bad2", "source_mapping": { - "start": 102, - "length": 85, + "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": [ - 5, - 6, - 7 + 8, + 9, + 10 ], "starting_column": 5, "ending_column": 6 @@ -627,7 +669,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -664,22 +706,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad1(uint256)" + "signature": "bad2()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol#L5-L7", - "id": "b8b557dc26e17f526df0fd98af8c5d06013dd18b163e05a281ea1519e15ca24e", + "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" diff --git a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol index dc0d152be1..e252aa8484 100644 --- a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol +++ b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol @@ -30,4 +30,10 @@ contract VarReadUsingThis { address local = erc20; } } + function mapExternal(uint x) external returns(address) { + return myMap[x]; + } + function good5(uint x) external returns(address) { + this.mapExternal(x); + } } diff --git a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json index 770276729e..512ca9fb7e 100644 --- a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json @@ -26,7 +26,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -63,7 +63,13 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 @@ -113,7 +119,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -150,7 +156,13 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 @@ -162,10 +174,10 @@ } } ], - "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 STATICALL.\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 STATICALL.\n", + "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": "44eec3d0ad87871981571b3d571f13579272bdabcfebe6bd25ac2880d2bf3c33", + "id": "1a8ed403cb8c6104a99c9dabdfb64e55282eaedf2c2d8b20fd3b366c49443639", "check": "var-read-using-this", "impact": "Optimization", "confidence": "High" @@ -174,20 +186,18 @@ "elements": [ { "type": "function", - "name": "bad4", + "name": "bad2", "source_mapping": { - "start": 379, - "length": 138, + "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": [ - 14, - 15, - 16, - 17, - 18 + 8, + 9, + 10 ], "starting_column": 5, "ending_column": 6 @@ -198,7 +208,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -235,48 +245,52 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad4()" + "signature": "bad2()" } }, { "type": "node", - "name": "local = this.erc20()", + "name": "this.erc20()", "source_mapping": { - "start": 471, - "length": 28, + "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": [ - 16 + 9 ], - "starting_column": 13, - "ending_column": 41 + "starting_column": 9, + "ending_column": 28 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad4", + "name": "bad2", "source_mapping": { - "start": 379, - "length": 138, + "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": [ - 14, - 15, - 16, - 17, - 18 + 8, + 9, + 10 ], "starting_column": 5, "ending_column": 6 @@ -287,7 +301,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -324,22 +338,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad4()" + "signature": "bad2()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L14-L18", - "id": "519caa8ce5e7990c223fd65d827817bb93fe3020efcf9133f204f7a80f6a4e7f", + "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" @@ -370,7 +390,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -407,7 +427,13 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 @@ -457,7 +483,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -494,7 +520,13 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 @@ -506,10 +538,10 @@ } } ], - "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 STATICALL.\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 STATICALL.\n", + "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": "7f28036af3c8cd6bc29a5a25378629d8f703b655a55f3a5cf36e8b96a11c792a", + "id": "924c227bf74e70dda261578563193b90b60b70a1ad043716e1d98cbc49b87ceb", "check": "var-read-using-this", "impact": "Optimization", "confidence": "High" @@ -518,18 +550,20 @@ "elements": [ { "type": "function", - "name": "bad2", + "name": "bad4", "source_mapping": { - "start": 192, - "length": 78, + "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": [ - 8, - 9, - 10 + 14, + 15, + 16, + 17, + 18 ], "starting_column": 5, "ending_column": 6 @@ -540,7 +574,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -577,46 +611,54 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad2()" + "signature": "bad4()" } }, { "type": "node", - "name": "this.erc20()", + "name": "local = this.erc20()", "source_mapping": { - "start": 244, - "length": 19, + "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": [ - 9 + 16 ], - "starting_column": 9, - "ending_column": 28 + "starting_column": 13, + "ending_column": 41 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad2", + "name": "bad4", "source_mapping": { - "start": 192, - "length": 78, + "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": [ - 8, - 9, - 10 + 14, + 15, + 16, + 17, + 18 ], "starting_column": 5, "ending_column": 6 @@ -627,7 +669,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -664,22 +706,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad2()" + "signature": "bad4()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol#L8-L10", - "id": "a19dc63eefbe43a4a7642c957b7b96fad0c42563e18d0b03fb1592c1ad5bad04", + "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" diff --git a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol index dc0d152be1..e252aa8484 100644 --- a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol +++ b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol @@ -30,4 +30,10 @@ contract VarReadUsingThis { address local = erc20; } } + function mapExternal(uint x) external returns(address) { + return myMap[x]; + } + function good5(uint x) external returns(address) { + this.mapExternal(x); + } } diff --git a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json index 4914c3f3b2..8872bf2fae 100644 --- a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json @@ -4,20 +4,18 @@ "elements": [ { "type": "function", - "name": "bad4", + "name": "bad2", "source_mapping": { - "start": 379, - "length": 138, + "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": [ - 14, - 15, - 16, - 17, - 18 + 8, + 9, + 10 ], "starting_column": 5, "ending_column": 6 @@ -28,7 +26,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -65,48 +63,52 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad4()" + "signature": "bad2()" } }, { "type": "node", - "name": "local = this.erc20()", + "name": "this.erc20()", "source_mapping": { - "start": 471, - "length": 28, + "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": [ - 16 + 9 ], - "starting_column": 13, - "ending_column": 41 + "starting_column": 9, + "ending_column": 28 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad4", + "name": "bad2", "source_mapping": { - "start": 379, - "length": 138, + "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": [ - 14, - 15, - 16, - 17, - 18 + 8, + 9, + 10 ], "starting_column": 5, "ending_column": 6 @@ -117,7 +119,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -154,22 +156,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad4()" + "signature": "bad2()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L14-L18", - "id": "1224862cf823193c24ce4a02579e7b9cf0eaded7167e8c9f9ed2861d9a9910cc", + "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" @@ -178,18 +186,18 @@ "elements": [ { "type": "function", - "name": "bad3", + "name": "bad1", "source_mapping": { - "start": 275, - "length": 99, + "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": [ - 11, - 12, - 13 + 5, + 6, + 7 ], "starting_column": 5, "ending_column": 6 @@ -200,7 +208,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -237,46 +245,52 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad3()" + "signature": "bad1(uint256)" } }, { "type": "node", - "name": "this.erc20() == address(0)", + "name": "this.myMap(x)", "source_mapping": { - "start": 331, - "length": 26, + "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": [ - 12 + 6 ], - "starting_column": 13, - "ending_column": 39 + "starting_column": 9, + "ending_column": 29 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad3", + "name": "bad1", "source_mapping": { - "start": 275, - "length": 99, + "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": [ - 11, - 12, - 13 + 5, + 6, + 7 ], "starting_column": 5, "ending_column": 6 @@ -287,7 +301,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -324,22 +338,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad3()" + "signature": "bad1(uint256)" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L11-L13", - "id": "29d9293adc1046d877a098beb2f9b7757658226e50c6d28228df65dfeeba7fd8", + "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" @@ -348,18 +368,18 @@ "elements": [ { "type": "function", - "name": "bad2", + "name": "bad3", "source_mapping": { - "start": 192, - "length": 78, + "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": [ - 8, - 9, - 10 + 11, + 12, + 13 ], "starting_column": 5, "ending_column": 6 @@ -370,7 +390,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -407,46 +427,52 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad2()" + "signature": "bad3()" } }, { "type": "node", - "name": "this.erc20()", + "name": "this.erc20() == address(0)", "source_mapping": { - "start": 244, - "length": 19, + "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": [ - 9 + 12 ], - "starting_column": 9, - "ending_column": 28 + "starting_column": 13, + "ending_column": 39 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad2", + "name": "bad3", "source_mapping": { - "start": 192, - "length": 78, + "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": [ - 8, - 9, - 10 + 11, + 12, + 13 ], "starting_column": 5, "ending_column": 6 @@ -457,7 +483,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -494,22 +520,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad2()" + "signature": "bad3()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L8-L10", - "id": "38e0c82eed10e2c79f5d232284f6e0d0b12966f71eaee7a5139a82e927d38005", + "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" @@ -518,18 +550,20 @@ "elements": [ { "type": "function", - "name": "bad1", + "name": "bad4", "source_mapping": { - "start": 102, - "length": 85, + "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": [ - 5, - 6, - 7 + 14, + 15, + 16, + 17, + 18 ], "starting_column": 5, "ending_column": 6 @@ -540,7 +574,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -577,46 +611,54 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad1(uint256)" + "signature": "bad4()" } }, { "type": "node", - "name": "this.myMap(x)", + "name": "local = this.erc20()", "source_mapping": { - "start": 160, - "length": 20, + "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": [ - 6 + 16 ], - "starting_column": 9, - "ending_column": 29 + "starting_column": 13, + "ending_column": 41 }, "type_specific_fields": { "parent": { "type": "function", - "name": "bad1", + "name": "bad4", "source_mapping": { - "start": 102, - "length": 85, + "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": [ - 5, - 6, - 7 + 14, + 15, + 16, + 17, + 18 ], "starting_column": 5, "ending_column": 6 @@ -627,7 +669,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 916, + "length": 1098, "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", @@ -664,22 +706,28 @@ 30, 31, 32, - 33 + 33, + 34, + 35, + 36, + 37, + 38, + 39 ], "starting_column": 1, "ending_column": 2 } }, - "signature": "bad1(uint256)" + "signature": "bad4()" } } } } ], - "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 STATICALL.\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 STATICALL.\n", - "first_markdown_element": "tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol#L5-L7", - "id": "aa84305fa524be189a9e050c79cea81a7bc258614c7563e22738e17a3559615a", + "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" From bd673dd6f350947bc0c34fed90ac01058a2d8d55 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Wed, 14 Dec 2022 12:21:11 -0600 Subject: [PATCH 6/6] make test function view --- .../0.5.16/var_read_using_this.sol | 2 +- ...d_using_this.sol.0.5.16.VarReadUsingThis.json | 16 ++++++++-------- .../0.6.11/var_read_using_this.sol | 2 +- ...d_using_this.sol.0.6.11.VarReadUsingThis.json | 16 ++++++++-------- .../0.7.6/var_read_using_this.sol | 2 +- ...ad_using_this.sol.0.7.6.VarReadUsingThis.json | 16 ++++++++-------- .../0.8.15/var_read_using_this.sol | 2 +- ...d_using_this.sol.0.8.15.VarReadUsingThis.json | 16 ++++++++-------- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol index 2382bf91a0..99cad0739c 100644 --- a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol +++ b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol @@ -30,7 +30,7 @@ contract VarReadUsingThis { address local = erc20; } } - function mapExternal(uint x) external returns(address) { + function mapExternal(uint x) external view returns(address) { return myMap[x]; } function good5(uint x) external returns(address) { diff --git a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json index 4b9a593140..15a0e08b57 100644 --- a/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.5.16/var_read_using_this.sol.0.5.16.VarReadUsingThis.json @@ -26,7 +26,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1102, + "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", @@ -119,7 +119,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1102, + "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", @@ -208,7 +208,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1102, + "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", @@ -301,7 +301,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1102, + "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", @@ -390,7 +390,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1102, + "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", @@ -483,7 +483,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1102, + "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", @@ -574,7 +574,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1102, + "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", @@ -669,7 +669,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1102, + "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", diff --git a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol index e252aa8484..6818007f6e 100644 --- a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol +++ b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol @@ -30,7 +30,7 @@ contract VarReadUsingThis { address local = erc20; } } - function mapExternal(uint x) external returns(address) { + function mapExternal(uint x) external view returns(address) { return myMap[x]; } function good5(uint x) external returns(address) { diff --git a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json index 7961802318..61143523e4 100644 --- a/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.6.11/var_read_using_this.sol.0.6.11.VarReadUsingThis.json @@ -26,7 +26,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -119,7 +119,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -210,7 +210,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -305,7 +305,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -394,7 +394,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -487,7 +487,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -576,7 +576,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -669,7 +669,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", diff --git a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol index e252aa8484..6818007f6e 100644 --- a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol +++ b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol @@ -30,7 +30,7 @@ contract VarReadUsingThis { address local = erc20; } } - function mapExternal(uint x) external returns(address) { + function mapExternal(uint x) external view returns(address) { return myMap[x]; } function good5(uint x) external returns(address) { diff --git a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json index 512ca9fb7e..555d6b7d57 100644 --- a/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.7.6/var_read_using_this.sol.0.7.6.VarReadUsingThis.json @@ -26,7 +26,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -119,7 +119,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -208,7 +208,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -301,7 +301,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -390,7 +390,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -483,7 +483,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -574,7 +574,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -669,7 +669,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", diff --git a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol index e252aa8484..6818007f6e 100644 --- a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol +++ b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol @@ -30,7 +30,7 @@ contract VarReadUsingThis { address local = erc20; } } - function mapExternal(uint x) external returns(address) { + function mapExternal(uint x) external view returns(address) { return myMap[x]; } function good5(uint x) external returns(address) { diff --git a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json index 8872bf2fae..143d43a6fd 100644 --- a/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json +++ b/tests/detectors/var-read-using-this/0.8.15/var_read_using_this.sol.0.8.15.VarReadUsingThis.json @@ -26,7 +26,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -119,7 +119,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -208,7 +208,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -301,7 +301,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -390,7 +390,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -483,7 +483,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -574,7 +574,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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", @@ -669,7 +669,7 @@ "name": "VarReadUsingThis", "source_mapping": { "start": 1, - "length": 1098, + "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",