Resolve merge conflicts

berndtz_experimental
Bernhard Mueller 6 years ago
commit 0e71d2c335
  1. 11
      mythril/analysis/modules/integer.py
  2. 7
      mythril/exceptions.py
  3. 15
      mythril/interfaces/cli.py
  4. 17
      mythril/support/dynamic_timeout.py

@ -297,7 +297,9 @@ class IntegerOverflowUnderflowModule(DetectionModule):
if len(state_annotations) == 0:
return
log.info("_handle_transaction_end: " + state.get_current_instruction()['opcode'])
log.info(
"_handle_transaction_end: " + state.get_current_instruction()["opcode"]
)
annotations = state_annotations[0].overflowing_state_annotations
@ -313,7 +315,12 @@ class IntegerOverflowUnderflowModule(DetectionModule):
else:
constraints = state.mstate.constraints + [annotation.constraint]
log.info("Checking {} overflow at: {}".format(ostate.get_current_instruction()['opcode'], ostate.get_current_instruction()['address']))
log.info(
"Checking {} overflow at: {}".format(
ostate.get_current_instruction()["opcode"],
ostate.get_current_instruction()["address"],
)
)
transaction_sequence = solver.get_transaction_sequence(
state, constraints

@ -39,3 +39,10 @@ class AddressNotFoundError(MythrilBaseException):
found."""
pass
class UnsupportedModeError(MythrilBaseException):
"""A Mythril exception denoting an unsupported dynamic timeout mode
constraints."""
pass

@ -15,6 +15,7 @@ import coloredlogs
import traceback
import mythril.support.signatures as sigs
from mythril.support import dynamic_timeout
from mythril.exceptions import AddressNotFoundError, CriticalError
from mythril.mythril import (
MythrilAnalyzer,
@ -224,6 +225,11 @@ def create_parser(parser: argparse.ArgumentParser) -> None:
default=86400,
help="The amount of seconds to spend on symbolic execution",
)
options.add_argument(
"--dynamic-timeout",
choices=["fast", "deep"],
help="Choose timeout dynamically for fast or extensive analysis",
)
options.add_argument(
"--create-timeout",
type=int,
@ -408,6 +414,14 @@ def execute_command(
print(storage)
return
if args.dynamic_timeout:
timeout = dynamic_timeout.get_timeout(
len(disassembler.contracts[0].creation_code), args.dynamic_timeout
)
else:
timeout = args.execution_timeout
log.debug("Set dynamic execution timeout: {}".format(timeout))
analyzer = MythrilAnalyzer(
strategy=args.strategy,
disassembler=disassembler,
@ -415,6 +429,7 @@ def execute_command(
max_depth=args.max_depth,
execution_timeout=args.execution_timeout,
loop_bound=args.loop_bound,
execution_timeout=timeout,
create_timeout=args.create_timeout,
enable_iprof=args.enable_iprof,
onchain_storage_access=not args.no_onchain_storage_access,

@ -0,0 +1,17 @@
from math import exp
from mythril.exceptions import UnsupportedModeError
def get_timeout(bytecode_length: int, mode: str) -> int:
"""
Returns a dynamically calculated timeout based on the length of the bytecode string.
:param bytecode_length: Length of the bytecode: len("0x....")
:param mode: Preset mode (fast or deep)
"""
if mode == "fast":
return int(min(100, 15 * exp(bytecode_length / 6000)))
elif mode == "deep":
return int(min(1800, 30 * exp(bytecode_length / 3000)))
raise UnsupportedModeError
Loading…
Cancel
Save