diff --git a/tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol b/tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol new file mode 100644 index 000000000..57ed13641 --- /dev/null +++ b/tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol @@ -0,0 +1,10 @@ +contract Test { + + function functionWithDeprecatedThrow() public constant { + // Deprecated: Change msg.gas -> gasleft() + if(msg.gas == msg.value) { + // Deprecated: Change throw -> revert() + throw; + } + } +} \ No newline at end of file diff --git a/tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol.0.4.25.DeprecatedStandards.json b/tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol.0.4.25.DeprecatedStandards.json new file mode 100644 index 000000000..ad121123d --- /dev/null +++ b/tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol.0.4.25.DeprecatedStandards.json @@ -0,0 +1,176 @@ +[ + [ + { + "elements": [ + { + "type": "node", + "name": "msg.gas == msg.value", + "source_mapping": { + "start": 140, + "length": 20, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "is_dependency": false, + "lines": [ + 5 + ], + "starting_column": 12, + "ending_column": 32 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "functionWithDeprecatedThrow", + "source_mapping": { + "start": 21, + "length": 229, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "is_dependency": false, + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 252, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "functionWithDeprecatedThrow()" + } + } + } + } + ], + "description": "Deprecated standard detected msg.gas == msg.value (tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol#5):\n\t- Usage of \"msg.gas\" should be replaced with \"gasleft()\"\n", + "markdown": "Deprecated standard detected [msg.gas == msg.value](tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol#L5):\n\t- Usage of \"msg.gas\" should be replaced with \"gasleft()\"\n", + "first_markdown_element": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol#L5", + "id": "e779713eabc28919356310f06b9413a8a3b7e9e713026d6cfae2d9f6839c1e57", + "check": "deprecated-standards", + "impact": "Informational", + "confidence": "High" + }, + { + "elements": [ + { + "type": "node", + "name": "", + "source_mapping": { + "start": 228, + "length": 5, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "is_dependency": false, + "lines": [ + 7 + ], + "starting_column": 13, + "ending_column": 18 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "functionWithDeprecatedThrow", + "source_mapping": { + "start": 21, + "length": 229, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "is_dependency": false, + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 252, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "functionWithDeprecatedThrow()" + } + } + } + } + ], + "description": "Deprecated standard detected THROW (tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol#7):\n\t- Usage of \"throw\" should be replaced with \"revert()\"\n", + "markdown": "Deprecated standard detected [THROW](tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol#L7):\n\t- Usage of \"throw\" should be replaced with \"revert()\"\n", + "first_markdown_element": "tests/detectors/deprecated-standards/0.4.25/deprecated_calls.sol#L7", + "id": "5fbf4a42467953d0fd8d0661cbb4eeb81d4b40f69ae3820196bf10c4be53044e", + "check": "deprecated-standards", + "impact": "Informational", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/test_detectors.py b/tests/test_detectors.py index 8719a899c..0f65bf137 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -1194,6 +1194,11 @@ ALL_TESTS = [ "multiple_constructor_schemes.sol", "0.4.22", ), + Test( + all_detectors.DeprecatedStandards, + "deprecated_calls.sol", + "0.4.25", + ), ] GENERIC_PATH = "/GENERIC_PATH"