Merge branch 'dev' of github.com:htadashi/slither into htadashi-dev

pull/1318/head
Josselin Feist 2 years ago
commit 9a1e63ef0c
  1. 43
      slither/detectors/functions/external_function.py
  2. 341
      tests/detectors/external-function/0.4.25/external_function.sol.0.4.25.ExternalFunction.json
  3. 11
      tests/detectors/external-function/0.4.25/external_function_3.sol
  4. 187
      tests/detectors/external-function/0.4.25/external_function_3.sol.0.4.25.ExternalFunction.json
  5. 341
      tests/detectors/external-function/0.5.16/external_function.sol.0.5.16.ExternalFunction.json
  6. 20
      tests/detectors/external-function/0.5.16/external_function_3.sol
  7. 276
      tests/detectors/external-function/0.5.16/external_function_3.sol.0.5.16.ExternalFunction.json
  8. 341
      tests/detectors/external-function/0.6.11/external_function.sol.0.6.11.ExternalFunction.json
  9. 19
      tests/detectors/external-function/0.6.11/external_function_3.sol
  10. 3
      tests/detectors/external-function/0.6.11/external_function_3.sol.0.6.11.ExternalFunction.json
  11. 341
      tests/detectors/external-function/0.7.6/external_function.sol.0.7.6.ExternalFunction.json
  12. 19
      tests/detectors/external-function/0.7.6/external_function_3.sol
  13. 3
      tests/detectors/external-function/0.7.6/external_function_3.sol.0.7.6.ExternalFunction.json
  14. 20
      tests/test_detectors.py

@ -1,3 +1,6 @@
from slither.core.solidity_types.array_type import ArrayType
from slither.core.declarations.structure import Structure
from slither.core.solidity_types.user_defined_type import UserDefinedType
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.slithir.operations import SolidityCall
from slither.slithir.operations import InternalCall, InternalDynamicCall
@ -20,10 +23,8 @@ class ExternalFunction(AbstractDetector):
WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#public-function-that-could-be-declared-external"
WIKI_TITLE = "Public function that could be declared external"
WIKI_DESCRIPTION = "`public` functions that are never called by the contract should be declared `external` to save gas."
WIKI_RECOMMENDATION = (
"Use the `external` attribute for functions never called from the contract."
)
WIKI_DESCRIPTION = "`public` functions that are never called by the contract should be declared `external`, and its immutable parameters should be located in `calldata` to save gas."
WIKI_RECOMMENDATION = "Use the `external` attribute for functions never called from the contract, and change the location of immutable parameters to `calldata` to save gas."
@staticmethod
def detect_functions_called(contract):
@ -105,9 +106,29 @@ class ExternalFunction(AbstractDetector):
def function_parameters_written(function):
return any(p in function.variables_written for p in function.parameters)
@staticmethod
def is_reference_type(parameter):
if isinstance(parameter.type, ArrayType):
return True
if isinstance(parameter.type, UserDefinedType) and isinstance(
parameter.type.type, Structure
):
return True
if str(parameter.type) in ["bytes", "string"]:
return True
return False
def _detect(self): # pylint: disable=too-many-locals,too-many-branches
results = []
# After solc 0.6.9, calldata arguments are allowed in public functions
if self.compilation_unit.solc_version >= "0.7." or self.compilation_unit.solc_version in [
"0.6.9",
"0.6.10",
"0.6.11",
]:
return results
# Create a set to track contracts with dynamic calls. All contracts with dynamic calls could potentially be
# calling functions internally, and thus we can't assume any function in such contracts isn't called by them.
dynamic_call_contracts = set()
@ -131,6 +152,14 @@ class ExternalFunction(AbstractDetector):
# Next we'll want to loop through all functions defined directly in this contract.
for function in contract.functions_declared:
# If all of the function arguments are non-reference type or calldata, we skip it.
reference_args = []
for arg in function.parameters:
if self.is_reference_type(arg) and arg.location == "memory":
reference_args.append(arg)
if len(reference_args) == 0:
continue
# If the function is a constructor, or is public, we skip it.
if function.is_constructor or function.visibility != "public":
continue
@ -203,6 +232,12 @@ class ExternalFunction(AbstractDetector):
info = [f"{function_definition.full_name} should be declared external:\n"]
info += ["\t- ", function_definition, "\n"]
if self.compilation_unit.solc_version >= "0.5.":
info += [
"Moreover, the following function parameters should change its data location:\n"
]
for reference_arg in reference_args:
info += [f"{reference_arg} location should be calldata\n"]
for other_function_definition in all_function_definitions:
info += ["\t- ", other_function_definition, "\n"]

