mirror of https://github.com/ConsenSys/mythril
parent
9b960a2985
commit
dd7b255fc9
@ -1,53 +0,0 @@ |
|||||||
import pytest |
|
||||||
from mythril.laser.ethereum.state.account import Storage |
|
||||||
from mythril.laser.smt import Expression |
|
||||||
|
|
||||||
storage_uninitialized_test_data = [({}, 1), ({1: 5}, 2), ({1: 5, 3: 10}, 2)] |
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("initial_storage,key", storage_uninitialized_test_data) |
|
||||||
def test_concrete_storage_uninitialized_index(initial_storage, key): |
|
||||||
# Arrange |
|
||||||
storage = Storage(concrete=True) |
|
||||||
storage._storage = initial_storage |
|
||||||
|
|
||||||
# Act |
|
||||||
value = storage[key] |
|
||||||
|
|
||||||
# Assert |
|
||||||
assert value == 0 |
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("initial_storage,key", storage_uninitialized_test_data) |
|
||||||
def test_symbolic_storage_uninitialized_index(initial_storage, key): |
|
||||||
# Arrange |
|
||||||
storage = Storage(concrete=False) |
|
||||||
storage._storage = initial_storage |
|
||||||
|
|
||||||
# Act |
|
||||||
value = storage[key] |
|
||||||
|
|
||||||
# Assert |
|
||||||
assert isinstance(value, Expression) |
|
||||||
|
|
||||||
|
|
||||||
def test_storage_set_item(): |
|
||||||
# Arrange |
|
||||||
storage = Storage() |
|
||||||
|
|
||||||
# Act |
|
||||||
storage[1] = 13 |
|
||||||
|
|
||||||
# Assert |
|
||||||
assert storage[1] == 13 |
|
||||||
|
|
||||||
|
|
||||||
def test_storage_change_item(): |
|
||||||
# Arrange |
|
||||||
storage = Storage() |
|
||||||
storage._storage = {1: 12} |
|
||||||
# Act |
|
||||||
storage[1] = 14 |
|
||||||
|
|
||||||
# Assert |
|
||||||
assert storage[1] == 14 |
|
@ -1,5 +1,19 @@ |
|||||||
{ |
{ |
||||||
"error": null, |
"error": null, |
||||||
"issues": [], |
"issues": [ |
||||||
|
{ |
||||||
|
"address": 498, |
||||||
|
"contract": "Unknown", |
||||||
|
"description": "The binary addition can overflow.\nThe operands of the addition operation are not sufficiently constrained. The addition could therefore result in an integer overflow. Prevent the overflow by checking inputs or ensure sure that the overflow is caught by an assertion.", |
||||||
|
"function": "sendToken(address,uint256)", |
||||||
|
"max_gas_used": 52806, |
||||||
|
"min_gas_used": 11860, |
||||||
|
"severity": "High", |
||||||
|
"sourceMap": null, |
||||||
|
"swc-id": "101", |
||||||
|
"title": "Integer Overflow", |
||||||
|
"tx_sequence": "<TX-DATA>" |
||||||
|
} |
||||||
|
], |
||||||
"success": true |
"success": true |
||||||
} |
} |
@ -1,3 +1,14 @@ |
|||||||
# Analysis results for None |
# Analysis results for test-filename.sol |
||||||
|
|
||||||
The analysis was completed successfully. No issues were detected. |
## Integer Overflow |
||||||
|
- SWC ID: 101 |
||||||
|
- Severity: High |
||||||
|
- Contract: Unknown |
||||||
|
- Function name: `sendToken(address,uint256)` |
||||||
|
- PC address: 498 |
||||||
|
- Estimated Gas Usage: 11860 - 52806 |
||||||
|
|
||||||
|
### Description |
||||||
|
|
||||||
|
The binary addition can overflow. |
||||||
|
The operands of the addition operation are not sufficiently constrained. The addition could therefore result in an integer overflow. Prevent the overflow by checking inputs or ensure sure that the overflow is caught by an assertion. |
||||||
|
@ -1 +1,11 @@ |
|||||||
The analysis was completed successfully. No issues were detected. |
==== Integer Overflow ==== |
||||||
|
SWC ID: 101 |
||||||
|
Severity: High |
||||||
|
Contract: Unknown |
||||||
|
Function name: sendToken(address,uint256) |
||||||
|
PC address: 498 |
||||||
|
Estimated Gas Usage: 11860 - 52806 |
||||||
|
The binary addition can overflow. |
||||||
|
The operands of the addition operation are not sufficiently constrained. The addition could therefore result in an integer overflow. Prevent the overflow by checking inputs or ensure sure that the overflow is caught by an assertion. |
||||||
|
-------------------- |
||||||
|
|
||||||
|
Loading…
Reference in new issue