Use proper title for integer underflow

pull/862/head
Nikhil Parasaram 6 years ago
parent 57403c185d
commit d9350d2334
  1. 8
      mythril/analysis/modules/integer.py
  2. 65
      tests/testdata/outputs_expected/overflow.sol.o.json
  3. 12
      tests/testdata/outputs_expected/overflow.sol.o.markdown
  4. 11
      tests/testdata/outputs_expected/overflow.sol.o.text
  5. 65
      tests/testdata/outputs_expected/underflow.sol.o.json
  6. 12
      tests/testdata/outputs_expected/underflow.sol.o.markdown
  7. 11
      tests/testdata/outputs_expected/underflow.sol.o.text

@ -168,13 +168,19 @@ class IntegerOverflowUnderflowModule(DetectionModule):
continue continue
ostate = annotation.overflowing_state ostate = annotation.overflowing_state
node = ostate.node node = ostate.node
title = (
"Integer Underflow"
if annotation.operator == "subtraction"
else "Integer Overflow"
)
issue = Issue( issue = Issue(
contract=node.contract_name, contract=node.contract_name,
function_name=node.function_name, function_name=node.function_name,
address=ostate.get_current_instruction()["address"], address=ostate.get_current_instruction()["address"],
swc_id=INTEGER_OVERFLOW_AND_UNDERFLOW, swc_id=INTEGER_OVERFLOW_AND_UNDERFLOW,
bytecode=ostate.environment.code.bytecode, bytecode=ostate.environment.code.bytecode,
title="Integer Overflow", title=title,
_type="Warning", _type="Warning",
gas_used=(state.mstate.min_gas_used, state.mstate.max_gas_used), gas_used=(state.mstate.min_gas_used, state.mstate.max_gas_used),
) )

@ -1,42 +1,27 @@
{ {
"error":null, "error": null,
"issues":[ "issues": [{
{ "address": 567,
"address":567, "contract": "Unknown",
"contract":"Unknown", "debug": "<DEBUG-DATA>",
"debug":"<DEBUG-DATA>", "description": "This binary subtraction operation can result in integer underflow.\n",
"description":"This binary subtraction operation can result in integer overflow.\n", "function": "sendeth(address,uint256)",
"function":"sendeth(address,uint256)", "max_gas_used": 1774,
"max_gas_used":1053, "min_gas_used": 1299,
"min_gas_used":768, "swc-id": "101",
"swc-id":"101", "title": "Integer Underflow",
"title":"Integer Overflow", "type": "Warning"
"type":"Warning" }, {
}, "address": 649,
{ "contract": "Unknown",
"address":567, "debug": "<DEBUG-DATA>",
"contract":"Unknown", "description": "This binary subtraction operation can result in integer underflow.\n",
"debug":"<DEBUG-DATA>", "function": "sendeth(address,uint256)",
"description":"This binary subtraction operation can result in integer underflow.\n", "max_gas_used": 1774,
"function":"sendeth(address,uint256)", "min_gas_used": 1299,
"max_gas_used":1774, "swc-id": "101",
"min_gas_used":1299, "title": "Integer Underflow",
"swc-id":"101", "type": "Warning"
"title":"Integer Underflow", }],
"type":"Warning" "success": true
},
{
"address":649,
"contract":"Unknown",
"debug":"<DEBUG-DATA>",
"description":"This binary subtraction operation can result in integer underflow.\n",
"function":"sendeth(address,uint256)",
"max_gas_used":1774,
"min_gas_used":1299,
"swc-id":"101",
"title":"Integer Underflow",
"type":"Warning"
}
],
"success":true
} }

@ -1,17 +1,5 @@
# Analysis results for test-filename.sol # Analysis results for test-filename.sol
## Integer Overflow
- SWC ID: 101
- Type: Warning
- Contract: Unknown
- Function name: `sendeth(address,uint256)`
- PC address: 567
- Estimated Gas Usage: 768 - 1053
### Description
This binary subtraction operation can result in integer overflow.
## Integer Underflow ## Integer Underflow
- SWC ID: 101 - SWC ID: 101
- Type: Warning - Type: Warning

@ -1,14 +1,3 @@
==== Integer Overflow ====
SWC ID: 101
Type: Warning
Contract: Unknown
Function name: sendeth(address,uint256)
PC address: 567
Estimated Gas Usage: 768 - 1053
This binary subtraction operation can result in integer overflow.
--------------------
==== Integer Underflow ==== ==== Integer Underflow ====
SWC ID: 101 SWC ID: 101
Type: Warning Type: Warning

@ -1,42 +1,27 @@
{ {
"error":null, "error": null,
"issues":[ "issues": [{
{ "address": 567,
"address":567, "contract": "Unknown",
"contract":"Unknown", "debug": "<DEBUG-DATA>",
"debug":"<DEBUG-DATA>", "description": "This binary subtraction operation can result in integer underflow.\n",
"description":"This binary subtraction operation can result in integer overflow.\n", "function": "sendeth(address,uint256)",
"function":"sendeth(address,uint256)", "max_gas_used": 1774,
"max_gas_used":1053, "min_gas_used": 1299,
"min_gas_used":768, "swc-id": "101",
"swc-id":"101", "title": "Integer Underflow",
"title":"Integer Overflow", "type": "Warning"
"type":"Warning" }, {
}, "address": 649,
{ "contract": "Unknown",
"address":567, "debug": "<DEBUG-DATA>",
"contract":"Unknown", "description": "This binary subtraction operation can result in integer underflow.\n",
"debug":"<DEBUG-DATA>", "function": "sendeth(address,uint256)",
"description":"This binary subtraction operation can result in integer underflow.\n", "max_gas_used": 1774,
"function":"sendeth(address,uint256)", "min_gas_used": 1299,
"max_gas_used":1774, "swc-id": "101",
"min_gas_used":1299, "title": "Integer Underflow",
"swc-id":"101", "type": "Warning"
"title":"Integer Underflow", }],
"type":"Warning" "success": true
},
{
"address":649,
"contract":"Unknown",
"debug":"<DEBUG-DATA>",
"description":"This binary subtraction operation can result in integer underflow.\n",
"function":"sendeth(address,uint256)",
"max_gas_used":1774,
"min_gas_used":1299,
"swc-id":"101",
"title":"Integer Underflow",
"type":"Warning"
}
],
"success":true
} }

@ -1,17 +1,5 @@
# Analysis results for test-filename.sol # Analysis results for test-filename.sol
## Integer Overflow
- SWC ID: 101
- Type: Warning
- Contract: Unknown
- Function name: `sendeth(address,uint256)`
- PC address: 567
- Estimated Gas Usage: 768 - 1053
### Description
This binary subtraction operation can result in integer overflow.
## Integer Underflow ## Integer Underflow
- SWC ID: 101 - SWC ID: 101
- Type: Warning - Type: Warning

@ -1,14 +1,3 @@
==== Integer Overflow ====
SWC ID: 101
Type: Warning
Contract: Unknown
Function name: sendeth(address,uint256)
PC address: 567
Estimated Gas Usage: 768 - 1053
This binary subtraction operation can result in integer overflow.
--------------------
==== Integer Underflow ==== ==== Integer Underflow ====
SWC ID: 101 SWC ID: 101
Type: Warning Type: Warning

Loading…
Cancel
Save