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/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol b/tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol new file mode 100644 index 000000000..baf27a44e --- /dev/null +++ b/tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol @@ -0,0 +1,5 @@ +contract A { + function f(uint a, uint b, uint c) public returns (uint) { + return (a / b) * c; + } +} \ No newline at end of file diff --git a/tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol.0.4.25.DivideBeforeMultiply.json b/tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol.0.4.25.DivideBeforeMultiply.json new file mode 100644 index 000000000..529f9444b --- /dev/null +++ b/tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol.0.4.25.DivideBeforeMultiply.json @@ -0,0 +1,127 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 92, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 2, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 108, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256,uint256,uint256)" + } + }, + { + "type": "node", + "name": "(a / b) * c", + "source_mapping": { + "start": 81, + "length": 18, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 9, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 92, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 2, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 108, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256,uint256,uint256)" + } + } + } + } + ], + "description": "A.f(uint256,uint256,uint256) (tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol#2-4) performs a multiplication on the result of a division:\n\t-(a / b) * c (tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol#3)\n", + "markdown": "[A.f(uint256,uint256,uint256)](tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol#L2-L4) performs a multiplication on the result of a division:\n\t-[(a / b) * c](tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol#L3)\n", + "first_markdown_element": "tests/detectors/divide-before-multiply/0.4.25/divide_before_multiply.sol#L2-L4", + "id": "fe40e2f72824d1270402b09af057ec7364af1ad2f8c48ef4df72fc27012b3186", + "check": "divide-before-multiply", + "impact": "Medium", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol b/tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol new file mode 100644 index 000000000..baf27a44e --- /dev/null +++ b/tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol @@ -0,0 +1,5 @@ +contract A { + function f(uint a, uint b, uint c) public returns (uint) { + return (a / b) * c; + } +} \ No newline at end of file diff --git a/tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol.0.5.16.DivideBeforeMultiply.json b/tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol.0.5.16.DivideBeforeMultiply.json new file mode 100644 index 000000000..4421fa0ef --- /dev/null +++ b/tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol.0.5.16.DivideBeforeMultiply.json @@ -0,0 +1,127 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 92, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 2, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 108, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256,uint256,uint256)" + } + }, + { + "type": "node", + "name": "(a / b) * c", + "source_mapping": { + "start": 81, + "length": 18, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 9, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 92, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 2, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 108, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256,uint256,uint256)" + } + } + } + } + ], + "description": "A.f(uint256,uint256,uint256) (tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol#2-4) performs a multiplication on the result of a division:\n\t-(a / b) * c (tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol#3)\n", + "markdown": "[A.f(uint256,uint256,uint256)](tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol#L2-L4) performs a multiplication on the result of a division:\n\t-[(a / b) * c](tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol#L3)\n", + "first_markdown_element": "tests/detectors/divide-before-multiply/0.5.16/divide_before_multiply.sol#L2-L4", + "id": "a484421df5c9ebf3dc3d8bcec6701ab3065e03b21e294c4972142c4503f2fccb", + "check": "divide-before-multiply", + "impact": "Medium", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol b/tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol new file mode 100644 index 000000000..baf27a44e --- /dev/null +++ b/tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol @@ -0,0 +1,5 @@ +contract A { + function f(uint a, uint b, uint c) public returns (uint) { + return (a / b) * c; + } +} \ No newline at end of file diff --git a/tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol.0.6.11.DivideBeforeMultiply.json b/tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol.0.6.11.DivideBeforeMultiply.json new file mode 100644 index 000000000..564cac140 --- /dev/null +++ b/tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol.0.6.11.DivideBeforeMultiply.json @@ -0,0 +1,127 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 92, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 2, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 108, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256,uint256,uint256)" + } + }, + { + "type": "node", + "name": "(a / b) * c", + "source_mapping": { + "start": 81, + "length": 18, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 9, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 92, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 2, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 108, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256,uint256,uint256)" + } + } + } + } + ], + "description": "A.f(uint256,uint256,uint256) (tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol#2-4) performs a multiplication on the result of a division:\n\t-(a / b) * c (tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol#3)\n", + "markdown": "[A.f(uint256,uint256,uint256)](tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol#L2-L4) performs a multiplication on the result of a division:\n\t-[(a / b) * c](tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol#L3)\n", + "first_markdown_element": "tests/detectors/divide-before-multiply/0.6.11/divide_before_multiply.sol#L2-L4", + "id": "9010aa3fdf8f7689d4c4d4ea0bcd771668212100e5427e48644ed7337de03a6d", + "check": "divide-before-multiply", + "impact": "Medium", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol b/tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol new file mode 100644 index 000000000..baf27a44e --- /dev/null +++ b/tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol @@ -0,0 +1,5 @@ +contract A { + function f(uint a, uint b, uint c) public returns (uint) { + return (a / b) * c; + } +} \ No newline at end of file diff --git a/tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol.0.7.6.DivideBeforeMultiply.json b/tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol.0.7.6.DivideBeforeMultiply.json new file mode 100644 index 000000000..23dd10c28 --- /dev/null +++ b/tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol.0.7.6.DivideBeforeMultiply.json @@ -0,0 +1,127 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 92, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 2, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 108, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256,uint256,uint256)" + } + }, + { + "type": "node", + "name": "(a / b) * c", + "source_mapping": { + "start": 81, + "length": 18, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 9, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 92, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 2, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 108, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256,uint256,uint256)" + } + } + } + } + ], + "description": "A.f(uint256,uint256,uint256) (tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol#2-4) performs a multiplication on the result of a division:\n\t-(a / b) * c (tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol#3)\n", + "markdown": "[A.f(uint256,uint256,uint256)](tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol#L2-L4) performs a multiplication on the result of a division:\n\t-[(a / b) * c](tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol#L3)\n", + "first_markdown_element": "tests/detectors/divide-before-multiply/0.7.6/divide_before_multiply.sol#L2-L4", + "id": "9bc6cb85ece6cd57fa946707784180957080ad5f9575abc17af218f0d2801f77", + "check": "divide-before-multiply", + "impact": "Medium", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/enum-conversion/0.4.2/enum_conversion.sol b/tests/detectors/enum-conversion/0.4.2/enum_conversion.sol new file mode 100644 index 000000000..7a72084eb --- /dev/null +++ b/tests/detectors/enum-conversion/0.4.2/enum_conversion.sol @@ -0,0 +1,9 @@ +pragma solidity 0.4.2; + contract Test{ + + enum E{a} + + function bug(uint a) public returns(E){ + return E(a); + } +} \ No newline at end of file diff --git a/tests/detectors/enum-conversion/0.4.2/enum_conversion.sol.0.4.2.EnumConversion.json b/tests/detectors/enum-conversion/0.4.2/enum_conversion.sol.0.4.2.EnumConversion.json new file mode 100644 index 000000000..8eab7b7df --- /dev/null +++ b/tests/detectors/enum-conversion/0.4.2/enum_conversion.sol.0.4.2.EnumConversion.json @@ -0,0 +1,222 @@ +[ + [ + { + "elements": [ + { + "type": "node", + "name": "Test.E(a)", + "source_mapping": { + "start": 118, + "length": 11, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "is_dependency": false, + "lines": [ + 7 + ], + "starting_column": 9, + "ending_column": 20 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bug", + "source_mapping": { + "start": 70, + "length": 69, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "is_dependency": false, + "lines": [ + 6, + 7, + 8 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 27, + "length": 114, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 5, + "ending_column": 0 + } + }, + "signature": "bug(uint256)" + } + } + } + }, + { + "type": "variable", + "name": "a", + "source_mapping": { + "start": 83, + "length": 6, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "is_dependency": false, + "lines": [ + 6 + ], + "starting_column": 18, + "ending_column": 24 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bug", + "source_mapping": { + "start": 70, + "length": 69, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "is_dependency": false, + "lines": [ + 6, + 7, + 8 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 27, + "length": 114, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 5, + "ending_column": 0 + } + }, + "signature": "bug(uint256)" + } + } + } + }, + { + "type": "node", + "name": "Test.E(a)", + "source_mapping": { + "start": 118, + "length": 11, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "is_dependency": false, + "lines": [ + 7 + ], + "starting_column": 9, + "ending_column": 20 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bug", + "source_mapping": { + "start": 70, + "length": 69, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "is_dependency": false, + "lines": [ + 6, + 7, + 8 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 27, + "length": 114, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 5, + "ending_column": 0 + } + }, + "signature": "bug(uint256)" + } + } + } + } + ], + "description": "Test.E(a) (tests/detectors/enum-conversion/0.4.2/enum_conversion.sol#7) has a dangerous enum conversion\n\t- Variable: Test.bug(uint256).a (tests/detectors/enum-conversion/0.4.2/enum_conversion.sol#6) of type: uint256\n\t- Enum conversion: Test.E(a) (tests/detectors/enum-conversion/0.4.2/enum_conversion.sol#7)\n", + "markdown": "[Test.E(a)](tests/detectors/enum-conversion/0.4.2/enum_conversion.sol#L7) has a dangerous enum conversion\n\t- Variable: [Test.bug(uint256).a](tests/detectors/enum-conversion/0.4.2/enum_conversion.sol#L6) of type: uint256\n\t- Enum conversion: [Test.E(a)](tests/detectors/enum-conversion/0.4.2/enum_conversion.sol#L7)\n", + "first_markdown_element": "tests/detectors/enum-conversion/0.4.2/enum_conversion.sol#L7", + "id": "f16bcdd6943fe3ff7ed6cc9b729ed5f95f61375509c7cce6646efa44c69860b7", + "check": "enum-conversion", + "impact": "Medium", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/incorrect-shift/0.4.25/shift_parameter_mixup.sol b/tests/detectors/incorrect-shift/0.4.25/shift_parameter_mixup.sol new file mode 100644 index 000000000..89a9210ad --- /dev/null +++ b/tests/detectors/incorrect-shift/0.4.25/shift_parameter_mixup.sol @@ -0,0 +1,8 @@ +contract C { + + function f() internal returns (uint a) { + assembly { + a := shr(a, 8) + } + } +} \ No newline at end of file diff --git a/tests/detectors/incorrect-shift/0.4.25/shift_parameter_mixup.sol.0.4.25.ShiftParameterMixup.json b/tests/detectors/incorrect-shift/0.4.25/shift_parameter_mixup.sol.0.4.25.ShiftParameterMixup.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/incorrect-shift/0.4.25/shift_parameter_mixup.sol.0.4.25.ShiftParameterMixup.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/detectors/incorrect-shift/0.5.16/shift_parameter_mixup.sol b/tests/detectors/incorrect-shift/0.5.16/shift_parameter_mixup.sol new file mode 100644 index 000000000..89a9210ad --- /dev/null +++ b/tests/detectors/incorrect-shift/0.5.16/shift_parameter_mixup.sol @@ -0,0 +1,8 @@ +contract C { + + function f() internal returns (uint a) { + assembly { + a := shr(a, 8) + } + } +} \ No newline at end of file diff --git a/tests/detectors/incorrect-shift/0.5.16/shift_parameter_mixup.sol.0.5.16.ShiftParameterMixup.json b/tests/detectors/incorrect-shift/0.5.16/shift_parameter_mixup.sol.0.5.16.ShiftParameterMixup.json new file mode 100644 index 000000000..5825bcacc --- /dev/null +++ b/tests/detectors/incorrect-shift/0.5.16/shift_parameter_mixup.sol.0.5.16.ShiftParameterMixup.json @@ -0,0 +1,3 @@ +[ + [] +] \ No newline at end of file diff --git a/tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol b/tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol new file mode 100644 index 000000000..89a9210ad --- /dev/null +++ b/tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol @@ -0,0 +1,8 @@ +contract C { + + function f() internal returns (uint a) { + assembly { + a := shr(a, 8) + } + } +} \ No newline at end of file diff --git a/tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol.0.6.11.ShiftParameterMixup.json b/tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol.0.6.11.ShiftParameterMixup.json new file mode 100644 index 000000000..e6a1c784f --- /dev/null +++ b/tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol.0.6.11.ShiftParameterMixup.json @@ -0,0 +1,135 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 19, + "length": 106, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 0, + "length": 128, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "f()" + } + }, + { + "type": "node", + "name": "a = 8 >> a", + "source_mapping": { + "start": 93, + "length": 14, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 5 + ], + "starting_column": 13, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 19, + "length": 106, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 0, + "length": 128, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "f()" + } + } + } + } + ], + "description": "C.f() (tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol#3-7) contains an incorrect shift operation: a = 8 >> a (tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol#5)\n", + "markdown": "[C.f()](tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol#L3-L7) contains an incorrect shift operation: [a = 8 >> a](tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol#L5)\n", + "first_markdown_element": "tests/detectors/incorrect-shift/0.6.11/shift_parameter_mixup.sol#L3-L7", + "id": "eefda017d078fd6c0cdb19b471ac8d0a96b2b3dba9bac04ac194270820a77301", + "check": "incorrect-shift", + "impact": "High", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol b/tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol new file mode 100644 index 000000000..89a9210ad --- /dev/null +++ b/tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol @@ -0,0 +1,8 @@ +contract C { + + function f() internal returns (uint a) { + assembly { + a := shr(a, 8) + } + } +} \ No newline at end of file diff --git a/tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol.0.7.6.ShiftParameterMixup.json b/tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol.0.7.6.ShiftParameterMixup.json new file mode 100644 index 000000000..5960eb824 --- /dev/null +++ b/tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol.0.7.6.ShiftParameterMixup.json @@ -0,0 +1,135 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 19, + "length": 106, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 0, + "length": 128, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "f()" + } + }, + { + "type": "node", + "name": "a = 8 >> a", + "source_mapping": { + "start": 93, + "length": 14, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 5 + ], + "starting_column": 13, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 19, + "length": 106, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 0, + "length": 128, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "f()" + } + } + } + } + ], + "description": "C.f() (tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol#3-7) contains an incorrect shift operation: a = 8 >> a (tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol#5)\n", + "markdown": "[C.f()](tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol#L3-L7) contains an incorrect shift operation: [a = 8 >> a](tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol#L5)\n", + "first_markdown_element": "tests/detectors/incorrect-shift/0.7.6/shift_parameter_mixup.sol#L3-L7", + "id": "8aa2292fd8d53a23f05aed92384dde452ea1f879d2422c4726b75a79a5aa6f81", + "check": "incorrect-shift", + "impact": "High", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol b/tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol new file mode 100644 index 000000000..58149d329 --- /dev/null +++ b/tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol @@ -0,0 +1,9 @@ +interface ISomething { + function f1() external returns(uint); +} + +contract Something { + function f1() external returns(uint){ + return 42; + } +} \ No newline at end of file diff --git a/tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol.0.4.25.MissingInheritance.json b/tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol.0.4.25.MissingInheritance.json new file mode 100644 index 000000000..bb52cfa9b --- /dev/null +++ b/tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol.0.4.25.MissingInheritance.json @@ -0,0 +1,58 @@ +[ + [ + { + "elements": [ + { + "type": "contract", + "name": "Something", + "source_mapping": { + "start": 68, + "length": 89, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol", + "is_dependency": false, + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + { + "type": "contract", + "name": "ISomething", + "source_mapping": { + "start": 0, + "length": 66, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3 + ], + "starting_column": 1, + "ending_column": 2 + } + } + ], + "description": "Something (tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#5-10) should inherit from ISomething (tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#1-3)\n", + "markdown": "[Something](tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#L5-L10) should inherit from [ISomething](tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#L1-L3)\n", + "first_markdown_element": "tests/detectors/missing-inheritance/0.4.25/unimplemented_interface.sol#L5-L10", + "id": "58962dc72a6c49524a027e8e1615ab92be30f1a0f5ef0eb4a029204687159649", + "check": "missing-inheritance", + "impact": "Informational", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol b/tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol new file mode 100644 index 000000000..58149d329 --- /dev/null +++ b/tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol @@ -0,0 +1,9 @@ +interface ISomething { + function f1() external returns(uint); +} + +contract Something { + function f1() external returns(uint){ + return 42; + } +} \ No newline at end of file diff --git a/tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol.0.5.16.MissingInheritance.json b/tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol.0.5.16.MissingInheritance.json new file mode 100644 index 000000000..4dc27f5b5 --- /dev/null +++ b/tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol.0.5.16.MissingInheritance.json @@ -0,0 +1,58 @@ +[ + [ + { + "elements": [ + { + "type": "contract", + "name": "Something", + "source_mapping": { + "start": 68, + "length": 89, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol", + "is_dependency": false, + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + { + "type": "contract", + "name": "ISomething", + "source_mapping": { + "start": 0, + "length": 66, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3 + ], + "starting_column": 1, + "ending_column": 2 + } + } + ], + "description": "Something (tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#5-10) should inherit from ISomething (tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#1-3)\n", + "markdown": "[Something](tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#L5-L10) should inherit from [ISomething](tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#L1-L3)\n", + "first_markdown_element": "tests/detectors/missing-inheritance/0.5.16/unimplemented_interface.sol#L5-L10", + "id": "58962dc72a6c49524a027e8e1615ab92be30f1a0f5ef0eb4a029204687159649", + "check": "missing-inheritance", + "impact": "Informational", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol b/tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol new file mode 100644 index 000000000..58149d329 --- /dev/null +++ b/tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol @@ -0,0 +1,9 @@ +interface ISomething { + function f1() external returns(uint); +} + +contract Something { + function f1() external returns(uint){ + return 42; + } +} \ No newline at end of file diff --git a/tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol.0.6.11.MissingInheritance.json b/tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol.0.6.11.MissingInheritance.json new file mode 100644 index 000000000..800114e0c --- /dev/null +++ b/tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol.0.6.11.MissingInheritance.json @@ -0,0 +1,58 @@ +[ + [ + { + "elements": [ + { + "type": "contract", + "name": "Something", + "source_mapping": { + "start": 68, + "length": 89, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol", + "is_dependency": false, + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + { + "type": "contract", + "name": "ISomething", + "source_mapping": { + "start": 0, + "length": 66, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3 + ], + "starting_column": 1, + "ending_column": 2 + } + } + ], + "description": "Something (tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#5-10) should inherit from ISomething (tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#1-3)\n", + "markdown": "[Something](tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#L5-L10) should inherit from [ISomething](tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#L1-L3)\n", + "first_markdown_element": "tests/detectors/missing-inheritance/0.6.11/unimplemented_interface.sol#L5-L10", + "id": "58962dc72a6c49524a027e8e1615ab92be30f1a0f5ef0eb4a029204687159649", + "check": "missing-inheritance", + "impact": "Informational", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol b/tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol new file mode 100644 index 000000000..58149d329 --- /dev/null +++ b/tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol @@ -0,0 +1,9 @@ +interface ISomething { + function f1() external returns(uint); +} + +contract Something { + function f1() external returns(uint){ + return 42; + } +} \ No newline at end of file diff --git a/tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol.0.7.6.MissingInheritance.json b/tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol.0.7.6.MissingInheritance.json new file mode 100644 index 000000000..7746c4a37 --- /dev/null +++ b/tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol.0.7.6.MissingInheritance.json @@ -0,0 +1,58 @@ +[ + [ + { + "elements": [ + { + "type": "contract", + "name": "Something", + "source_mapping": { + "start": 68, + "length": 89, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol", + "is_dependency": false, + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + { + "type": "contract", + "name": "ISomething", + "source_mapping": { + "start": 0, + "length": 66, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3 + ], + "starting_column": 1, + "ending_column": 2 + } + } + ], + "description": "Something (tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#5-10) should inherit from ISomething (tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#1-3)\n", + "markdown": "[Something](tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#L5-L10) should inherit from [ISomething](tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#L1-L3)\n", + "first_markdown_element": "tests/detectors/missing-inheritance/0.7.6/unimplemented_interface.sol#L5-L10", + "id": "58962dc72a6c49524a027e8e1615ab92be30f1a0f5ef0eb4a029204687159649", + "check": "missing-inheritance", + "impact": "Informational", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol b/tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol new file mode 100644 index 000000000..3703d71e5 --- /dev/null +++ b/tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol @@ -0,0 +1,13 @@ +contract A { + uint x; + constructor() public { + x = 0; + } + function A() public { + x = 1; + } + + function test() public returns(uint) { + return x; + } +} \ No newline at end of file diff --git a/tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol.0.4.22.MultipleConstructorSchemes.json b/tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol.0.4.22.MultipleConstructorSchemes.json new file mode 100644 index 000000000..cf72d53fb --- /dev/null +++ b/tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol.0.4.22.MultipleConstructorSchemes.json @@ -0,0 +1,154 @@ +[ + [ + { + "elements": [ + { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 193, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + { + "type": "function", + "name": "constructor", + "source_mapping": { + "start": 29, + "length": 43, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "is_dependency": false, + "lines": [ + 3, + 4, + 5 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 193, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "constructor()" + } + }, + { + "type": "function", + "name": "A", + "source_mapping": { + "start": 77, + "length": 42, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "is_dependency": false, + "lines": [ + 6, + 7, + 8 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 193, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "A()" + } + } + ], + "description": "A (tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol#1-14) contains multiple constructors in the same contract:\n\t- A.constructor() (tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol#3-5)\n\t- A.A() (tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol#6-8)\n", + "markdown": "[A](tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol#L1-L14) contains multiple constructors in the same contract:\n\t- [A.constructor()](tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol#L3-L5)\n\t- [A.A()](tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol#L6-L8)\n", + "first_markdown_element": "tests/detectors/multiple-constructors/0.4.22/multiple_constructor_schemes.sol#L1-L14", + "id": "704cdb1c05e919913c22befaf077b9585bc75e31b5033fa46c930ad82dc6852e", + "check": "multiple-constructors", + "impact": "High", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/similar-names/0.4.25/similar_variables.sol b/tests/detectors/similar-names/0.4.25/similar_variables.sol new file mode 100644 index 000000000..57f969867 --- /dev/null +++ b/tests/detectors/similar-names/0.4.25/similar_variables.sol @@ -0,0 +1,7 @@ +contract Similar { + function f() public returns (uint) { + uint testVariable = 1; + uint textVariable = 2; + return testVariable + textVariable; + } +} \ No newline at end of file diff --git a/tests/detectors/similar-names/0.4.25/similar_variables.sol.0.4.25.SimilarVarsDetection.json b/tests/detectors/similar-names/0.4.25/similar_variables.sol.0.4.25.SimilarVarsDetection.json new file mode 100644 index 000000000..3393d1d06 --- /dev/null +++ b/tests/detectors/similar-names/0.4.25/similar_variables.sol.0.4.25.SimilarVarsDetection.json @@ -0,0 +1,155 @@ +[ + [ + { + "elements": [ + { + "type": "variable", + "name": "testVariable", + "source_mapping": { + "start": 69, + "length": 21, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 9, + "ending_column": 30 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 23, + "length": 149, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Similar", + "source_mapping": { + "start": 0, + "length": 174, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f()" + } + } + } + }, + { + "type": "variable", + "name": "textVariable", + "source_mapping": { + "start": 100, + "length": 21, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "is_dependency": false, + "lines": [ + 4 + ], + "starting_column": 9, + "ending_column": 30 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 23, + "length": 149, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Similar", + "source_mapping": { + "start": 0, + "length": 174, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.4.25/similar_variables.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f()" + } + } + } + } + ], + "description": "Variable Similar.f().testVariable (tests/detectors/similar-names/0.4.25/similar_variables.sol#3) is too similar to Similar.f().textVariable (tests/detectors/similar-names/0.4.25/similar_variables.sol#4)\n", + "markdown": "Variable [Similar.f().testVariable](tests/detectors/similar-names/0.4.25/similar_variables.sol#L3) is too similar to [Similar.f().textVariable](tests/detectors/similar-names/0.4.25/similar_variables.sol#L4)\n", + "first_markdown_element": "tests/detectors/similar-names/0.4.25/similar_variables.sol#L3", + "id": "2f767a2bb6f48a8435ce456e2d3ad859bdeccf66507735a14e20515e914038d5", + "check": "similar-names", + "impact": "Informational", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/similar-names/0.5.16/similar_variables.sol b/tests/detectors/similar-names/0.5.16/similar_variables.sol new file mode 100644 index 000000000..57f969867 --- /dev/null +++ b/tests/detectors/similar-names/0.5.16/similar_variables.sol @@ -0,0 +1,7 @@ +contract Similar { + function f() public returns (uint) { + uint testVariable = 1; + uint textVariable = 2; + return testVariable + textVariable; + } +} \ No newline at end of file diff --git a/tests/detectors/similar-names/0.5.16/similar_variables.sol.0.5.16.SimilarVarsDetection.json b/tests/detectors/similar-names/0.5.16/similar_variables.sol.0.5.16.SimilarVarsDetection.json new file mode 100644 index 000000000..543023e43 --- /dev/null +++ b/tests/detectors/similar-names/0.5.16/similar_variables.sol.0.5.16.SimilarVarsDetection.json @@ -0,0 +1,155 @@ +[ + [ + { + "elements": [ + { + "type": "variable", + "name": "testVariable", + "source_mapping": { + "start": 69, + "length": 21, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 9, + "ending_column": 30 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 23, + "length": 149, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Similar", + "source_mapping": { + "start": 0, + "length": 174, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f()" + } + } + } + }, + { + "type": "variable", + "name": "textVariable", + "source_mapping": { + "start": 100, + "length": 21, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "is_dependency": false, + "lines": [ + 4 + ], + "starting_column": 9, + "ending_column": 30 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 23, + "length": 149, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Similar", + "source_mapping": { + "start": 0, + "length": 174, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.5.16/similar_variables.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f()" + } + } + } + } + ], + "description": "Variable Similar.f().testVariable (tests/detectors/similar-names/0.5.16/similar_variables.sol#3) is too similar to Similar.f().textVariable (tests/detectors/similar-names/0.5.16/similar_variables.sol#4)\n", + "markdown": "Variable [Similar.f().testVariable](tests/detectors/similar-names/0.5.16/similar_variables.sol#L3) is too similar to [Similar.f().textVariable](tests/detectors/similar-names/0.5.16/similar_variables.sol#L4)\n", + "first_markdown_element": "tests/detectors/similar-names/0.5.16/similar_variables.sol#L3", + "id": "2f767a2bb6f48a8435ce456e2d3ad859bdeccf66507735a14e20515e914038d5", + "check": "similar-names", + "impact": "Informational", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/similar-names/0.6.11/similar_variables.sol b/tests/detectors/similar-names/0.6.11/similar_variables.sol new file mode 100644 index 000000000..57f969867 --- /dev/null +++ b/tests/detectors/similar-names/0.6.11/similar_variables.sol @@ -0,0 +1,7 @@ +contract Similar { + function f() public returns (uint) { + uint testVariable = 1; + uint textVariable = 2; + return testVariable + textVariable; + } +} \ No newline at end of file diff --git a/tests/detectors/similar-names/0.6.11/similar_variables.sol.0.6.11.SimilarVarsDetection.json b/tests/detectors/similar-names/0.6.11/similar_variables.sol.0.6.11.SimilarVarsDetection.json new file mode 100644 index 000000000..89aa1e5dc --- /dev/null +++ b/tests/detectors/similar-names/0.6.11/similar_variables.sol.0.6.11.SimilarVarsDetection.json @@ -0,0 +1,155 @@ +[ + [ + { + "elements": [ + { + "type": "variable", + "name": "testVariable", + "source_mapping": { + "start": 69, + "length": 21, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 9, + "ending_column": 30 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 23, + "length": 149, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Similar", + "source_mapping": { + "start": 0, + "length": 174, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f()" + } + } + } + }, + { + "type": "variable", + "name": "textVariable", + "source_mapping": { + "start": 100, + "length": 21, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "is_dependency": false, + "lines": [ + 4 + ], + "starting_column": 9, + "ending_column": 30 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 23, + "length": 149, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Similar", + "source_mapping": { + "start": 0, + "length": 174, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.6.11/similar_variables.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f()" + } + } + } + } + ], + "description": "Variable Similar.f().testVariable (tests/detectors/similar-names/0.6.11/similar_variables.sol#3) is too similar to Similar.f().textVariable (tests/detectors/similar-names/0.6.11/similar_variables.sol#4)\n", + "markdown": "Variable [Similar.f().testVariable](tests/detectors/similar-names/0.6.11/similar_variables.sol#L3) is too similar to [Similar.f().textVariable](tests/detectors/similar-names/0.6.11/similar_variables.sol#L4)\n", + "first_markdown_element": "tests/detectors/similar-names/0.6.11/similar_variables.sol#L3", + "id": "2f767a2bb6f48a8435ce456e2d3ad859bdeccf66507735a14e20515e914038d5", + "check": "similar-names", + "impact": "Informational", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/similar-names/0.7.6/similar_variables.sol b/tests/detectors/similar-names/0.7.6/similar_variables.sol new file mode 100644 index 000000000..57f969867 --- /dev/null +++ b/tests/detectors/similar-names/0.7.6/similar_variables.sol @@ -0,0 +1,7 @@ +contract Similar { + function f() public returns (uint) { + uint testVariable = 1; + uint textVariable = 2; + return testVariable + textVariable; + } +} \ No newline at end of file diff --git a/tests/detectors/similar-names/0.7.6/similar_variables.sol.0.7.6.SimilarVarsDetection.json b/tests/detectors/similar-names/0.7.6/similar_variables.sol.0.7.6.SimilarVarsDetection.json new file mode 100644 index 000000000..dd05b4133 --- /dev/null +++ b/tests/detectors/similar-names/0.7.6/similar_variables.sol.0.7.6.SimilarVarsDetection.json @@ -0,0 +1,155 @@ +[ + [ + { + "elements": [ + { + "type": "variable", + "name": "testVariable", + "source_mapping": { + "start": 69, + "length": 21, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 9, + "ending_column": 30 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 23, + "length": 149, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Similar", + "source_mapping": { + "start": 0, + "length": 174, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f()" + } + } + } + }, + { + "type": "variable", + "name": "textVariable", + "source_mapping": { + "start": 100, + "length": 21, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "is_dependency": false, + "lines": [ + 4 + ], + "starting_column": 9, + "ending_column": 30 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 23, + "length": 149, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Similar", + "source_mapping": { + "start": 0, + "length": 174, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/similar-names/0.7.6/similar_variables.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f()" + } + } + } + } + ], + "description": "Variable Similar.f().testVariable (tests/detectors/similar-names/0.7.6/similar_variables.sol#3) is too similar to Similar.f().textVariable (tests/detectors/similar-names/0.7.6/similar_variables.sol#4)\n", + "markdown": "Variable [Similar.f().testVariable](tests/detectors/similar-names/0.7.6/similar_variables.sol#L3) is too similar to [Similar.f().textVariable](tests/detectors/similar-names/0.7.6/similar_variables.sol#L4)\n", + "first_markdown_element": "tests/detectors/similar-names/0.7.6/similar_variables.sol#L3", + "id": "2f767a2bb6f48a8435ce456e2d3ad859bdeccf66507735a14e20515e914038d5", + "check": "similar-names", + "impact": "Informational", + "confidence": "Medium" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/tautology/0.4.25/type_based_tautology.sol b/tests/detectors/tautology/0.4.25/type_based_tautology.sol new file mode 100644 index 000000000..cfd3997c6 --- /dev/null +++ b/tests/detectors/tautology/0.4.25/type_based_tautology.sol @@ -0,0 +1,12 @@ +contract A { + function f(uint x) public returns (uint) { + if (x >= 0) { // bad -- always true + return 1; + } + return 7; + } + + function g(uint8 y) public returns (bool) { + return (y < 512); // bad! + } +} \ No newline at end of file diff --git a/tests/detectors/tautology/0.4.25/type_based_tautology.sol.0.4.25.TypeBasedTautology.json b/tests/detectors/tautology/0.4.25/type_based_tautology.sol.0.4.25.TypeBasedTautology.json new file mode 100644 index 000000000..1592c496c --- /dev/null +++ b/tests/detectors/tautology/0.4.25/type_based_tautology.sol.0.4.25.TypeBasedTautology.json @@ -0,0 +1,284 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 133, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256)" + } + }, + { + "type": "node", + "name": "x >= 0", + "source_mapping": { + "start": 69, + "length": 6, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 13, + "ending_column": 19 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 133, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256)" + } + } + } + } + ], + "description": "A.f(uint256) (tests/detectors/tautology/0.4.25/type_based_tautology.sol#2-7) contains a tautology or contradiction:\n\t- x >= 0 (tests/detectors/tautology/0.4.25/type_based_tautology.sol#3)\n", + "markdown": "[A.f(uint256)](tests/detectors/tautology/0.4.25/type_based_tautology.sol#L2-L7) contains a tautology or contradiction:\n\t- [x >= 0](tests/detectors/tautology/0.4.25/type_based_tautology.sol#L3)\n", + "first_markdown_element": "tests/detectors/tautology/0.4.25/type_based_tautology.sol#L2-L7", + "id": "c9b8085dbb7e6d0dfc2ee5711ac45a70e4c0f494ac4efcae42a6b947e3170ddb", + "check": "tautology", + "impact": "Medium", + "confidence": "High" + }, + { + "elements": [ + { + "type": "function", + "name": "g", + "source_mapping": { + "start": 150, + "length": 80, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "g(uint8)" + } + }, + { + "type": "node", + "name": "(y < 512)", + "source_mapping": { + "start": 202, + "length": 16, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 10 + ], + "starting_column": 9, + "ending_column": 25 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "g", + "source_mapping": { + "start": 150, + "length": 80, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.4.25/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "g(uint8)" + } + } + } + } + ], + "description": "A.g(uint8) (tests/detectors/tautology/0.4.25/type_based_tautology.sol#9-11) contains a tautology or contradiction:\n\t- (y < 512) (tests/detectors/tautology/0.4.25/type_based_tautology.sol#10)\n", + "markdown": "[A.g(uint8)](tests/detectors/tautology/0.4.25/type_based_tautology.sol#L9-L11) contains a tautology or contradiction:\n\t- [(y < 512)](tests/detectors/tautology/0.4.25/type_based_tautology.sol#L10)\n", + "first_markdown_element": "tests/detectors/tautology/0.4.25/type_based_tautology.sol#L9-L11", + "id": "75dfe0b8776a8cf490a4e3f30366dec173fd0dc7418335f77c68ba5bca536382", + "check": "tautology", + "impact": "Medium", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/tautology/0.5.16/type_based_tautology.sol b/tests/detectors/tautology/0.5.16/type_based_tautology.sol new file mode 100644 index 000000000..cfd3997c6 --- /dev/null +++ b/tests/detectors/tautology/0.5.16/type_based_tautology.sol @@ -0,0 +1,12 @@ +contract A { + function f(uint x) public returns (uint) { + if (x >= 0) { // bad -- always true + return 1; + } + return 7; + } + + function g(uint8 y) public returns (bool) { + return (y < 512); // bad! + } +} \ No newline at end of file diff --git a/tests/detectors/tautology/0.5.16/type_based_tautology.sol.0.5.16.TypeBasedTautology.json b/tests/detectors/tautology/0.5.16/type_based_tautology.sol.0.5.16.TypeBasedTautology.json new file mode 100644 index 000000000..2b347f0e8 --- /dev/null +++ b/tests/detectors/tautology/0.5.16/type_based_tautology.sol.0.5.16.TypeBasedTautology.json @@ -0,0 +1,284 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 133, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256)" + } + }, + { + "type": "node", + "name": "x >= 0", + "source_mapping": { + "start": 69, + "length": 6, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 13, + "ending_column": 19 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 133, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256)" + } + } + } + } + ], + "description": "A.f(uint256) (tests/detectors/tautology/0.5.16/type_based_tautology.sol#2-7) contains a tautology or contradiction:\n\t- x >= 0 (tests/detectors/tautology/0.5.16/type_based_tautology.sol#3)\n", + "markdown": "[A.f(uint256)](tests/detectors/tautology/0.5.16/type_based_tautology.sol#L2-L7) contains a tautology or contradiction:\n\t- [x >= 0](tests/detectors/tautology/0.5.16/type_based_tautology.sol#L3)\n", + "first_markdown_element": "tests/detectors/tautology/0.5.16/type_based_tautology.sol#L2-L7", + "id": "764eb2c7aa5cd1a30d16deb620e0dc3b8a9e9170978908bcc1f6fc1ac5a8daa1", + "check": "tautology", + "impact": "Medium", + "confidence": "High" + }, + { + "elements": [ + { + "type": "function", + "name": "g", + "source_mapping": { + "start": 150, + "length": 80, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "g(uint8)" + } + }, + { + "type": "node", + "name": "(y < 512)", + "source_mapping": { + "start": 202, + "length": 16, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 10 + ], + "starting_column": 9, + "ending_column": 25 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "g", + "source_mapping": { + "start": 150, + "length": 80, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.5.16/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "g(uint8)" + } + } + } + } + ], + "description": "A.g(uint8) (tests/detectors/tautology/0.5.16/type_based_tautology.sol#9-11) contains a tautology or contradiction:\n\t- (y < 512) (tests/detectors/tautology/0.5.16/type_based_tautology.sol#10)\n", + "markdown": "[A.g(uint8)](tests/detectors/tautology/0.5.16/type_based_tautology.sol#L9-L11) contains a tautology or contradiction:\n\t- [(y < 512)](tests/detectors/tautology/0.5.16/type_based_tautology.sol#L10)\n", + "first_markdown_element": "tests/detectors/tautology/0.5.16/type_based_tautology.sol#L9-L11", + "id": "0c29aa92764cb30104a4c4ba02e307d5949143b4cbfa2d8a52d9473140907872", + "check": "tautology", + "impact": "Medium", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/tautology/0.6.11/type_based_tautology.sol b/tests/detectors/tautology/0.6.11/type_based_tautology.sol new file mode 100644 index 000000000..cfd3997c6 --- /dev/null +++ b/tests/detectors/tautology/0.6.11/type_based_tautology.sol @@ -0,0 +1,12 @@ +contract A { + function f(uint x) public returns (uint) { + if (x >= 0) { // bad -- always true + return 1; + } + return 7; + } + + function g(uint8 y) public returns (bool) { + return (y < 512); // bad! + } +} \ No newline at end of file diff --git a/tests/detectors/tautology/0.6.11/type_based_tautology.sol.0.6.11.TypeBasedTautology.json b/tests/detectors/tautology/0.6.11/type_based_tautology.sol.0.6.11.TypeBasedTautology.json new file mode 100644 index 000000000..971033eae --- /dev/null +++ b/tests/detectors/tautology/0.6.11/type_based_tautology.sol.0.6.11.TypeBasedTautology.json @@ -0,0 +1,284 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 133, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256)" + } + }, + { + "type": "node", + "name": "x >= 0", + "source_mapping": { + "start": 69, + "length": 6, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 13, + "ending_column": 19 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 133, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256)" + } + } + } + } + ], + "description": "A.f(uint256) (tests/detectors/tautology/0.6.11/type_based_tautology.sol#2-7) contains a tautology or contradiction:\n\t- x >= 0 (tests/detectors/tautology/0.6.11/type_based_tautology.sol#3)\n", + "markdown": "[A.f(uint256)](tests/detectors/tautology/0.6.11/type_based_tautology.sol#L2-L7) contains a tautology or contradiction:\n\t- [x >= 0](tests/detectors/tautology/0.6.11/type_based_tautology.sol#L3)\n", + "first_markdown_element": "tests/detectors/tautology/0.6.11/type_based_tautology.sol#L2-L7", + "id": "fec3df769045cbe4984e50b2f651f60ffc36b116bc7273a64f761e8fbfc674b9", + "check": "tautology", + "impact": "Medium", + "confidence": "High" + }, + { + "elements": [ + { + "type": "function", + "name": "g", + "source_mapping": { + "start": 150, + "length": 80, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "g(uint8)" + } + }, + { + "type": "node", + "name": "(y < 512)", + "source_mapping": { + "start": 202, + "length": 16, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 10 + ], + "starting_column": 9, + "ending_column": 25 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "g", + "source_mapping": { + "start": 150, + "length": 80, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.6.11/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "g(uint8)" + } + } + } + } + ], + "description": "A.g(uint8) (tests/detectors/tautology/0.6.11/type_based_tautology.sol#9-11) contains a tautology or contradiction:\n\t- (y < 512) (tests/detectors/tautology/0.6.11/type_based_tautology.sol#10)\n", + "markdown": "[A.g(uint8)](tests/detectors/tautology/0.6.11/type_based_tautology.sol#L9-L11) contains a tautology or contradiction:\n\t- [(y < 512)](tests/detectors/tautology/0.6.11/type_based_tautology.sol#L10)\n", + "first_markdown_element": "tests/detectors/tautology/0.6.11/type_based_tautology.sol#L9-L11", + "id": "51bc777574da16aab9aefb9d0294fdad9ef3a44136e9e7b1f7e05cfd9c1d4e54", + "check": "tautology", + "impact": "Medium", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/detectors/tautology/0.7.6/type_based_tautology.sol b/tests/detectors/tautology/0.7.6/type_based_tautology.sol new file mode 100644 index 000000000..cfd3997c6 --- /dev/null +++ b/tests/detectors/tautology/0.7.6/type_based_tautology.sol @@ -0,0 +1,12 @@ +contract A { + function f(uint x) public returns (uint) { + if (x >= 0) { // bad -- always true + return 1; + } + return 7; + } + + function g(uint8 y) public returns (bool) { + return (y < 512); // bad! + } +} \ No newline at end of file diff --git a/tests/detectors/tautology/0.7.6/type_based_tautology.sol.0.7.6.TypeBasedTautology.json b/tests/detectors/tautology/0.7.6/type_based_tautology.sol.0.7.6.TypeBasedTautology.json new file mode 100644 index 000000000..633bbaa05 --- /dev/null +++ b/tests/detectors/tautology/0.7.6/type_based_tautology.sol.0.7.6.TypeBasedTautology.json @@ -0,0 +1,284 @@ +[ + [ + { + "elements": [ + { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 133, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256)" + } + }, + { + "type": "node", + "name": "x >= 0", + "source_mapping": { + "start": 69, + "length": 6, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 3 + ], + "starting_column": 13, + "ending_column": 19 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 14, + "length": 133, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "f(uint256)" + } + } + } + } + ], + "description": "A.f(uint256) (tests/detectors/tautology/0.7.6/type_based_tautology.sol#2-7) contains a tautology or contradiction:\n\t- x >= 0 (tests/detectors/tautology/0.7.6/type_based_tautology.sol#3)\n", + "markdown": "[A.f(uint256)](tests/detectors/tautology/0.7.6/type_based_tautology.sol#L2-L7) contains a tautology or contradiction:\n\t- [x >= 0](tests/detectors/tautology/0.7.6/type_based_tautology.sol#L3)\n", + "first_markdown_element": "tests/detectors/tautology/0.7.6/type_based_tautology.sol#L2-L7", + "id": "e444c1c7287bff97cae3505472d10d8ef5e01aa1f2e7660c81a3beb11eeaea0e", + "check": "tautology", + "impact": "Medium", + "confidence": "High" + }, + { + "elements": [ + { + "type": "function", + "name": "g", + "source_mapping": { + "start": 150, + "length": 80, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "g(uint8)" + } + }, + { + "type": "node", + "name": "(y < 512)", + "source_mapping": { + "start": 202, + "length": 16, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 10 + ], + "starting_column": 9, + "ending_column": 25 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "g", + "source_mapping": { + "start": 150, + "length": 80, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 2, + "ending_column": 3 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 0, + "length": 232, + "filename_used": "/GENERIC_PATH", + "filename_relative": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "filename_absolute": "/GENERIC_PATH", + "filename_short": "tests/detectors/tautology/0.7.6/type_based_tautology.sol", + "is_dependency": false, + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 1, + "ending_column": 0 + } + }, + "signature": "g(uint8)" + } + } + } + } + ], + "description": "A.g(uint8) (tests/detectors/tautology/0.7.6/type_based_tautology.sol#9-11) contains a tautology or contradiction:\n\t- (y < 512) (tests/detectors/tautology/0.7.6/type_based_tautology.sol#10)\n", + "markdown": "[A.g(uint8)](tests/detectors/tautology/0.7.6/type_based_tautology.sol#L9-L11) contains a tautology or contradiction:\n\t- [(y < 512)](tests/detectors/tautology/0.7.6/type_based_tautology.sol#L10)\n", + "first_markdown_element": "tests/detectors/tautology/0.7.6/type_based_tautology.sol#L9-L11", + "id": "036b1ecab6ee0dcb07806dbd8ffb05abf29941bbbcbb161da0013b31be51b3de", + "check": "tautology", + "impact": "Medium", + "confidence": "High" + } + ] +] \ No newline at end of file diff --git a/tests/test_detectors.py b/tests/test_detectors.py index c01594f5f..7aea45bbe 100644 --- a/tests/test_detectors.py +++ b/tests/test_detectors.py @@ -1217,6 +1217,122 @@ ALL_TEST_OBJECTS = [ "write-after-write.sol", "0.8.0", ), + Test( + all_detectors.ShiftParameterMixup, + "shift_parameter_mixup.sol", + "0.4.25", + ), + Test( + all_detectors.ShiftParameterMixup, + "shift_parameter_mixup.sol", + "0.5.16", + ), + Test( + all_detectors.ShiftParameterMixup, + "shift_parameter_mixup.sol", + "0.6.11", + ), + Test( + all_detectors.ShiftParameterMixup, + "shift_parameter_mixup.sol", + "0.7.6", + ), + Test( + all_detectors.MissingInheritance, + "unimplemented_interface.sol", + "0.4.25", + ), + Test( + all_detectors.MissingInheritance, + "unimplemented_interface.sol", + "0.5.16", + ), + Test( + all_detectors.MissingInheritance, + "unimplemented_interface.sol", + "0.6.11", + ), + Test( + all_detectors.MissingInheritance, + "unimplemented_interface.sol", + "0.7.6", + ), + # Does not work on the CI. Most likely because of solc 0.4.2? + # Test( + # all_detectors.EnumConversion, + # "enum_conversion.sol", + # "0.4.2", + # ), + Test( + all_detectors.MultipleConstructorSchemes, + "multiple_constructor_schemes.sol", + "0.4.22", + ), + Test( + all_detectors.DeprecatedStandards, + "deprecated_calls.sol", + "0.4.25", + ), + Test( + all_detectors.DivideBeforeMultiply, + "divide_before_multiply.sol", + "0.4.25", + ), + Test( + all_detectors.DivideBeforeMultiply, + "divide_before_multiply.sol", + "0.5.16", + ), + Test( + all_detectors.DivideBeforeMultiply, + "divide_before_multiply.sol", + "0.6.11", + ), + Test( + all_detectors.DivideBeforeMultiply, + "divide_before_multiply.sol", + "0.7.6", + ), + Test( + all_detectors.TypeBasedTautology, + "type_based_tautology.sol", + "0.4.25", + ), + Test( + all_detectors.TypeBasedTautology, + "type_based_tautology.sol", + "0.5.16", + ), + Test( + all_detectors.TypeBasedTautology, + "type_based_tautology.sol", + "0.6.11", + ), + Test( + all_detectors.TypeBasedTautology, + "type_based_tautology.sol", + "0.7.6", + ), + Test( + all_detectors.SimilarVarsDetection, + "similar_variables.sol", + "0.4.25", + ), + Test( + all_detectors.SimilarVarsDetection, + "similar_variables.sol", + "0.5.16", + ), + Test( + all_detectors.SimilarVarsDetection, + "similar_variables.sol", + "0.6.11", + ), + Test( + all_detectors.SimilarVarsDetection, + "similar_variables.sol", + "0.7.6", + ), Test( all_detectors.MsgValueInLoop, "msg_value_loop.sol",