From 9fe0964f3548954116bf7388b2f2caa2d24a31aa Mon Sep 17 00:00:00 2001 From: Joran Honig Date: Sun, 28 Oct 2018 16:58:47 +0100 Subject: [PATCH] merge fixes --- mythril/analysis/report.py | 2 +- mythril/disassembler/asm.py | 2 +- mythril/disassembler/disassembly.py | 5 +++-- requirements.txt | 1 + tests/testdata/outputs_expected/overflow.sol.o.json | 2 +- tests/testdata/outputs_expected/overflow.sol.o.markdown | 4 ++-- tests/testdata/outputs_expected/overflow.sol.o.text | 4 ++-- tests/testdata/outputs_expected/underflow.sol.o.json | 2 +- tests/testdata/outputs_expected/underflow.sol.o.markdown | 4 ++-- tests/testdata/outputs_expected/underflow.sol.o.text | 4 ++-- 10 files changed, 16 insertions(+), 14 deletions(-) diff --git a/mythril/analysis/report.py b/mythril/analysis/report.py index 5d79bcf9..91bf7674 100644 --- a/mythril/analysis/report.py +++ b/mythril/analysis/report.py @@ -2,7 +2,7 @@ import logging import json import operator from jinja2 import PackageLoader, Environment -import sha3 +import _pysha3 as sha3 import hashlib class Issue: diff --git a/mythril/disassembler/asm.py b/mythril/disassembler/asm.py index 762d1251..2f447eb2 100644 --- a/mythril/disassembler/asm.py +++ b/mythril/disassembler/asm.py @@ -23,7 +23,7 @@ class EvmInstruction: return result -def instruction_list_to_easm(instruction_list: dict) -> str: +def instruction_list_to_easm(instruction_list: list) -> str: result = "" for instruction in instruction_list: diff --git a/mythril/disassembler/disassembly.py b/mythril/disassembler/disassembly.py index d86d32e5..507cf452 100644 --- a/mythril/disassembler/disassembly.py +++ b/mythril/disassembler/disassembly.py @@ -1,4 +1,5 @@ -from mythril.ether import asm, util +from mythril.ether import util +from mythril.disassembler import asm from mythril.support.signatures import SignatureDb import logging @@ -33,7 +34,7 @@ class Disassembly(object): ) # Need to take from PUSH1 to PUSH4 because solc seems to remove excess 0s at the beginning for optimizing - jump_table_indices = asm.find_opcode_sequence( + jump_table_indices = asm.find_op_code_sequence( [("PUSH1", "PUSH2", "PUSH3", "PUSH4"), ("EQ",)], self.instruction_list ) diff --git a/requirements.txt b/requirements.txt index b41daf56..d829a885 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,3 +25,4 @@ requests rlp>=1.0.1 transaction>=2.2.1 z3-solver>=4.5 +pysha3 diff --git a/tests/testdata/outputs_expected/overflow.sol.o.json b/tests/testdata/outputs_expected/overflow.sol.o.json index d794122d..fb92acaf 100644 --- a/tests/testdata/outputs_expected/overflow.sol.o.json +++ b/tests/testdata/outputs_expected/overflow.sol.o.json @@ -1 +1 @@ -{"error": null, "issues": [{"address": 567, "contract": "Unknown", "debug": "", "description": "The subtraction can result in an integer underflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Underflow", "type": "Warning"}, {"address": 649, "contract": "Unknown", "debug": "", "description": "The subtraction can result in an integer underflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Underflow", "type": "Warning"}, {"address": 725, "contract": "Unknown", "debug": "", "description": "The arithmetic operation can result in integer overflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Overflow", "type": "Warning"}], "success": true} +{"error": null, "issues": [{"address": 567, "contract": "Unknown", "debug": "", "description": "The substraction can result in an integer underflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Underflow", "type": "Warning"}, {"address": 649, "contract": "Unknown", "debug": "", "description": "The substraction can result in an integer underflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Underflow", "type": "Warning"}, {"address": 725, "contract": "Unknown", "debug": "", "description": "The arithmetic operation can result in integer overflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Overflow", "type": "Warning"}], "success": true} \ No newline at end of file diff --git a/tests/testdata/outputs_expected/overflow.sol.o.markdown b/tests/testdata/outputs_expected/overflow.sol.o.markdown index f042f183..4f86063c 100644 --- a/tests/testdata/outputs_expected/overflow.sol.o.markdown +++ b/tests/testdata/outputs_expected/overflow.sol.o.markdown @@ -9,7 +9,7 @@ ### Description -The subtraction can result in an integer underflow. +The substraction can result in an integer underflow. ## Integer Underflow - SWC ID: 101 @@ -20,7 +20,7 @@ The subtraction can result in an integer underflow. ### Description -The subtraction can result in an integer underflow. +The substraction can result in an integer underflow. ## Integer Overflow - SWC ID: 101 diff --git a/tests/testdata/outputs_expected/overflow.sol.o.text b/tests/testdata/outputs_expected/overflow.sol.o.text index ad480ffd..acdce40b 100644 --- a/tests/testdata/outputs_expected/overflow.sol.o.text +++ b/tests/testdata/outputs_expected/overflow.sol.o.text @@ -4,7 +4,7 @@ Type: Warning Contract: Unknown Function name: sendeth(address,uint256) PC address: 567 -The subtraction can result in an integer underflow. +The substraction can result in an integer underflow. -------------------- @@ -14,7 +14,7 @@ Type: Warning Contract: Unknown Function name: sendeth(address,uint256) PC address: 649 -The subtraction can result in an integer underflow. +The substraction can result in an integer underflow. -------------------- diff --git a/tests/testdata/outputs_expected/underflow.sol.o.json b/tests/testdata/outputs_expected/underflow.sol.o.json index d794122d..fb92acaf 100644 --- a/tests/testdata/outputs_expected/underflow.sol.o.json +++ b/tests/testdata/outputs_expected/underflow.sol.o.json @@ -1 +1 @@ -{"error": null, "issues": [{"address": 567, "contract": "Unknown", "debug": "", "description": "The subtraction can result in an integer underflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Underflow", "type": "Warning"}, {"address": 649, "contract": "Unknown", "debug": "", "description": "The subtraction can result in an integer underflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Underflow", "type": "Warning"}, {"address": 725, "contract": "Unknown", "debug": "", "description": "The arithmetic operation can result in integer overflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Overflow", "type": "Warning"}], "success": true} +{"error": null, "issues": [{"address": 567, "contract": "Unknown", "debug": "", "description": "The substraction can result in an integer underflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Underflow", "type": "Warning"}, {"address": 649, "contract": "Unknown", "debug": "", "description": "The substraction can result in an integer underflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Underflow", "type": "Warning"}, {"address": 725, "contract": "Unknown", "debug": "", "description": "The arithmetic operation can result in integer overflow.\n", "function": "sendeth(address,uint256)", "swc_id": "101", "title": "Integer Overflow", "type": "Warning"}], "success": true} \ No newline at end of file diff --git a/tests/testdata/outputs_expected/underflow.sol.o.markdown b/tests/testdata/outputs_expected/underflow.sol.o.markdown index f042f183..4f86063c 100644 --- a/tests/testdata/outputs_expected/underflow.sol.o.markdown +++ b/tests/testdata/outputs_expected/underflow.sol.o.markdown @@ -9,7 +9,7 @@ ### Description -The subtraction can result in an integer underflow. +The substraction can result in an integer underflow. ## Integer Underflow - SWC ID: 101 @@ -20,7 +20,7 @@ The subtraction can result in an integer underflow. ### Description -The subtraction can result in an integer underflow. +The substraction can result in an integer underflow. ## Integer Overflow - SWC ID: 101 diff --git a/tests/testdata/outputs_expected/underflow.sol.o.text b/tests/testdata/outputs_expected/underflow.sol.o.text index ad480ffd..acdce40b 100644 --- a/tests/testdata/outputs_expected/underflow.sol.o.text +++ b/tests/testdata/outputs_expected/underflow.sol.o.text @@ -4,7 +4,7 @@ Type: Warning Contract: Unknown Function name: sendeth(address,uint256) PC address: 567 -The subtraction can result in an integer underflow. +The substraction can result in an integer underflow. -------------------- @@ -14,7 +14,7 @@ Type: Warning Contract: Unknown Function name: sendeth(address,uint256) PC address: 649 -The subtraction can result in an integer underflow. +The substraction can result in an integer underflow. --------------------