@ -1,342 +1,3 @@
[
[
{
"elements": [
{
"type": "function",
"name": "funcNotCalled3",
"source_mapping": {
"start": 259,
"length": 41,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
13,
14,
15
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled3()"
}
}
],
"description": "funcNotCalled3() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled3() (tests/detectors/external-function/0.4.25/external_function.sol#13-15)\n",
"markdown": "funcNotCalled3() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled3()](tests/detectors/external-function/0.4.25/external_function.sol#L13-L15)\n",
"first_markdown_element": "tests/detectors/external-function/0.4.25/external_function.sol#L13-L15",
"id": "026d9a579ea0304e58c8a5174296494f4b672e4ea032f4e17504f3dac327c4e6",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled2",
"source_mapping": {
"start": 306,
"length": 41,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
17,
18,
19
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled2()"
}
}
],
"description": "funcNotCalled2() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled2() (tests/detectors/external-function/0.4.25/external_function.sol#17-19)\n",
"markdown": "funcNotCalled2() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled2()](tests/detectors/external-function/0.4.25/external_function.sol#L17-L19)\n",
"first_markdown_element": "tests/detectors/external-function/0.4.25/external_function.sol#L17-L19",
"id": "1ef1f19a92a8ab8d27df156d50dd75628ec3057b5f5eb16b7d1faa0e5c3850a0",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled",
"source_mapping": {
"start": 353,
"length": 40,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
21,
22,
23
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled()"
}
}
],
"description": "funcNotCalled() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled() (tests/detectors/external-function/0.4.25/external_function.sol#21-23)\n",
"markdown": "funcNotCalled() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled()](tests/detectors/external-function/0.4.25/external_function.sol#L21-L23)\n",
"first_markdown_element": "tests/detectors/external-function/0.4.25/external_function.sol#L21-L23",
"id": "369a2f3d071735755ff4f5bc43081fe858bbfb07eed94e5c6dda3c8daa22ba26",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "parameter_read_ok_for_external",
"source_mapping": {
"start": 1420,
"length": 81,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
74,
75,
76
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "FunctionParameterWrite",
"source_mapping": {
"start": 1381,
"length": 234,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "parameter_read_ok_for_external(uint256)"
}
}
],
"description": "parameter_read_ok_for_external(uint256) should be declared external:\n\t- FunctionParameterWrite.parameter_read_ok_for_external(uint256) (tests/detectors/external-function/0.4.25/external_function.sol#74-76)\n",
"markdown": "parameter_read_ok_for_external(uint256) should be declared external:\n\t- [FunctionParameterWrite.parameter_read_ok_for_external(uint256)](tests/detectors/external-function/0.4.25/external_function.sol#L74-L76)\n",
"first_markdown_element": "tests/detectors/external-function/0.4.25/external_function.sol#L74-L76",
"id": "3a0a42d128eff9fb04d8f7605bf2d6f7574c2cbbdffa2dcabbae66d7568ecc59",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled",
"source_mapping": {
"start": 554,
"length": 325,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
32,
33,
34,
35,
36,
37,
38,
39
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled2",
"source_mapping": {
"start": 473,
"length": 408,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function.sol",
"is_dependency": false,
"lines": [
31,
32,
33,
34,
35,
36,
37,
38,
39,
40
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled()"
}
}
],
"description": "funcNotCalled() should be declared external:\n\t- ContractWithFunctionNotCalled2.funcNotCalled() (tests/detectors/external-function/0.4.25/external_function.sol#32-39)\n",
"markdown": "funcNotCalled() should be declared external:\n\t- [ContractWithFunctionNotCalled2.funcNotCalled()](tests/detectors/external-function/0.4.25/external_function.sol#L32-L39)\n",
"first_markdown_element": "tests/detectors/external-function/0.4.25/external_function.sol#L32-L39",
"id": "80a0a3a3954cc6e314079a1d8d96d6739d521ddbcf738e63078d7f210e443562",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
}
]
[]
]

