mirror of https://github.com/crytic/slither
commit
c449d99f22
@ -0,0 +1,96 @@ |
||||
""" |
||||
Detect incorrect erc721 interface. |
||||
""" |
||||
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification |
||||
|
||||
|
||||
class IncorrectERC721InterfaceDetection(AbstractDetector): |
||||
""" |
||||
Incorrect ERC721 Interface |
||||
""" |
||||
|
||||
ARGUMENT = 'erc721-interface' |
||||
HELP = 'Incorrect ERC721 interfaces' |
||||
IMPACT = DetectorClassification.MEDIUM |
||||
CONFIDENCE = DetectorClassification.HIGH |
||||
|
||||
WIKI = 'https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-erc721-interface' |
||||
|
||||
WIKI_TITLE = 'Incorrect erc721 interface' |
||||
WIKI_DESCRIPTION = 'Incorrect return values for ERC721 functions. A contract compiled with solidity > 0.4.22 interacting with these functions will fail to execute them, as the return value is missing.' |
||||
WIKI_EXPLOIT_SCENARIO = ''' |
||||
```solidity |
||||
contract Token{ |
||||
function ownerOf(uint256 _tokenId) external view returns (bool); |
||||
//... |
||||
} |
||||
``` |
||||
`Token.ownerOf` does not return an address as ERC721 expects. Bob deploys the token. Alice creates a contract that interacts with it but assumes a correct ERC721 interface implementation. Alice's contract is unable to interact with Bob's contract.''' |
||||
|
||||
WIKI_RECOMMENDATION = 'Set the appropriate return values and value-types for the defined ERC721 functions.' |
||||
|
||||
@staticmethod |
||||
def incorrect_erc721_interface(signature): |
||||
(name, parameters, returnVars) = signature |
||||
|
||||
# ERC721 |
||||
if name == 'balanceOf' and parameters == ['address'] and returnVars != ['uint256']: |
||||
return True |
||||
if name == 'ownerOf' and parameters == ['uint256'] and returnVars != ['address']: |
||||
return True |
||||
if name == 'safeTransferFrom' and parameters == ['address', 'address', 'uint256', 'bytes'] and returnVars != []: |
||||
return True |
||||
if name == 'safeTransferFrom' and parameters == ['address', 'address', 'uint256'] and returnVars != []: |
||||
return True |
||||
if name == 'transferFrom' and parameters == ['address', 'address', 'uint256'] and returnVars != []: |
||||
return True |
||||
if name == 'approve' and parameters == ['address', 'uint256'] and returnVars != []: |
||||
return True |
||||
if name == 'setApprovalForAll' and parameters == ['address', 'bool'] and returnVars != []: |
||||
return True |
||||
if name == 'getApproved' and parameters == ['uint256'] and returnVars != ['address']: |
||||
return True |
||||
if name == 'isApprovedForAll' and parameters == ['address', 'address'] and returnVars != ['bool']: |
||||
return True |
||||
|
||||
# ERC165 (dependency) |
||||
if name == 'supportsInterface' and parameters == ['bytes4'] and returnVars != ['bool']: |
||||
return True |
||||
|
||||
return False |
||||
|
||||
@staticmethod |
||||
def detect_incorrect_erc721_interface(contract): |
||||
""" Detect incorrect ERC721 interface |
||||
|
||||
Returns: |
||||
list(str) : list of incorrect function signatures |
||||
""" |
||||
|
||||
# Verify this is an ERC721 contract. |
||||
if not contract.has_an_erc721_function() or not contract.has_an_erc20_function(): |
||||
return [] |
||||
|
||||
functions = [f for f in contract.functions if IncorrectERC721InterfaceDetection.incorrect_erc721_interface(f.signature)] |
||||
return functions |
||||
|
||||
def _detect(self): |
||||
""" Detect incorrect erc721 interface |
||||
|
||||
Returns: |
||||
dict: [contract name] = set(str) events |
||||
""" |
||||
results = [] |
||||
for c in self.contracts: |
||||
functions = IncorrectERC721InterfaceDetection.detect_incorrect_erc721_interface(c) |
||||
if functions: |
||||
info = "{} ({}) has incorrect ERC721 function interface(s):\n" |
||||
info = info.format(c.name, |
||||
c.source_mapping_str) |
||||
for function in functions: |
||||
info += "\t-{} ({})\n".format(function.name, function.source_mapping_str) |
||||
json = self.generate_json_result(info) |
||||
self.add_functions_to_json(functions, json) |
||||
results.append(json) |
||||
|
||||
return results |
@ -0,0 +1,80 @@ |
||||
""" |
||||
Module detecting numbers with too many digits. |
||||
""" |
||||
|
||||
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification |
||||
from slither.slithir.variables import Constant |
||||
|
||||
class TooManyDigits(AbstractDetector): |
||||
""" |
||||
Detect numbers with too many digits |
||||
""" |
||||
|
||||
ARGUMENT = 'too-many-digits' |
||||
HELP = 'Conformance to numeric notation best practices' |
||||
IMPACT = DetectorClassification.INFORMATIONAL |
||||
CONFIDENCE = DetectorClassification.MEDIUM |
||||
|
||||
WIKI = 'https://github.com/crytic/slither/wiki/Detector-Documentation#too-many-digits' |
||||
WIKI_TITLE = 'Too many digits' |
||||
WIKI_DESCRIPTION = ''' |
||||
Literals with many digits are difficult to read and review. |
||||
''' |
||||
WIKI_EXPLOIT_SCENARIO = ''' |
||||
```solidity |
||||
contract MyContract{ |
||||
uint 1_ether = 10000000000000000000; |
||||
} |
||||
``` |
||||
|
||||
While `1_ether` looks like `1 ether`, it is `10 ether`. As a result, its usage is likely to be incorrect. |
||||
''' |
||||
WIKI_RECOMMENDATION = ''' |
||||
Use: |
||||
- [Ether suffix](https://solidity.readthedocs.io/en/latest/units-and-global-variables.html#ether-units) |
||||
- [Time suffix](https://solidity.readthedocs.io/en/latest/units-and-global-variables.html#time-units), or |
||||
- [The scientific notation](https://solidity.readthedocs.io/en/latest/types.html#rational-and-integer-literals) |
||||
''' |
||||
|
||||
@staticmethod |
||||
def _detect_too_many_digits(f): |
||||
ret = [] |
||||
for node in f.nodes: |
||||
# each node contains a list of IR instruction |
||||
for ir in node.irs: |
||||
# iterate over all the variables read by the IR |
||||
for read in ir.read: |
||||
# if the variable is a constant |
||||
if isinstance(read, Constant): |
||||
# read.value can return an int or a str. Convert it to str |
||||
value_as_str = read.original_value |
||||
line_of_code = str(node.expression) |
||||
if '00000' in value_as_str: |
||||
# Info to be printed |
||||
ret.append(node) |
||||
return ret |
||||
|
||||
def _detect(self): |
||||
results = [] |
||||
|
||||
# iterate over all contracts |
||||
for contract in self.slither.contracts_derived: |
||||
# iterate over all functions |
||||
for f in contract.functions: |
||||
# iterate over all the nodes |
||||
ret = self._detect_too_many_digits(f) |
||||
if ret: |
||||
info = '{}.{} ({}) uses literals with too many digits:'.format(f.contract.name, |
||||
f.name, |
||||
f.source_mapping_str) |
||||
for node in ret: |
||||
info += '\n\t- {}'.format(node.expression) |
||||
info += '\n\tUse the proper denomination (ether-unit, time-unit,' |
||||
info += 'or the scientific notation\n' |
||||
|
||||
# Add the result in result |
||||
json = self.generate_json_result(info) |
||||
self.add_nodes_to_json(ret, json) |
||||
results.append(json) |
||||
|
||||
return results |
@ -0,0 +1,31 @@ |
||||
from slither.core.solidity_types import (ArrayType, MappingType, ElementaryType) |
||||
|
||||
def _add_mapping_parameter(t, l): |
||||
while isinstance(t, MappingType): |
||||
l.append(t.type_from) |
||||
t = t.type_to |
||||
_add_array_parameter(t, l) |
||||
|
||||
def _add_array_parameter(t, l): |
||||
while isinstance(t, ArrayType): |
||||
l.append(ElementaryType('uint256')) |
||||
t = t.type |
||||
|
||||
def export_nested_types_from_variable(variable): |
||||
""" |
||||
Export the list of nested types (mapping/array) |
||||
:param variable: |
||||
:return: list(Type) |
||||
""" |
||||
l = [] |
||||
if isinstance(variable.type, MappingType): |
||||
t = variable.type |
||||
_add_mapping_parameter(t, l) |
||||
|
||||
if isinstance(variable.type, ArrayType): |
||||
v = variable |
||||
_add_array_parameter(v.type, l) |
||||
|
||||
return l |
||||
|
||||
|
@ -0,0 +1,442 @@ |
||||
[ |
||||
{ |
||||
"check": "erc721-interface", |
||||
"impact": "Medium", |
||||
"confidence": "High", |
||||
"description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface(s):\n\t-supportsInterface (tests/incorrect_erc721_interface.sol#4)\n\t-balanceOf (tests/incorrect_erc721_interface.sol#7)\n\t-ownerOf (tests/incorrect_erc721_interface.sol#8)\n\t-safeTransferFrom (tests/incorrect_erc721_interface.sol#9)\n\t-safeTransferFrom (tests/incorrect_erc721_interface.sol#10)\n\t-transferFrom (tests/incorrect_erc721_interface.sol#11)\n\t-approve (tests/incorrect_erc721_interface.sol#12)\n\t-setApprovalForAll (tests/incorrect_erc721_interface.sol#13)\n\t-getApproved (tests/incorrect_erc721_interface.sol#14)\n\t-isApprovedForAll (tests/incorrect_erc721_interface.sol#15)\n", |
||||
"elements": [ |
||||
{ |
||||
"type": "function", |
||||
"name": "approve", |
||||
"source_mapping": { |
||||
"start": 549, |
||||
"length": 78, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
12 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 83 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "Token", |
||||
"source_mapping": { |
||||
"start": 109, |
||||
"length": 739, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
6, |
||||
7, |
||||
8, |
||||
9, |
||||
10, |
||||
11, |
||||
12, |
||||
13, |
||||
14, |
||||
15, |
||||
16 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
"type": "function", |
||||
"name": "balanceOf", |
||||
"source_mapping": { |
||||
"start": 140, |
||||
"length": 44, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
7 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 49 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "Token", |
||||
"source_mapping": { |
||||
"start": 109, |
||||
"length": 739, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
6, |
||||
7, |
||||
8, |
||||
9, |
||||
10, |
||||
11, |
||||
12, |
||||
13, |
||||
14, |
||||
15, |
||||
16 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
"type": "function", |
||||
"name": "getApproved", |
||||
"source_mapping": { |
||||
"start": 723, |
||||
"length": 48, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
14 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 53 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "Token", |
||||
"source_mapping": { |
||||
"start": 109, |
||||
"length": 739, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
6, |
||||
7, |
||||
8, |
||||
9, |
||||
10, |
||||
11, |
||||
12, |
||||
13, |
||||
14, |
||||
15, |
||||
16 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
"type": "function", |
||||
"name": "isApprovedForAll", |
||||
"source_mapping": { |
||||
"start": 776, |
||||
"length": 70, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
15 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 75 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "Token", |
||||
"source_mapping": { |
||||
"start": 109, |
||||
"length": 739, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
6, |
||||
7, |
||||
8, |
||||
9, |
||||
10, |
||||
11, |
||||
12, |
||||
13, |
||||
14, |
||||
15, |
||||
16 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
"type": "function", |
||||
"name": "ownerOf", |
||||
"source_mapping": { |
||||
"start": 189, |
||||
"length": 44, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
8 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 49 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "Token", |
||||
"source_mapping": { |
||||
"start": 109, |
||||
"length": 739, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
6, |
||||
7, |
||||
8, |
||||
9, |
||||
10, |
||||
11, |
||||
12, |
||||
13, |
||||
14, |
||||
15, |
||||
16 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
"type": "function", |
||||
"name": "safeTransferFrom", |
||||
"source_mapping": { |
||||
"start": 238, |
||||
"length": 108, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
9 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 113 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "Token", |
||||
"source_mapping": { |
||||
"start": 109, |
||||
"length": 739, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
6, |
||||
7, |
||||
8, |
||||
9, |
||||
10, |
||||
11, |
||||
12, |
||||
13, |
||||
14, |
||||
15, |
||||
16 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
"type": "function", |
||||
"name": "safeTransferFrom", |
||||
"source_mapping": { |
||||
"start": 351, |
||||
"length": 96, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
10 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 101 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "Token", |
||||
"source_mapping": { |
||||
"start": 109, |
||||
"length": 739, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
6, |
||||
7, |
||||
8, |
||||
9, |
||||
10, |
||||
11, |
||||
12, |
||||
13, |
||||
14, |
||||
15, |
||||
16 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
"type": "function", |
||||
"name": "setApprovalForAll", |
||||
"source_mapping": { |
||||
"start": 632, |
||||
"length": 86, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
13 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 91 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "Token", |
||||
"source_mapping": { |
||||
"start": 109, |
||||
"length": 739, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
6, |
||||
7, |
||||
8, |
||||
9, |
||||
10, |
||||
11, |
||||
12, |
||||
13, |
||||
14, |
||||
15, |
||||
16 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
"type": "function", |
||||
"name": "supportsInterface", |
||||
"source_mapping": { |
||||
"start": 50, |
||||
"length": 56, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
4 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 61 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "IERC165", |
||||
"source_mapping": { |
||||
"start": 26, |
||||
"length": 82, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
3, |
||||
4, |
||||
5 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
"type": "function", |
||||
"name": "transferFrom", |
||||
"source_mapping": { |
||||
"start": 452, |
||||
"length": 92, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
11 |
||||
], |
||||
"starting_column": 5, |
||||
"ending_column": 97 |
||||
}, |
||||
"contract": { |
||||
"type": "contract", |
||||
"name": "Token", |
||||
"source_mapping": { |
||||
"start": 109, |
||||
"length": 739, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_relative": "tests/incorrect_erc721_interface.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", |
||||
"filename_short": "tests/incorrect_erc721_interface.sol", |
||||
"lines": [ |
||||
6, |
||||
7, |
||||
8, |
||||
9, |
||||
10, |
||||
11, |
||||
12, |
||||
13, |
||||
14, |
||||
15, |
||||
16 |
||||
], |
||||
"starting_column": 1, |
||||
"ending_column": 2 |
||||
} |
||||
} |
||||
} |
||||
] |
||||
} |
||||
] |
@ -0,0 +1,196 @@ |
||||
[ |
||||
{ |
||||
"check": "too-many-digits", |
||||
"impact": "Informational", |
||||
"confidence": "Medium", |
||||
"description": "C.f (tests/too_many_digits.sol#9-15) uses literals with too many digits:\n\t- x1 = 0x000001\n\t- x2 = 0x0000000000001\n\t- x3 = 1000000000000000000\n\t- x4 = 100000\n\tUse the proper denomination (ether-unit, time-unit,or the scientific notation\n", |
||||
"elements": [ |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x1 = 0x000001", |
||||
"source_mapping": { |
||||
"start": 206, |
||||
"length": 18, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
10 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 27 |
||||
} |
||||
}, |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x2 = 0x0000000000001", |
||||
"source_mapping": { |
||||
"start": 234, |
||||
"length": 25, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
11 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 34 |
||||
} |
||||
}, |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x3 = 1000000000000000000", |
||||
"source_mapping": { |
||||
"start": 269, |
||||
"length": 29, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
12 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 38 |
||||
} |
||||
}, |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x4 = 100000", |
||||
"source_mapping": { |
||||
"start": 308, |
||||
"length": 16, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
13 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 25 |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
"check": "too-many-digits", |
||||
"impact": "Informational", |
||||
"confidence": "Medium", |
||||
"description": "C.h (tests/too_many_digits.sol#20-24) uses literals with too many digits:\n\t- x2 = 100000\n\tUse the proper denomination (ether-unit, time-unit,or the scientific notation\n", |
||||
"elements": [ |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x2 = 100000", |
||||
"source_mapping": { |
||||
"start": 509, |
||||
"length": 16, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
22 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 25 |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
"check": "too-many-digits", |
||||
"impact": "Informational", |
||||
"confidence": "Medium", |
||||
"description": "C.i (tests/too_many_digits.sol#29-33) uses literals with too many digits:\n\t- x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000\n\t- x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000\n\t- x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000\n\t- x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000\n\t- x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000\n\tUse the proper denomination (ether-unit, time-unit,or the scientific notation\n", |
||||
"elements": [ |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000", |
||||
"source_mapping": { |
||||
"start": 749, |
||||
"length": 67, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
31 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 76 |
||||
} |
||||
}, |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000", |
||||
"source_mapping": { |
||||
"start": 749, |
||||
"length": 67, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
31 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 76 |
||||
} |
||||
}, |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000", |
||||
"source_mapping": { |
||||
"start": 749, |
||||
"length": 67, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
31 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 76 |
||||
} |
||||
}, |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000", |
||||
"source_mapping": { |
||||
"start": 749, |
||||
"length": 67, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
31 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 76 |
||||
} |
||||
}, |
||||
{ |
||||
"type": "expression", |
||||
"expression": "x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000", |
||||
"source_mapping": { |
||||
"start": 749, |
||||
"length": 67, |
||||
"filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_relative": "tests/too_many_digits.sol", |
||||
"filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", |
||||
"filename_short": "tests/too_many_digits.sol", |
||||
"lines": [ |
||||
31 |
||||
], |
||||
"starting_column": 9, |
||||
"ending_column": 76 |
||||
} |
||||
} |
||||
] |
||||
} |
||||
] |
@ -1,7 +1,10 @@ |
||||
pragma solidity ^0.4.24; |
||||
|
||||
contract Token{ |
||||
|
||||
function transfer(address to, uint value) external; |
||||
|
||||
function approve(address spender, uint value) external; |
||||
function transferFrom(address from, address to, uint value) external; |
||||
function totalSupply() external; |
||||
function balanceOf(address who) external; |
||||
function allowance(address owner, address spender) external; |
||||
} |
||||
|
@ -0,0 +1,16 @@ |
||||
pragma solidity ^0.4.24; |
||||
|
||||
interface IERC165 { |
||||
function supportsInterface(bytes4 interfaceID) external; |
||||
} |
||||
contract Token is IERC165{ |
||||
function balanceOf(address _owner) external; |
||||
function ownerOf(uint256 _tokenId) external; |
||||
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external returns (bool); |
||||
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external returns (bool); |
||||
function transferFrom(address _from, address _to, uint256 _tokenId) external returns (bool); |
||||
function approve(address _approved, uint256 _tokenId) external returns (bool); |
||||
function setApprovalForAll(address _operator, bool _approved) external returns (bool); |
||||
function getApproved(uint256 _tokenId) external; |
||||
function isApprovedForAll(address _owner, address _operator) external; |
||||
} |
@ -0,0 +1,35 @@ |
||||
pragma solidity ^0.5.1; |
||||
|
||||
contract C { |
||||
uint balance; |
||||
|
||||
/** |
||||
* @dev Variables are not Ok - using too many digits in place of the Ether denomination. |
||||
*/ |
||||
function f() external { |
||||
uint x1 = 0x000001; |
||||
uint x2 = 0x0000000000001; |
||||
uint x3 = 1000000000000000000; |
||||
uint x4 = 100000; |
||||
balance += x1 + x2 + x3 + x4; |
||||
} |
||||
|
||||
/** |
||||
* @dev Variables are Ok - not using too many digits. |
||||
*/ |
||||
function h() external { |
||||
uint x1 = 1000; |
||||
uint x2 = 100000; |
||||
balance += x1 + x2 + 100; |
||||
} |
||||
|
||||
/** |
||||
* @dev Variables are Ok - Using Ether denominations. |
||||
*/ |
||||
function i() external { |
||||
uint x1 = 1 wei + 10 wei + 100 wei + 1000 wei + 10000 wei; |
||||
uint x2 = 1 szabo + 10 szabo + 100 szabo + 1000 szabo + 10000 szabo; |
||||
balance += x1 + x2; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue