From c7e83339eb577d5a87fe32d846c8b4da02ecf8bf Mon Sep 17 00:00:00 2001 From: Gustavo Grieco <31542053+ggrieco-tob@users.noreply.github.com> Date: Mon, 30 Nov 2020 14:58:52 -0300 Subject: [PATCH 01/12] Allow totalSupply() to be an external method in the ERC20 properties --- .../properties/properties/ercs/erc20/properties/transfer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slither/tools/properties/properties/ercs/erc20/properties/transfer.py b/slither/tools/properties/properties/ercs/erc20/properties/transfer.py index bea208f022..d5cdd45611 100644 --- a/slither/tools/properties/properties/ercs/erc20/properties/transfer.py +++ b/slither/tools/properties/properties/ercs/erc20/properties/transfer.py @@ -37,7 +37,7 @@ name="crytic_less_than_total_ERC20Properties()", description="Balance of one user must be less or equal to the total supply.", content=""" -\t\treturn this.balanceOf(msg.sender) <= totalSupply();""", +\t\treturn this.balanceOf(msg.sender) <= this.totalSupply();""", type=PropertyType.MEDIUM_SEVERITY, return_type=PropertyReturn.SUCCESS, is_unit_test=True, @@ -48,7 +48,7 @@ name="crytic_totalSupply_consistant_ERC20Properties()", description="Balance of the crytic users must be less or equal to the total supply.", content=""" -\t\treturn this.balanceOf(crytic_owner) + this.balanceOf(crytic_user) + this.balanceOf(crytic_attacker) <= totalSupply();""", +\t\treturn this.balanceOf(crytic_owner) + this.balanceOf(crytic_user) + this.balanceOf(crytic_attacker) <= this.totalSupply();""", type=PropertyType.MEDIUM_SEVERITY, return_type=PropertyReturn.SUCCESS, is_unit_test=True, From ab5f2425054af4b68cf8a39c4c9f94a25a5791b2 Mon Sep 17 00:00:00 2001 From: Natalie Chin Date: Mon, 30 Nov 2020 16:31:51 -0500 Subject: [PATCH 02/12] Added boolean equality tests --- .../statements/boolean_constant_equality.py | 21 +++++++-------- .../boolean-equality/boolean-equality.sol | 27 +++++++++++++++++++ tests/test_detectors.py | 2 ++ 3 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 tests/detectors/boolean-equality/boolean-equality.sol diff --git a/slither/detectors/statements/boolean_constant_equality.py b/slither/detectors/statements/boolean_constant_equality.py index a8d5e6e0a8..8d5ea290e5 100644 --- a/slither/detectors/statements/boolean_constant_equality.py +++ b/slither/detectors/statements/boolean_constant_equality.py @@ -72,17 +72,16 @@ def _detect(self): results = [] for contract in self.contracts: boolean_constant_misuses = self._detect_boolean_equality(contract) - if boolean_constant_misuses: - for (func, nodes) in boolean_constant_misuses: - for node in nodes: - info = [ - func, - " compares to a boolean constant:\n\t-", - node, - "\n", - ] + for (func, nodes) in boolean_constant_misuses: + for node in nodes: + info = [ + func, + " compares to a boolean constant:\n\t-", + node, + "\n", + ] - res = self.generate_result(info) - results.append(res) + res = self.generate_result(info) + results.append(res) return results diff --git a/tests/detectors/boolean-equality/boolean-equality.sol b/tests/detectors/boolean-equality/boolean-equality.sol new file mode 100644 index 0000000000..edd70b7827 --- /dev/null +++ b/tests/detectors/boolean-equality/boolean-equality.sol @@ -0,0 +1,27 @@ +contract MyConc { + function bad0() public pure returns (bool) { + if (false) { + return true; + } + } + + function bad1(bool b) public pure returns (bool) { + return (b || true); + } + + function bad2(bool x, uint8 y) public pure returns (bool) { + if (x == (y > 0)) { + return true; + } + } + + function bad3() public pure returns (bool) { + uint256 a; + if (a == 10) { + return true; + } + } + function good(uint8 a) public pure returns (bool) { + return a >= 1; + } +} diff --git a/tests/test_detectors.py b/tests/test_detectors.py index bc1780c3f5..03b1fc2920 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -37,6 +37,7 @@ from slither.detectors.shadowing.state import StateShadowing from slither.detectors.source.rtlo import RightToLeftOverride from slither.detectors.statements.assembly import Assembly +from slither.detectors.statements.boolean_constant_equality import BooleanEquality from slither.detectors.statements.calls_in_loop import MultipleCallsInLoop from slither.detectors.statements.controlled_delegatecall import ControlledDelegateCall from slither.detectors.statements.incorrect_strict_equality import IncorrectStrictEquality @@ -91,6 +92,7 @@ def id_test(test_item: Test): ALL_TESTS = [ + Test(BooleanEquality, "tests/detectors/boolean-equality/boolean-equality.sol", "0.5.1"), Test(UncheckedLowLevel, "tests/detectors/unchecked-lowlevel/unchecked_lowlevel.sol", "0.4.25"), Test( UncheckedLowLevel, From 6c2427a9f14d72f91d1cc56e3eaf36bb73b5d5af Mon Sep 17 00:00:00 2001 From: Natalie Chin Date: Fri, 4 Dec 2020 10:01:14 -0500 Subject: [PATCH 03/12] Renamed test file and added json artifact --- .../statements/boolean_constant_equality.py | 2 +- .../boolean-constant-equality.sol} | 12 +- ...t-equality.sol.0.4.25.BooleanEquality.json | 170 ++++++++++++++++++ tests/test_detectors.py | 2 +- 4 files changed, 178 insertions(+), 8 deletions(-) rename tests/detectors/{boolean-equality/boolean-equality.sol => boolean-constant-equality/boolean-constant-equality.sol} (72%) create mode 100644 tests/detectors/boolean-constant-equality/boolean-constant-equality.sol.0.4.25.BooleanEquality.json diff --git a/slither/detectors/statements/boolean_constant_equality.py b/slither/detectors/statements/boolean_constant_equality.py index 8d5ea290e5..8ae4669d75 100644 --- a/slither/detectors/statements/boolean_constant_equality.py +++ b/slither/detectors/statements/boolean_constant_equality.py @@ -12,7 +12,7 @@ class BooleanEquality(AbstractDetector): """ - Boolean constant misuse + Boolean constant equality """ ARGUMENT = "boolean-equal" diff --git a/tests/detectors/boolean-equality/boolean-equality.sol b/tests/detectors/boolean-constant-equality/boolean-constant-equality.sol similarity index 72% rename from tests/detectors/boolean-equality/boolean-equality.sol rename to tests/detectors/boolean-constant-equality/boolean-constant-equality.sol index edd70b7827..799f433357 100644 --- a/tests/detectors/boolean-equality/boolean-equality.sol +++ b/tests/detectors/boolean-constant-equality/boolean-constant-equality.sol @@ -1,12 +1,11 @@ contract MyConc { - function bad0() public pure returns (bool) { - if (false) { + function bad0(bool foo) public pure returns (bool) { + if (foo) { return true; } } - function bad1(bool b) public pure returns (bool) { - return (b || true); + return (b == true); } function bad2(bool x, uint8 y) public pure returns (bool) { @@ -21,7 +20,8 @@ contract MyConc { return true; } } - function good(uint8 a) public pure returns (bool) { + + function good(uint8 a) public pure returns (bool) { return a >= 1; } -} +} \ No newline at end of file diff --git a/tests/detectors/boolean-constant-equality/boolean-constant-equality.sol.0.4.25.BooleanEquality.json b/tests/detectors/boolean-constant-equality/boolean-constant-equality.sol.0.4.25.BooleanEquality.json new file mode 100644 index 0000000000..72c1bcbbe2 --- /dev/null +++ b/tests/detectors/boolean-constant-equality/boolean-constant-equality.sol.0.4.25.BooleanEquality.json @@ -0,0 +1,170 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 139, + "length": 84, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "is_dependency": false, + "lines": [ + 7, + 8, + 9 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 578, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "bad1(bool)" + } + }, + { + "type": "node", + "name": "(b == true)", + "source_mapping": { + "start": 198, + "length": 18, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "is_dependency": false, + "lines": [ + 8 + ], + "starting_column": 9, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 139, + "length": 84, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "is_dependency": false, + "lines": [ + 7, + 8, + 9 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 578, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "bad1(bool)" + } + } + } + } + ], + "description": "MyConc.bad1(bool) (tests/detectors/boolean-constant-equality/boolean-constant-equality.sol#7-9) compares to a boolean constant:\n\t-(b == true) (tests/detectors/boolean-constant-equality/boolean-constant-equality.sol#8)\n", + "markdown": "[MyConc.bad1(bool)](tests/detectors/boolean-constant-equality/boolean-constant-equality.sol#L7-L9) compares to a boolean constant:\n\t-[(b == true)](tests/detectors/boolean-constant-equality/boolean-constant-equality.sol#L8)\n", + "id": "4a53e773c88b730f07c2e4106545df03b44679c56ee0d9dbd75dca010320e69c", + "check": "boolean-equal", + "impact": "Informational", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/test_detectors.py b/tests/test_detectors.py index 03b1fc2920..7bbbcdfe18 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -92,7 +92,7 @@ def id_test(test_item: Test): ALL_TESTS = [ - Test(BooleanEquality, "tests/detectors/boolean-equality/boolean-equality.sol", "0.5.1"), + Test(BooleanEquality, "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", "0.4.25"), Test(UncheckedLowLevel, "tests/detectors/unchecked-lowlevel/unchecked_lowlevel.sol", "0.4.25"), Test( UncheckedLowLevel, From 91cb3db4453a4a1cc927589c3f6a834fa62ebbd3 Mon Sep 17 00:00:00 2001 From: Natalie Chin Date: Fri, 4 Dec 2020 10:38:08 -0500 Subject: [PATCH 04/12] Fixed linter formatting for test_detectors --- tests/test_detectors.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_detectors.py b/tests/test_detectors.py index 7bbbcdfe18..5173947912 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -92,7 +92,11 @@ def id_test(test_item: Test): ALL_TESTS = [ - Test(BooleanEquality, "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", "0.4.25"), + Test( + BooleanEquality, + "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", + "0.4.25", + ), Test(UncheckedLowLevel, "tests/detectors/unchecked-lowlevel/unchecked_lowlevel.sol", "0.4.25"), Test( UncheckedLowLevel, From 99176f9f882dd4dc1c452db0aab9f0372c6a1eb4 Mon Sep 17 00:00:00 2001 From: Natalie Chin Date: Fri, 4 Dec 2020 11:19:02 -0500 Subject: [PATCH 05/12] Removed trailing whitespace for super linter --- slither/detectors/statements/boolean_constant_equality.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/detectors/statements/boolean_constant_equality.py b/slither/detectors/statements/boolean_constant_equality.py index 8ae4669d75..17df74e988 100644 --- a/slither/detectors/statements/boolean_constant_equality.py +++ b/slither/detectors/statements/boolean_constant_equality.py @@ -12,7 +12,7 @@ class BooleanEquality(AbstractDetector): """ - Boolean constant equality + Boolean constant equality """ ARGUMENT = "boolean-equal" From 84c30e821330a1cd91cbbd97f7d029fdcb922bbf Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 4 Dec 2020 17:36:24 +0100 Subject: [PATCH 06/12] Improve support for legacy ast --- slither/solc_parsing/declarations/event.py | 16 +++++++++------- slither/solc_parsing/declarations/function.py | 10 ++++++++-- slither/solc_parsing/declarations/modifier.py | 14 ++++++++++---- tests/ast-parsing/comment-all.sol | 7 +++++++ .../expected/comment-0.4.0-legacy.json | 5 +++++ .../expected/comment-0.4.1-legacy.json | 5 +++++ .../expected/comment-0.4.10-legacy.json | 5 +++++ .../expected/comment-0.4.11-legacy.json | 5 +++++ .../expected/comment-0.4.12-compact.json | 5 +++++ .../expected/comment-0.4.12-legacy.json | 5 +++++ .../expected/comment-0.4.13-compact.json | 5 +++++ .../expected/comment-0.4.13-legacy.json | 5 +++++ .../expected/comment-0.4.14-compact.json | 5 +++++ .../expected/comment-0.4.14-legacy.json | 5 +++++ .../expected/comment-0.4.15-compact.json | 5 +++++ .../expected/comment-0.4.15-legacy.json | 5 +++++ .../expected/comment-0.4.16-compact.json | 5 +++++ .../expected/comment-0.4.16-legacy.json | 5 +++++ .../expected/comment-0.4.17-compact.json | 5 +++++ .../expected/comment-0.4.17-legacy.json | 5 +++++ .../expected/comment-0.4.18-compact.json | 5 +++++ .../expected/comment-0.4.18-legacy.json | 5 +++++ .../expected/comment-0.4.19-compact.json | 5 +++++ .../expected/comment-0.4.19-legacy.json | 5 +++++ .../expected/comment-0.4.2-legacy.json | 5 +++++ .../expected/comment-0.4.20-compact.json | 5 +++++ .../expected/comment-0.4.20-legacy.json | 5 +++++ .../expected/comment-0.4.21-compact.json | 5 +++++ .../expected/comment-0.4.21-legacy.json | 5 +++++ .../expected/comment-0.4.22-compact.json | 5 +++++ .../expected/comment-0.4.22-legacy.json | 5 +++++ .../expected/comment-0.4.23-compact.json | 5 +++++ .../expected/comment-0.4.23-legacy.json | 5 +++++ .../expected/comment-0.4.24-compact.json | 5 +++++ .../expected/comment-0.4.24-legacy.json | 5 +++++ .../expected/comment-0.4.25-compact.json | 5 +++++ .../expected/comment-0.4.25-legacy.json | 5 +++++ .../expected/comment-0.4.26-compact.json | 5 +++++ .../expected/comment-0.4.26-legacy.json | 5 +++++ .../expected/comment-0.4.3-legacy.json | 5 +++++ .../expected/comment-0.4.4-legacy.json | 5 +++++ .../expected/comment-0.4.5-legacy.json | 5 +++++ .../expected/comment-0.4.6-legacy.json | 5 +++++ .../expected/comment-0.4.7-legacy.json | 5 +++++ .../expected/comment-0.4.8-legacy.json | 5 +++++ .../expected/comment-0.4.9-legacy.json | 5 +++++ .../expected/comment-0.5.0-compact.json | 5 +++++ .../expected/comment-0.5.0-legacy.json | 5 +++++ .../expected/comment-0.5.1-compact.json | 5 +++++ .../expected/comment-0.5.1-legacy.json | 5 +++++ .../expected/comment-0.5.10-compact.json | 5 +++++ .../expected/comment-0.5.10-legacy.json | 5 +++++ .../expected/comment-0.5.11-compact.json | 5 +++++ .../expected/comment-0.5.11-legacy.json | 5 +++++ .../expected/comment-0.5.12-compact.json | 5 +++++ .../expected/comment-0.5.12-legacy.json | 5 +++++ .../expected/comment-0.5.13-compact.json | 5 +++++ .../expected/comment-0.5.13-legacy.json | 5 +++++ .../expected/comment-0.5.14-compact.json | 5 +++++ .../expected/comment-0.5.14-legacy.json | 5 +++++ .../expected/comment-0.5.15-compact.json | 5 +++++ .../expected/comment-0.5.15-legacy.json | 5 +++++ .../expected/comment-0.5.16-compact.json | 5 +++++ .../expected/comment-0.5.16-legacy.json | 5 +++++ .../expected/comment-0.5.17-compact.json | 5 +++++ .../expected/comment-0.5.17-legacy.json | 5 +++++ .../expected/comment-0.5.2-compact.json | 5 +++++ .../expected/comment-0.5.2-legacy.json | 5 +++++ .../expected/comment-0.5.3-compact.json | 5 +++++ .../expected/comment-0.5.3-legacy.json | 5 +++++ .../expected/comment-0.5.4-compact.json | 5 +++++ .../expected/comment-0.5.4-legacy.json | 5 +++++ .../expected/comment-0.5.5-compact.json | 5 +++++ .../expected/comment-0.5.5-legacy.json | 5 +++++ .../expected/comment-0.5.6-compact.json | 5 +++++ .../expected/comment-0.5.6-legacy.json | 5 +++++ .../expected/comment-0.5.7-compact.json | 5 +++++ .../expected/comment-0.5.7-legacy.json | 5 +++++ .../expected/comment-0.5.8-compact.json | 5 +++++ .../expected/comment-0.5.8-legacy.json | 5 +++++ .../expected/comment-0.5.9-compact.json | 5 +++++ .../expected/comment-0.5.9-legacy.json | 5 +++++ .../expected/comment-0.6.0-compact.json | 5 +++++ .../expected/comment-0.6.0-legacy.json | 5 +++++ .../expected/comment-0.6.1-compact.json | 5 +++++ .../expected/comment-0.6.1-legacy.json | 5 +++++ .../expected/comment-0.6.10-compact.json | 5 +++++ .../expected/comment-0.6.10-legacy.json | 5 +++++ .../expected/comment-0.6.11-compact.json | 5 +++++ .../expected/comment-0.6.11-legacy.json | 5 +++++ .../expected/comment-0.6.12-compact.json | 5 +++++ .../expected/comment-0.6.12-legacy.json | 5 +++++ .../expected/comment-0.6.2-compact.json | 5 +++++ .../expected/comment-0.6.2-legacy.json | 5 +++++ .../expected/comment-0.6.3-compact.json | 5 +++++ .../expected/comment-0.6.3-legacy.json | 5 +++++ .../expected/comment-0.6.4-compact.json | 5 +++++ .../expected/comment-0.6.4-legacy.json | 5 +++++ .../expected/comment-0.6.5-compact.json | 5 +++++ .../expected/comment-0.6.5-legacy.json | 5 +++++ .../expected/comment-0.6.6-compact.json | 5 +++++ .../expected/comment-0.6.6-legacy.json | 5 +++++ .../expected/comment-0.6.7-compact.json | 5 +++++ .../expected/comment-0.6.7-legacy.json | 5 +++++ .../expected/comment-0.6.8-compact.json | 5 +++++ .../expected/comment-0.6.8-legacy.json | 5 +++++ .../expected/comment-0.6.9-compact.json | 5 +++++ .../expected/comment-0.6.9-legacy.json | 5 +++++ .../expected/comment-0.7.0-compact.json | 5 +++++ .../expected/comment-0.7.0-legacy.json | 5 +++++ .../expected/comment-0.7.1-compact.json | 5 +++++ .../expected/comment-0.7.1-legacy.json | 5 +++++ .../expected/comment-0.7.2-compact.json | 5 +++++ .../expected/comment-0.7.2-legacy.json | 5 +++++ .../expected/comment-0.7.3-compact.json | 5 +++++ .../expected/comment-0.7.3-legacy.json | 5 +++++ .../expected/comment-0.7.4-compact.json | 5 +++++ .../expected/comment-0.7.4-legacy.json | 5 +++++ 118 files changed, 604 insertions(+), 13 deletions(-) create mode 100644 tests/ast-parsing/comment-all.sol create mode 100644 tests/ast-parsing/expected/comment-0.4.0-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.1-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.10-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.11-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.12-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.12-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.13-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.13-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.14-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.14-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.15-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.15-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.16-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.16-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.17-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.17-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.18-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.18-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.19-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.19-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.2-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.20-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.20-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.21-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.21-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.22-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.22-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.23-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.23-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.24-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.24-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.25-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.25-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.26-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.4.26-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.3-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.4-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.5-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.6-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.7-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.8-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.4.9-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.0-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.0-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.1-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.1-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.10-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.10-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.11-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.11-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.12-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.12-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.13-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.13-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.14-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.14-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.15-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.15-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.16-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.16-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.17-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.17-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.2-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.2-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.3-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.3-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.4-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.4-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.5-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.5-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.6-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.6-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.7-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.7-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.8-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.8-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.5.9-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.5.9-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.0-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.0-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.1-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.1-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.10-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.10-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.11-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.11-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.12-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.12-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.2-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.2-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.3-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.3-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.4-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.4-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.5-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.5-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.6-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.6-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.7-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.7-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.8-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.8-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.6.9-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.6.9-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.7.0-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.7.0-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.7.1-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.7.1-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.7.2-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.7.2-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.7.3-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.7.3-legacy.json create mode 100644 tests/ast-parsing/expected/comment-0.7.4-compact.json create mode 100644 tests/ast-parsing/expected/comment-0.7.4-legacy.json diff --git a/slither/solc_parsing/declarations/event.py b/slither/solc_parsing/declarations/event.py index f480e3974f..29fee7b4ab 100644 --- a/slither/solc_parsing/declarations/event.py +++ b/slither/solc_parsing/declarations/event.py @@ -29,13 +29,15 @@ def __init__(self, event: Event, event_data: Dict, contract_parser: "ContractSol self._elemsNotParsed = elems["parameters"] else: self._event.name = event_data["attributes"]["name"] - elems = event_data["children"][0] - - assert elems["name"] == "ParameterList" - if "children" in elems: - self._elemsNotParsed = elems["children"] - else: - self._elemsNotParsed = [] + for elem in event_data["children"]: + # From Solidity 0.6.3 to 0.6.10 (included) + # Comment above a event might be added in the children + # of an event for the legacy ast + if elem["name"] == "ParameterList": + if "children" in elem: + self._elemsNotParsed = elem["children"] + else: + self._elemsNotParsed = [] @property def is_compact_ast(self) -> bool: diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 5a8cde5324..fe5fa89821 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -258,8 +258,14 @@ def analyze_params(self): returns = self._functionNotParsed["returnParameters"] else: children = self._functionNotParsed[self.get_children("children")] - params = children[0] - returns = children[1] + # It uses to be + # params = children[0] + # returns = children[1] + # But from Solidity 0.6.3 to 0.6.10 (included) + # Comment above a function might be added in the children + child_iter = iter([child for child in children if child[self.get_key()] == "ParameterList"]) + params = next(child_iter) + returns = next(child_iter) if params: self._parse_params(params) diff --git a/slither/solc_parsing/declarations/modifier.py b/slither/solc_parsing/declarations/modifier.py index 1bd5d17411..158cc82638 100644 --- a/slither/solc_parsing/declarations/modifier.py +++ b/slither/solc_parsing/declarations/modifier.py @@ -37,7 +37,11 @@ def analyze_params(self): params = self._functionNotParsed["parameters"] else: children = self._functionNotParsed["children"] - params = children[0] + # It uses to be + # params = children[0] + # But from Solidity 0.6.3 to 0.6.10 (included) + # Comment above a function might be added in the children + params = next(child for child in children if child[self.get_key()] == "ParameterList") if params: self._parse_params(params) @@ -60,9 +64,11 @@ def analyze_content(self): self._function.is_implemented = False if len(children) > 1: - assert len(children) == 2 - block = children[1] - assert block["name"] == "Block" + # It uses to be + # params = children[1] + # But from Solidity 0.6.3 to 0.6.10 (included) + # Comment above a function might be added in the children + block = next(child for child in children if child[self.get_key()] == "Block") self._function.is_implemented = True self._parse_cfg(block) diff --git a/tests/ast-parsing/comment-all.sol b/tests/ast-parsing/comment-all.sol new file mode 100644 index 0000000000..3a1ebfb5c3 --- /dev/null +++ b/tests/ast-parsing/comment-all.sol @@ -0,0 +1,7 @@ +contract A{ + /*** Events ***/ + event E(); + + /*** Function ***/ + function f() public{} +} diff --git a/tests/ast-parsing/expected/comment-0.4.0-legacy.json b/tests/ast-parsing/expected/comment-0.4.0-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.0-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.1-legacy.json b/tests/ast-parsing/expected/comment-0.4.1-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.1-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.10-legacy.json b/tests/ast-parsing/expected/comment-0.4.10-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.10-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.11-legacy.json b/tests/ast-parsing/expected/comment-0.4.11-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.11-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.12-compact.json b/tests/ast-parsing/expected/comment-0.4.12-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.12-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.12-legacy.json b/tests/ast-parsing/expected/comment-0.4.12-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.12-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.13-compact.json b/tests/ast-parsing/expected/comment-0.4.13-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.13-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.13-legacy.json b/tests/ast-parsing/expected/comment-0.4.13-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.13-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.14-compact.json b/tests/ast-parsing/expected/comment-0.4.14-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.14-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.14-legacy.json b/tests/ast-parsing/expected/comment-0.4.14-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.14-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.15-compact.json b/tests/ast-parsing/expected/comment-0.4.15-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.15-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.15-legacy.json b/tests/ast-parsing/expected/comment-0.4.15-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.15-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.16-compact.json b/tests/ast-parsing/expected/comment-0.4.16-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.16-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.16-legacy.json b/tests/ast-parsing/expected/comment-0.4.16-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.16-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.17-compact.json b/tests/ast-parsing/expected/comment-0.4.17-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.17-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.17-legacy.json b/tests/ast-parsing/expected/comment-0.4.17-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.17-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.18-compact.json b/tests/ast-parsing/expected/comment-0.4.18-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.18-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.18-legacy.json b/tests/ast-parsing/expected/comment-0.4.18-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.18-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.19-compact.json b/tests/ast-parsing/expected/comment-0.4.19-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.19-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.19-legacy.json b/tests/ast-parsing/expected/comment-0.4.19-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.19-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.2-legacy.json b/tests/ast-parsing/expected/comment-0.4.2-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.2-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.20-compact.json b/tests/ast-parsing/expected/comment-0.4.20-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.20-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.20-legacy.json b/tests/ast-parsing/expected/comment-0.4.20-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.20-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.21-compact.json b/tests/ast-parsing/expected/comment-0.4.21-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.21-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.21-legacy.json b/tests/ast-parsing/expected/comment-0.4.21-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.21-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.22-compact.json b/tests/ast-parsing/expected/comment-0.4.22-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.22-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.22-legacy.json b/tests/ast-parsing/expected/comment-0.4.22-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.22-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.23-compact.json b/tests/ast-parsing/expected/comment-0.4.23-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.23-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.23-legacy.json b/tests/ast-parsing/expected/comment-0.4.23-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.23-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.24-compact.json b/tests/ast-parsing/expected/comment-0.4.24-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.24-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.24-legacy.json b/tests/ast-parsing/expected/comment-0.4.24-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.24-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.25-compact.json b/tests/ast-parsing/expected/comment-0.4.25-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.25-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.25-legacy.json b/tests/ast-parsing/expected/comment-0.4.25-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.25-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.26-compact.json b/tests/ast-parsing/expected/comment-0.4.26-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.26-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.26-legacy.json b/tests/ast-parsing/expected/comment-0.4.26-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.26-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.3-legacy.json b/tests/ast-parsing/expected/comment-0.4.3-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.3-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.4-legacy.json b/tests/ast-parsing/expected/comment-0.4.4-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.4-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.5-legacy.json b/tests/ast-parsing/expected/comment-0.4.5-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.5-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.6-legacy.json b/tests/ast-parsing/expected/comment-0.4.6-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.6-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.7-legacy.json b/tests/ast-parsing/expected/comment-0.4.7-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.7-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.8-legacy.json b/tests/ast-parsing/expected/comment-0.4.8-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.8-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.4.9-legacy.json b/tests/ast-parsing/expected/comment-0.4.9-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.4.9-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.0-compact.json b/tests/ast-parsing/expected/comment-0.5.0-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.0-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.0-legacy.json b/tests/ast-parsing/expected/comment-0.5.0-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.0-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.1-compact.json b/tests/ast-parsing/expected/comment-0.5.1-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.1-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.1-legacy.json b/tests/ast-parsing/expected/comment-0.5.1-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.1-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.10-compact.json b/tests/ast-parsing/expected/comment-0.5.10-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.10-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.10-legacy.json b/tests/ast-parsing/expected/comment-0.5.10-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.10-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.11-compact.json b/tests/ast-parsing/expected/comment-0.5.11-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.11-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.11-legacy.json b/tests/ast-parsing/expected/comment-0.5.11-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.11-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.12-compact.json b/tests/ast-parsing/expected/comment-0.5.12-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.12-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.12-legacy.json b/tests/ast-parsing/expected/comment-0.5.12-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.12-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.13-compact.json b/tests/ast-parsing/expected/comment-0.5.13-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.13-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.13-legacy.json b/tests/ast-parsing/expected/comment-0.5.13-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.13-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.14-compact.json b/tests/ast-parsing/expected/comment-0.5.14-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.14-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.14-legacy.json b/tests/ast-parsing/expected/comment-0.5.14-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.14-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.15-compact.json b/tests/ast-parsing/expected/comment-0.5.15-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.15-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.15-legacy.json b/tests/ast-parsing/expected/comment-0.5.15-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.15-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.16-compact.json b/tests/ast-parsing/expected/comment-0.5.16-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.16-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.16-legacy.json b/tests/ast-parsing/expected/comment-0.5.16-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.16-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.17-compact.json b/tests/ast-parsing/expected/comment-0.5.17-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.17-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.17-legacy.json b/tests/ast-parsing/expected/comment-0.5.17-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.17-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.2-compact.json b/tests/ast-parsing/expected/comment-0.5.2-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.2-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.2-legacy.json b/tests/ast-parsing/expected/comment-0.5.2-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.2-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.3-compact.json b/tests/ast-parsing/expected/comment-0.5.3-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.3-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.3-legacy.json b/tests/ast-parsing/expected/comment-0.5.3-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.3-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.4-compact.json b/tests/ast-parsing/expected/comment-0.5.4-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.4-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.4-legacy.json b/tests/ast-parsing/expected/comment-0.5.4-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.4-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.5-compact.json b/tests/ast-parsing/expected/comment-0.5.5-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.5-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.5-legacy.json b/tests/ast-parsing/expected/comment-0.5.5-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.5-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.6-compact.json b/tests/ast-parsing/expected/comment-0.5.6-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.6-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.6-legacy.json b/tests/ast-parsing/expected/comment-0.5.6-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.6-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.7-compact.json b/tests/ast-parsing/expected/comment-0.5.7-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.7-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.7-legacy.json b/tests/ast-parsing/expected/comment-0.5.7-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.7-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.8-compact.json b/tests/ast-parsing/expected/comment-0.5.8-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.8-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.8-legacy.json b/tests/ast-parsing/expected/comment-0.5.8-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.8-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.9-compact.json b/tests/ast-parsing/expected/comment-0.5.9-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.9-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.5.9-legacy.json b/tests/ast-parsing/expected/comment-0.5.9-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.5.9-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.0-compact.json b/tests/ast-parsing/expected/comment-0.6.0-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.0-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.0-legacy.json b/tests/ast-parsing/expected/comment-0.6.0-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.0-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.1-compact.json b/tests/ast-parsing/expected/comment-0.6.1-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.1-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.1-legacy.json b/tests/ast-parsing/expected/comment-0.6.1-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.1-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.10-compact.json b/tests/ast-parsing/expected/comment-0.6.10-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.10-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.10-legacy.json b/tests/ast-parsing/expected/comment-0.6.10-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.10-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.11-compact.json b/tests/ast-parsing/expected/comment-0.6.11-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.11-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.11-legacy.json b/tests/ast-parsing/expected/comment-0.6.11-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.11-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.12-compact.json b/tests/ast-parsing/expected/comment-0.6.12-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.12-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.12-legacy.json b/tests/ast-parsing/expected/comment-0.6.12-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.12-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.2-compact.json b/tests/ast-parsing/expected/comment-0.6.2-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.2-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.2-legacy.json b/tests/ast-parsing/expected/comment-0.6.2-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.2-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.3-compact.json b/tests/ast-parsing/expected/comment-0.6.3-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.3-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.3-legacy.json b/tests/ast-parsing/expected/comment-0.6.3-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.3-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.4-compact.json b/tests/ast-parsing/expected/comment-0.6.4-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.4-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.4-legacy.json b/tests/ast-parsing/expected/comment-0.6.4-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.4-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.5-compact.json b/tests/ast-parsing/expected/comment-0.6.5-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.5-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.5-legacy.json b/tests/ast-parsing/expected/comment-0.6.5-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.5-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.6-compact.json b/tests/ast-parsing/expected/comment-0.6.6-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.6-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.6-legacy.json b/tests/ast-parsing/expected/comment-0.6.6-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.6-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.7-compact.json b/tests/ast-parsing/expected/comment-0.6.7-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.7-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.7-legacy.json b/tests/ast-parsing/expected/comment-0.6.7-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.7-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.8-compact.json b/tests/ast-parsing/expected/comment-0.6.8-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.8-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.8-legacy.json b/tests/ast-parsing/expected/comment-0.6.8-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.8-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.9-compact.json b/tests/ast-parsing/expected/comment-0.6.9-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.9-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.6.9-legacy.json b/tests/ast-parsing/expected/comment-0.6.9-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.6.9-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.0-compact.json b/tests/ast-parsing/expected/comment-0.7.0-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.0-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.0-legacy.json b/tests/ast-parsing/expected/comment-0.7.0-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.0-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.1-compact.json b/tests/ast-parsing/expected/comment-0.7.1-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.1-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.1-legacy.json b/tests/ast-parsing/expected/comment-0.7.1-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.1-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.2-compact.json b/tests/ast-parsing/expected/comment-0.7.2-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.2-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.2-legacy.json b/tests/ast-parsing/expected/comment-0.7.2-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.2-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.3-compact.json b/tests/ast-parsing/expected/comment-0.7.3-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.3-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.3-legacy.json b/tests/ast-parsing/expected/comment-0.7.3-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.3-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.4-compact.json b/tests/ast-parsing/expected/comment-0.7.4-compact.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.4-compact.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file diff --git a/tests/ast-parsing/expected/comment-0.7.4-legacy.json b/tests/ast-parsing/expected/comment-0.7.4-legacy.json new file mode 100644 index 0000000000..a53745acd0 --- /dev/null +++ b/tests/ast-parsing/expected/comment-0.7.4-legacy.json @@ -0,0 +1,5 @@ +{ + "A": { + "f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n}\n" + } +} \ No newline at end of file From c3c580702e1f312fdc83e31e2da4f84f09fc9640 Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 4 Dec 2020 18:08:41 +0100 Subject: [PATCH 07/12] Run black --- slither/solc_parsing/declarations/function.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index fe5fa89821..ae772dfdd6 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -263,7 +263,9 @@ def analyze_params(self): # returns = children[1] # But from Solidity 0.6.3 to 0.6.10 (included) # Comment above a function might be added in the children - child_iter = iter([child for child in children if child[self.get_key()] == "ParameterList"]) + child_iter = iter( + [child for child in children if child[self.get_key()] == "ParameterList"] + ) params = next(child_iter) returns = next(child_iter) From 82fd8606ea736cb2d1191bce638ab5f7f261ed11 Mon Sep 17 00:00:00 2001 From: Natalie Chin Date: Fri, 4 Dec 2020 14:56:59 -0500 Subject: [PATCH 08/12] Added test and json artifact for boolean-constant-misuse --- .../statements/boolean_constant_misuse.py | 53 ++--- .../boolean-constant-misuse.sol | 46 ++++ ...isuse.sol.0.6.0.BooleanConstantMisuse.json | 208 ++++++++++++++++++ tests/test_detectors.py | 2 + 4 files changed, 280 insertions(+), 29 deletions(-) create mode 100644 tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol create mode 100644 tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol.0.6.0.BooleanConstantMisuse.json diff --git a/slither/detectors/statements/boolean_constant_misuse.py b/slither/detectors/statements/boolean_constant_misuse.py index 3b77ba02d5..4ab6fe8ffa 100644 --- a/slither/detectors/statements/boolean_constant_misuse.py +++ b/slither/detectors/statements/boolean_constant_misuse.py @@ -67,39 +67,35 @@ def _detect_boolean_constant_misuses(contract): # pylint: disable=too-many-bran results = [] # Loop for each function and modifier. - for function in contract.functions_declared: # pylint: disable=too-many-nested-blocks + for function in contract.functions_declared: f_results = set() # Loop for every node in this function, looking for boolean constants for node in function.nodes: # Do not report "while(true)" - if node.type == NodeType.IFLOOP: - if node.irs: - if len(node.irs) == 1: - ir = node.irs[0] - if isinstance(ir, Condition) and ir.value == Constant( - "True", ElementaryType("bool") - ): - continue + if node.type == NodeType.IFLOOP and node.irs and len(node.irs) == 1: + ir = node.irs[0] + if isinstance(ir, Condition) and ir.value == Constant( + "True", ElementaryType("bool") + ): + continue for ir in node.irs: if isinstance(ir, (Assignment, Call, Return, InitArray)): # It's ok to use a bare boolean constant in these contexts continue - if isinstance(ir, Binary): - if ir.type in [ + if isinstance(ir, Binary) and ir.type in [ BinaryType.ADDITION, BinaryType.EQUAL, BinaryType.NOT_EQUAL, ]: - # Comparing to a Boolean constant is dubious style, but harmless - # Equal is catch by another detector (informational severity) - continue + # Comparing to a Boolean constant is dubious style, but harmless + # Equal is catch by another detector (informational severity) + continue for r in ir.read: - if isinstance(r, Constant): - if isinstance(r.value, bool): - f_results.add(node) + if isinstance(r, Constant) and isinstance(r.value, bool): + f_results.add(node) results.append((function, f_results)) # Return the resulting set of nodes with improper uses of Boolean constants @@ -112,17 +108,16 @@ def _detect(self): results = [] for contract in self.contracts: boolean_constant_misuses = self._detect_boolean_constant_misuses(contract) - if boolean_constant_misuses: - for (func, nodes) in boolean_constant_misuses: - for node in nodes: - info = [ - func, - " uses a Boolean constant improperly:\n\t-", - node, - "\n", - ] - - res = self.generate_result(info) - results.append(res) + for (func, nodes) in boolean_constant_misuses: + for node in nodes: + info = [ + func, + " uses a Boolean constant improperly:\n\t-", + node, + "\n", + ] + + res = self.generate_result(info) + results.append(res) return results diff --git a/tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol b/tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol new file mode 100644 index 0000000000..6d3df44f32 --- /dev/null +++ b/tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol @@ -0,0 +1,46 @@ +contract MyConc { + function bad0(bool foo) public pure returns (bool) { + if (foo) { + return true; + } + return false; + } + + function bad1(bool b) public pure returns (bool) { + return (b || true); + } + + function bad2(bool x, uint8 y) public pure returns (bool) { + while (x == (y > 0)) { + return true; + } + return false; + } + + function bad3(bool a) public pure returns (bool) { + uint256 b = 0; + while (a) { + b++; + } + return true; + } + + function bad4() public pure returns (bool) { + uint256 b = 0; + while (true) { + b++; + } + return true; + } + + function bad5() public pure returns (bool) { + while (true) { + return true; + } + return false; + } + + function good() public pure returns (bool) { + return true; + } +} \ No newline at end of file diff --git a/tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol.0.6.0.BooleanConstantMisuse.json b/tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol.0.6.0.BooleanConstantMisuse.json new file mode 100644 index 0000000000..a4bf8607d3 --- /dev/null +++ b/tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol.0.6.0.BooleanConstantMisuse.json @@ -0,0 +1,208 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 162, + "length": 84, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 923, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "bad1(bool)" + } + }, + { + "type": "node", + "name": "(b || true)", + "source_mapping": { + "start": 221, + "length": 18, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "is_dependency": false, + "lines": [ + 10 + ], + "starting_column": 9, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 162, + "length": 84, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 923, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "bad1(bool)" + } + } + } + } + ], + "description": "MyConc.bad1(bool) (tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol#9-11) uses a Boolean constant improperly:\n\t-(b || true) (tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol#10)\n", + "markdown": "[MyConc.bad1(bool)](tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol#L9-L11) uses a Boolean constant improperly:\n\t-[(b || true)](tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol#L10)\n", + "id": "12517fed0ec8f0a2232b467a6add9fd94a6a84325017e02e8a48794fc9112c6b", + "check": "boolean-cst", + "impact": "Medium", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/test_detectors.py b/tests/test_detectors.py index 5173947912..04a6bb4051 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -37,6 +37,7 @@ from slither.detectors.shadowing.state import StateShadowing from slither.detectors.source.rtlo import RightToLeftOverride from slither.detectors.statements.assembly import Assembly +from slither.detectors.statements.boolean_constant_misuse import BooleanConstantMisuse from slither.detectors.statements.boolean_constant_equality import BooleanEquality from slither.detectors.statements.calls_in_loop import MultipleCallsInLoop from slither.detectors.statements.controlled_delegatecall import ControlledDelegateCall @@ -97,6 +98,7 @@ def id_test(test_item: Test): "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", "0.4.25", ), + Test(BooleanConstantMisuse, "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", "0.6.0"), Test(UncheckedLowLevel, "tests/detectors/unchecked-lowlevel/unchecked_lowlevel.sol", "0.4.25"), Test( UncheckedLowLevel, From fb1b43949103eecd8ab93d174c8b618192d6c5cb Mon Sep 17 00:00:00 2001 From: Natalie Chin Date: Fri, 4 Dec 2020 15:50:13 -0500 Subject: [PATCH 09/12] Fixed black --- slither/detectors/statements/boolean_constant_misuse.py | 8 ++++---- tests/test_detectors.py | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/slither/detectors/statements/boolean_constant_misuse.py b/slither/detectors/statements/boolean_constant_misuse.py index 4ab6fe8ffa..7bba5a3e63 100644 --- a/slither/detectors/statements/boolean_constant_misuse.py +++ b/slither/detectors/statements/boolean_constant_misuse.py @@ -86,10 +86,10 @@ def _detect_boolean_constant_misuses(contract): # pylint: disable=too-many-bran # It's ok to use a bare boolean constant in these contexts continue if isinstance(ir, Binary) and ir.type in [ - BinaryType.ADDITION, - BinaryType.EQUAL, - BinaryType.NOT_EQUAL, - ]: + BinaryType.ADDITION, + BinaryType.EQUAL, + BinaryType.NOT_EQUAL, + ]: # Comparing to a Boolean constant is dubious style, but harmless # Equal is catch by another detector (informational severity) continue diff --git a/tests/test_detectors.py b/tests/test_detectors.py index 04a6bb4051..33d72d015f 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -98,7 +98,11 @@ def id_test(test_item: Test): "tests/detectors/boolean-constant-equality/boolean-constant-equality.sol", "0.4.25", ), - Test(BooleanConstantMisuse, "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", "0.6.0"), + Test( + BooleanConstantMisuse, + "tests/detectors/boolean-constant-misuse/boolean-constant-misuse.sol", + "0.6.0", + ), Test(UncheckedLowLevel, "tests/detectors/unchecked-lowlevel/unchecked_lowlevel.sol", "0.4.25"), Test( UncheckedLowLevel, From cd95851094f9b17f5438ea0eddcd0b62c031fe3b Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 7 Dec 2020 19:52:16 +0100 Subject: [PATCH 10/12] Add missing this.totalSupply() --- .../tools/properties/properties/ercs/erc20/properties/mint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/tools/properties/properties/ercs/erc20/properties/mint.py b/slither/tools/properties/properties/ercs/erc20/properties/mint.py index 4aafa907e2..1549e7e643 100644 --- a/slither/tools/properties/properties/ercs/erc20/properties/mint.py +++ b/slither/tools/properties/properties/ercs/erc20/properties/mint.py @@ -10,7 +10,7 @@ name="crytic_supply_constant_ERC20PropertiesNotMintable()", description="The total supply does not increase.", content=""" -\t\treturn initialTotalSupply >= totalSupply();""", +\t\treturn initialTotalSupply >= this.totalSupply();""", type=PropertyType.MEDIUM_SEVERITY, return_type=PropertyReturn.SUCCESS, is_unit_test=True, From 192888c806ce5d5dc64fc10f94d75a2813a3b367 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 7 Dec 2020 19:53:55 +0100 Subject: [PATCH 11/12] Use crytic-compile 0.1.11 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 68cd1e7d12..1dad9ee5e1 100644 --- a/setup.py +++ b/setup.py @@ -11,10 +11,10 @@ install_requires=[ "prettytable>=0.7.2", "pysha3>=1.0.2", - # "crytic-compile>=0.1.10", + "crytic-compile>=0.1.11", "crytic-compile", ], - dependency_links=["git+https://github.com/crytic/crytic-compile.git@master#egg=crytic-compile"], + # dependency_links=["git+https://github.com/crytic/crytic-compile.git@master#egg=crytic-compile"], license="AGPL-3.0", long_description=open("README.md").read(), entry_points={ From 134a3e60f6731d6130cd0534ebe89255096e7bb7 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 7 Dec 2020 19:55:13 +0100 Subject: [PATCH 12/12] Minor --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1dad9ee5e1..374a9aa1e6 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ "prettytable>=0.7.2", "pysha3>=1.0.2", "crytic-compile>=0.1.11", - "crytic-compile", + # "crytic-compile", ], # dependency_links=["git+https://github.com/crytic/crytic-compile.git@master#egg=crytic-compile"], license="AGPL-3.0",