@ -0,0 +1,11 @@
contract Test {
function good(bytes x) external {}
function good2() public {}
function good3(uint256 x, uint256 y) public {}
function good4(uint256[] x, string y) external {}
function bad(bytes memory x) public {}
function bad2(uint256[] memory x) public {}
function bad3(string memory x) public {}
}

@ -0,0 +1,187 @@
[
[
{
"elements": [
{
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 239,
"length": 43,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"is_dependency": false,
"lines": [
8
],
"starting_column": 5,
"ending_column": 48
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "Test",
"source_mapping": {
"start": 0,
"length": 330,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
],
"starting_column": 1,
"ending_column": 0
}
},
"signature": "bad2(uint256[])"
}
}
],
"description": "bad2(uint256[]) should be declared external:\n\t- Test.bad2(uint256[]) (tests/detectors/external-function/0.4.25/external_function_3.sol#8)\n",
"markdown": "bad2(uint256[]) should be declared external:\n\t- [Test.bad2(uint256[])](tests/detectors/external-function/0.4.25/external_function_3.sol#L8)\n",
"first_markdown_element": "tests/detectors/external-function/0.4.25/external_function_3.sol#L8",
"id": "69068a3072d6f392073d197438688ae8e0bee7844098cfe4cc6c7d345e603678",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "bad",
"source_mapping": {
"start": 196,
"length": 38,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"is_dependency": false,
"lines": [
7
],
"starting_column": 5,
"ending_column": 43
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "Test",
"source_mapping": {
"start": 0,
"length": 330,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
],
"starting_column": 1,
"ending_column": 0
}
},
"signature": "bad(bytes)"
}
}
],
"description": "bad(bytes) should be declared external:\n\t- Test.bad(bytes) (tests/detectors/external-function/0.4.25/external_function_3.sol#7)\n",
"markdown": "bad(bytes) should be declared external:\n\t- [Test.bad(bytes)](tests/detectors/external-function/0.4.25/external_function_3.sol#L7)\n",
"first_markdown_element": "tests/detectors/external-function/0.4.25/external_function_3.sol#L7",
"id": "695915ec89adb6bfc4bf7f8eebf7993e02756da20f0b0e5a8d1dd251bf956c43",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "bad3",
"source_mapping": {
"start": 287,
"length": 40,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"is_dependency": false,
"lines": [
9
],
"starting_column": 5,
"ending_column": 45
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "Test",
"source_mapping": {
"start": 0,
"length": 330,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.4.25/external_function_3.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
],
"starting_column": 1,
"ending_column": 0
}
},
"signature": "bad3(string)"
}
}
],
"description": "bad3(string) should be declared external:\n\t- Test.bad3(string) (tests/detectors/external-function/0.4.25/external_function_3.sol#9)\n",
"markdown": "bad3(string) should be declared external:\n\t- [Test.bad3(string)](tests/detectors/external-function/0.4.25/external_function_3.sol#L9)\n",
"first_markdown_element": "tests/detectors/external-function/0.4.25/external_function_3.sol#L9",
"id": "f56b73c72461d3d9fd4e79bd3cd2649f79c425406843e5c7b2de3fad5b2f663a",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
}
]
]

