Add 'loop-bound' CLI argument'

pull/1060/head
Bernhard Mueller 6 years ago
parent 780ea9ab9b
commit 6292ccd216
  1. 8
      mythril/interfaces/cli.py
  2. 7
      mythril/laser/ethereum/strategy/extensions/bounded_loops.py

@ -197,13 +197,19 @@ def create_parser(parser: argparse.ArgumentParser) -> None:
default=50,
help="Maximum recursion depth for symbolic execution",
)
options.add_argument(
"--strategy",
choices=["dfs", "bfs", "naive-random", "weighted-random"],
default="bfs",
help="Symbolic execution strategy",
)
options.add_argument(
"-b",
"--loop-bound",
type=int,
default=4,
help="Bound loops at n iterations",
)
options.add_argument(
"-t",
"--transaction-count",

@ -7,7 +7,6 @@ from copy import copy
import logging
JUMPDEST_LIMIT = 4
log = logging.getLogger(__name__)
@ -28,8 +27,10 @@ class BFSBoundedLoopsStrategy(BasicSearchStrategy):
Ignores JUMPI instruction if the destination was targeted >JUMPDEST_LIMIT times.
"""
def __init__(self, super_strategy: BasicSearchStrategy):
def __init__(self, super_strategy: BasicSearchStrategy, loop_bound: int):
self.super_strategy = super_strategy
self.jumpdest_limit = loop_bound
BasicSearchStrategy.__init__(
self, super_strategy.work_list, super_strategy.max_depth
)
@ -65,7 +66,7 @@ class BFSBoundedLoopsStrategy(BasicSearchStrategy):
except KeyError:
annotation._jumpdest_count[target] = 1
if annotation._jumpdest_count[target] > JUMPDEST_LIMIT:
if annotation._jumpdest_count[target] > self.jumpdest_limit:
log.debug("JUMPDEST limit reached, skipping JUMPI")
continue

Loading…
Cancel
Save