@ -1,342 +1,3 @@
[
[
{
"elements": [
{
"type": "function",
"name": "funcNotCalled3",
"source_mapping": {
"start": 259,
"length": 41,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
13,
14,
15
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled3()"
}
}
],
"description": "funcNotCalled3() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled3() (tests/detectors/external-function/0.5.16/external_function.sol#13-15)\n",
"markdown": "funcNotCalled3() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled3()](tests/detectors/external-function/0.5.16/external_function.sol#L13-L15)\n",
"first_markdown_element": "tests/detectors/external-function/0.5.16/external_function.sol#L13-L15",
"id": "026d9a579ea0304e58c8a5174296494f4b672e4ea032f4e17504f3dac327c4e6",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled2",
"source_mapping": {
"start": 306,
"length": 41,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
17,
18,
19
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled2()"
}
}
],
"description": "funcNotCalled2() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled2() (tests/detectors/external-function/0.5.16/external_function.sol#17-19)\n",
"markdown": "funcNotCalled2() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled2()](tests/detectors/external-function/0.5.16/external_function.sol#L17-L19)\n",
"first_markdown_element": "tests/detectors/external-function/0.5.16/external_function.sol#L17-L19",
"id": "1ef1f19a92a8ab8d27df156d50dd75628ec3057b5f5eb16b7d1faa0e5c3850a0",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled",
"source_mapping": {
"start": 353,
"length": 40,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
21,
22,
23
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled()"
}
}
],
"description": "funcNotCalled() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled() (tests/detectors/external-function/0.5.16/external_function.sol#21-23)\n",
"markdown": "funcNotCalled() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled()](tests/detectors/external-function/0.5.16/external_function.sol#L21-L23)\n",
"first_markdown_element": "tests/detectors/external-function/0.5.16/external_function.sol#L21-L23",
"id": "369a2f3d071735755ff4f5bc43081fe858bbfb07eed94e5c6dda3c8daa22ba26",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "parameter_read_ok_for_external",
"source_mapping": {
"start": 1420,
"length": 81,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
74,
75,
76
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "FunctionParameterWrite",
"source_mapping": {
"start": 1381,
"length": 234,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "parameter_read_ok_for_external(uint256)"
}
}
],
"description": "parameter_read_ok_for_external(uint256) should be declared external:\n\t- FunctionParameterWrite.parameter_read_ok_for_external(uint256) (tests/detectors/external-function/0.5.16/external_function.sol#74-76)\n",
"markdown": "parameter_read_ok_for_external(uint256) should be declared external:\n\t- [FunctionParameterWrite.parameter_read_ok_for_external(uint256)](tests/detectors/external-function/0.5.16/external_function.sol#L74-L76)\n",
"first_markdown_element": "tests/detectors/external-function/0.5.16/external_function.sol#L74-L76",
"id": "3a0a42d128eff9fb04d8f7605bf2d6f7574c2cbbdffa2dcabbae66d7568ecc59",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled",
"source_mapping": {
"start": 554,
"length": 325,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
32,
33,
34,
35,
36,
37,
38,
39
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled2",
"source_mapping": {
"start": 473,
"length": 408,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function.sol",
"is_dependency": false,
"lines": [
31,
32,
33,
34,
35,
36,
37,
38,
39,
40
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled()"
}
}
],
"description": "funcNotCalled() should be declared external:\n\t- ContractWithFunctionNotCalled2.funcNotCalled() (tests/detectors/external-function/0.5.16/external_function.sol#32-39)\n",
"markdown": "funcNotCalled() should be declared external:\n\t- [ContractWithFunctionNotCalled2.funcNotCalled()](tests/detectors/external-function/0.5.16/external_function.sol#L32-L39)\n",
"first_markdown_element": "tests/detectors/external-function/0.5.16/external_function.sol#L32-L39",
"id": "80a0a3a3954cc6e314079a1d8d96d6739d521ddbcf738e63078d7f210e443562",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
}
]
[]
]

@ -0,0 +1,20 @@
pragma experimental ABIEncoderV2;
contract Test {
struct testStruct {
uint256 id;
string name;
}
function good(bytes calldata x) external {}
function good2() public {}
function good3(uint256 x, uint256 y) public {}
function good4(uint256[] calldata x, string calldata y) external {}
function good5(testStruct calldata x) external {}
function bad(bytes memory x) public {}
function bad2(uint256[] memory x) public {}
function bad3(testStruct memory x) public {}
function bad4(string memory x) public {}
}

@ -0,0 +1,276 @@
[
[
{
"elements": [
{
"type": "function",
"name": "bad4",
"source_mapping": {
"start": 524,
"length": 40,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"is_dependency": false,
"lines": [
18
],
"starting_column": 5,
"ending_column": 45
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "Test",
"source_mapping": {
"start": 35,
"length": 532,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"is_dependency": false,
"lines": [
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21
],
"starting_column": 1,
"ending_column": 0
}
},
"signature": "bad4(string)"
}
}
],
"description": "bad4(string) should be declared external:\n\t- Test.bad4(string) (tests/detectors/external-function/0.5.16/external_function_3.sol#18)\nMoreover, the following function parameters should change its data location:\nx location should be calldata\n",
"markdown": "bad4(string) should be declared external:\n\t- [Test.bad4(string)](tests/detectors/external-function/0.5.16/external_function_3.sol#L18)\nMoreover, the following function parameters should change its data location:\nx location should be calldata\n",
"first_markdown_element": "tests/detectors/external-function/0.5.16/external_function_3.sol#L18",
"id": "1b6de528ed7f8ecf61a543879c8bcbee1bce7e08bdef89c6f8f663937d5a7209",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "bad3",
"source_mapping": {
"start": 475,
"length": 44,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"is_dependency": false,
"lines": [
17
],
"starting_column": 5,
"ending_column": 49
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "Test",
"source_mapping": {
"start": 35,
"length": 532,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"is_dependency": false,
"lines": [
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21
],
"starting_column": 1,
"ending_column": 0
}
},
"signature": "bad3(Test.testStruct)"
}
}
],
"description": "bad3(Test.testStruct) should be declared external:\n\t- Test.bad3(Test.testStruct) (tests/detectors/external-function/0.5.16/external_function_3.sol#17)\nMoreover, the following function parameters should change its data location:\nx location should be calldata\n",
"markdown": "bad3(Test.testStruct) should be declared external:\n\t- [Test.bad3(Test.testStruct)](tests/detectors/external-function/0.5.16/external_function_3.sol#L17)\nMoreover, the following function parameters should change its data location:\nx location should be calldata\n",
"first_markdown_element": "tests/detectors/external-function/0.5.16/external_function_3.sol#L17",
"id": "a60742b3998c52eee654f61cfb5b39834d63a1b13212511a01811206ac445dd5",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 427,
"length": 43,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"is_dependency": false,
"lines": [
16
],
"starting_column": 5,
"ending_column": 48
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "Test",
"source_mapping": {
"start": 35,
"length": 532,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"is_dependency": false,
"lines": [
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21
],
"starting_column": 1,
"ending_column": 0
}
},
"signature": "bad2(uint256[])"
}
}
],
"description": "bad2(uint256[]) should be declared external:\n\t- Test.bad2(uint256[]) (tests/detectors/external-function/0.5.16/external_function_3.sol#16)\nMoreover, the following function parameters should change its data location:\nx location should be calldata\n",
"markdown": "bad2(uint256[]) should be declared external:\n\t- [Test.bad2(uint256[])](tests/detectors/external-function/0.5.16/external_function_3.sol#L16)\nMoreover, the following function parameters should change its data location:\nx location should be calldata\n",
"first_markdown_element": "tests/detectors/external-function/0.5.16/external_function_3.sol#L16",
"id": "aa4b0cae64f1a6f9f11d3f9981255fd04f37f558c960195ee46413ca4b142822",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "bad",
"source_mapping": {
"start": 384,
"length": 38,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"is_dependency": false,
"lines": [
15
],
"starting_column": 5,
"ending_column": 43
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "Test",
"source_mapping": {
"start": 35,
"length": 532,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.5.16/external_function_3.sol",
"is_dependency": false,
"lines": [
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21
],
"starting_column": 1,
"ending_column": 0
}
},
"signature": "bad(bytes)"
}
}
],
"description": "bad(bytes) should be declared external:\n\t- Test.bad(bytes) (tests/detectors/external-function/0.5.16/external_function_3.sol#15)\nMoreover, the following function parameters should change its data location:\nx location should be calldata\n",
"markdown": "bad(bytes) should be declared external:\n\t- [Test.bad(bytes)](tests/detectors/external-function/0.5.16/external_function_3.sol#L15)\nMoreover, the following function parameters should change its data location:\nx location should be calldata\n",
"first_markdown_element": "tests/detectors/external-function/0.5.16/external_function_3.sol#L15",
"id": "df1688f3d1120f9600f61accff294ba821689c45dc261f1a9b94f23e6a402367",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
}
]
]

@ -1,342 +1,3 @@
[
[
{
"elements": [
{
"type": "function",
"name": "funcNotCalled3",
"source_mapping": {
"start": 259,
"length": 41,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
13,
14,
15
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled3()"
}
}
],
"description": "funcNotCalled3() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled3() (tests/detectors/external-function/0.6.11/external_function.sol#13-15)\n",
"markdown": "funcNotCalled3() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled3()](tests/detectors/external-function/0.6.11/external_function.sol#L13-L15)\n",
"first_markdown_element": "tests/detectors/external-function/0.6.11/external_function.sol#L13-L15",
"id": "026d9a579ea0304e58c8a5174296494f4b672e4ea032f4e17504f3dac327c4e6",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled2",
"source_mapping": {
"start": 306,
"length": 41,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
17,
18,
19
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled2()"
}
}
],
"description": "funcNotCalled2() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled2() (tests/detectors/external-function/0.6.11/external_function.sol#17-19)\n",
"markdown": "funcNotCalled2() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled2()](tests/detectors/external-function/0.6.11/external_function.sol#L17-L19)\n",
"first_markdown_element": "tests/detectors/external-function/0.6.11/external_function.sol#L17-L19",
"id": "1ef1f19a92a8ab8d27df156d50dd75628ec3057b5f5eb16b7d1faa0e5c3850a0",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled",
"source_mapping": {
"start": 353,
"length": 40,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
21,
22,
23
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled()"
}
}
],
"description": "funcNotCalled() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled() (tests/detectors/external-function/0.6.11/external_function.sol#21-23)\n",
"markdown": "funcNotCalled() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled()](tests/detectors/external-function/0.6.11/external_function.sol#L21-L23)\n",
"first_markdown_element": "tests/detectors/external-function/0.6.11/external_function.sol#L21-L23",
"id": "369a2f3d071735755ff4f5bc43081fe858bbfb07eed94e5c6dda3c8daa22ba26",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "parameter_read_ok_for_external",
"source_mapping": {
"start": 1420,
"length": 81,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
74,
75,
76
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "FunctionParameterWrite",
"source_mapping": {
"start": 1381,
"length": 234,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "parameter_read_ok_for_external(uint256)"
}
}
],
"description": "parameter_read_ok_for_external(uint256) should be declared external:\n\t- FunctionParameterWrite.parameter_read_ok_for_external(uint256) (tests/detectors/external-function/0.6.11/external_function.sol#74-76)\n",
"markdown": "parameter_read_ok_for_external(uint256) should be declared external:\n\t- [FunctionParameterWrite.parameter_read_ok_for_external(uint256)](tests/detectors/external-function/0.6.11/external_function.sol#L74-L76)\n",
"first_markdown_element": "tests/detectors/external-function/0.6.11/external_function.sol#L74-L76",
"id": "3a0a42d128eff9fb04d8f7605bf2d6f7574c2cbbdffa2dcabbae66d7568ecc59",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled",
"source_mapping": {
"start": 554,
"length": 325,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
32,
33,
34,
35,
36,
37,
38,
39
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled2",
"source_mapping": {
"start": 473,
"length": 408,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.6.11/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.6.11/external_function.sol",
"is_dependency": false,
"lines": [
31,
32,
33,
34,
35,
36,
37,
38,
39,
40
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled()"
}
}
],
"description": "funcNotCalled() should be declared external:\n\t- ContractWithFunctionNotCalled2.funcNotCalled() (tests/detectors/external-function/0.6.11/external_function.sol#32-39)\n",
"markdown": "funcNotCalled() should be declared external:\n\t- [ContractWithFunctionNotCalled2.funcNotCalled()](tests/detectors/external-function/0.6.11/external_function.sol#L32-L39)\n",
"first_markdown_element": "tests/detectors/external-function/0.6.11/external_function.sol#L32-L39",
"id": "80a0a3a3954cc6e314079a1d8d96d6739d521ddbcf738e63078d7f210e443562",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
}
]
[]
]

@ -0,0 +1,19 @@
pragma experimental ABIEncoderV2;
contract Test {
struct testStruct {
uint256 id;
string name;
}
function good(bytes calldata x) external {}
function good2() public {}
function good3(uint256 x, uint256 y) public {}
function good4(uint256[] calldata x, string calldata y) external {}
function good5(testStruct calldata x) external {}
function bad(bytes memory x) public {}
function bad2(uint256[] memory x) public {}
function bad3(testStruct memory x) public {}
function bad4(string memory x) public {}
}

@ -1,342 +1,3 @@
[
[
{
"elements": [
{
"type": "function",
"name": "funcNotCalled3",
"source_mapping": {
"start": 259,
"length": 41,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
13,
14,
15
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled3()"
}
}
],
"description": "funcNotCalled3() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled3() (tests/detectors/external-function/0.7.6/external_function.sol#13-15)\n",
"markdown": "funcNotCalled3() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled3()](tests/detectors/external-function/0.7.6/external_function.sol#L13-L15)\n",
"first_markdown_element": "tests/detectors/external-function/0.7.6/external_function.sol#L13-L15",
"id": "026d9a579ea0304e58c8a5174296494f4b672e4ea032f4e17504f3dac327c4e6",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled2",
"source_mapping": {
"start": 306,
"length": 41,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
17,
18,
19
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled2()"
}
}
],
"description": "funcNotCalled2() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled2() (tests/detectors/external-function/0.7.6/external_function.sol#17-19)\n",
"markdown": "funcNotCalled2() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled2()](tests/detectors/external-function/0.7.6/external_function.sol#L17-L19)\n",
"first_markdown_element": "tests/detectors/external-function/0.7.6/external_function.sol#L17-L19",
"id": "1ef1f19a92a8ab8d27df156d50dd75628ec3057b5f5eb16b7d1faa0e5c3850a0",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled",
"source_mapping": {
"start": 353,
"length": 40,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
21,
22,
23
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled",
"source_mapping": {
"start": 213,
"length": 258,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled()"
}
}
],
"description": "funcNotCalled() should be declared external:\n\t- ContractWithFunctionNotCalled.funcNotCalled() (tests/detectors/external-function/0.7.6/external_function.sol#21-23)\n",
"markdown": "funcNotCalled() should be declared external:\n\t- [ContractWithFunctionNotCalled.funcNotCalled()](tests/detectors/external-function/0.7.6/external_function.sol#L21-L23)\n",
"first_markdown_element": "tests/detectors/external-function/0.7.6/external_function.sol#L21-L23",
"id": "369a2f3d071735755ff4f5bc43081fe858bbfb07eed94e5c6dda3c8daa22ba26",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "parameter_read_ok_for_external",
"source_mapping": {
"start": 1420,
"length": 81,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
74,
75,
76
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "FunctionParameterWrite",
"source_mapping": {
"start": 1381,
"length": 234,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "parameter_read_ok_for_external(uint256)"
}
}
],
"description": "parameter_read_ok_for_external(uint256) should be declared external:\n\t- FunctionParameterWrite.parameter_read_ok_for_external(uint256) (tests/detectors/external-function/0.7.6/external_function.sol#74-76)\n",
"markdown": "parameter_read_ok_for_external(uint256) should be declared external:\n\t- [FunctionParameterWrite.parameter_read_ok_for_external(uint256)](tests/detectors/external-function/0.7.6/external_function.sol#L74-L76)\n",
"first_markdown_element": "tests/detectors/external-function/0.7.6/external_function.sol#L74-L76",
"id": "3a0a42d128eff9fb04d8f7605bf2d6f7574c2cbbdffa2dcabbae66d7568ecc59",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
},
{
"elements": [
{
"type": "function",
"name": "funcNotCalled",
"source_mapping": {
"start": 554,
"length": 325,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
32,
33,
34,
35,
36,
37,
38,
39
],
"starting_column": 5,
"ending_column": 6
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "ContractWithFunctionNotCalled2",
"source_mapping": {
"start": 473,
"length": 408,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/external-function/0.7.6/external_function.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/external-function/0.7.6/external_function.sol",
"is_dependency": false,
"lines": [
31,
32,
33,
34,
35,
36,
37,
38,
39,
40
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "funcNotCalled()"
}
}
],
"description": "funcNotCalled() should be declared external:\n\t- ContractWithFunctionNotCalled2.funcNotCalled() (tests/detectors/external-function/0.7.6/external_function.sol#32-39)\n",
"markdown": "funcNotCalled() should be declared external:\n\t- [ContractWithFunctionNotCalled2.funcNotCalled()](tests/detectors/external-function/0.7.6/external_function.sol#L32-L39)\n",
"first_markdown_element": "tests/detectors/external-function/0.7.6/external_function.sol#L32-L39",
"id": "80a0a3a3954cc6e314079a1d8d96d6739d521ddbcf738e63078d7f210e443562",
"check": "external-function",
"impact": "Optimization",
"confidence": "High"
}
]
[]
]

@ -0,0 +1,19 @@
pragma experimental ABIEncoderV2;
contract Test {
struct testStruct {
uint256 id;
string name;
}
function good(bytes calldata x) external {}
function good2() public {}
function good3(uint256 x, uint256 y) public {}
function good4(uint256[] calldata x, string calldata y) external {}
function good5(testStruct calldata x) external {}
function bad(bytes memory x) public {}
function bad2(uint256[] memory x) public {}
function bad3(testStruct memory x) public {}
function bad4(string memory x) public {}
}

@ -510,6 +510,11 @@ ALL_TEST_OBJECTS = [
"external_function_2.sol",
"0.4.25",
),
Test(
all_detectors.ExternalFunction,
"external_function_3.sol",
"0.4.25",
),
Test(
all_detectors.ExternalFunction,
"external_function.sol",
@ -520,6 +525,11 @@ ALL_TEST_OBJECTS = [
"external_function_2.sol",
"0.5.16",
),
Test(
all_detectors.ExternalFunction,
"external_function_3.sol",
"0.5.16",
),
Test(
all_detectors.ExternalFunction,
"external_function.sol",
@ -530,6 +540,11 @@ ALL_TEST_OBJECTS = [
"external_function_2.sol",
"0.6.11",
),
Test(
all_detectors.ExternalFunction,
"external_function_3.sol",
"0.6.11",
),
Test(
all_detectors.ExternalFunction,
"external_function.sol",
@ -540,6 +555,11 @@ ALL_TEST_OBJECTS = [
"external_function_2.sol",
"0.7.6",
),
Test(
all_detectors.ExternalFunction,
"external_function_3.sol",
"0.7.6",
),
Test(
all_detectors.NamingConvention,
"naming_convention.sol",

Loading…
Cancel
Save