Revert change - allow only a single statespace to be exported

pull/188/head
Bernhard Mueller 7 years ago
parent 52ab65154c
commit 9c1a50ab57
  1. 14
      mythril/interfaces/cli.py
  2. 13
      mythril/mythril.py

@ -208,17 +208,17 @@ def main():
print(outputs[args.outform]) print(outputs[args.outform])
elif args.statespace_json: elif args.statespace_json:
if not mythril.contracts: if not mythril.contracts:
exit_with_error(args.outform, "input files do not contain any valid contracts") exit_with_error(args.outform, "input files do not contain any valid contracts")
for nr, contract_statespace in enumerate(mythril.dump_statespaces(address=address, max_depth=args.max_depth)): statespace = mythril.dump_statespace(mythril.contracts[0], address=address, max_depth=args.max_depth)
contract, statespace = contract_statespace try:
try: with open(args.statespace_json, "w") as f:
with open("%s_%d_%s.json" % (args.statespace_json, nr, contract.name), "w") as f: json.dump(statespace, f)
json.dump(statespace, f) except Exception as e:
except Exception as e: exit_with_error(args.outform, "Error saving json: " + str(e))
exit_with_error(args.outform, "Error saving json: " + str(e))
else: else:
parser.print_help() parser.print_help()

@ -296,16 +296,13 @@ class Mythril(object):
self._update_signatures(self.sigs) self._update_signatures(self.sigs)
return address, contracts return address, contracts
def dump_statespaces(self, contracts=None, address=None, max_depth=12): def dump_statespace(self, contract, address=None, max_depth=12):
statespaces = []
for contract in (contracts or self.contracts): sym = SymExecWrapper(contract, address,
sym = SymExecWrapper(contract, address, dynloader=DynLoader(self.eth) if self.dynld else None,
dynloader=DynLoader(self.eth) if self.dynld else None, max_depth=max_depth)
max_depth=max_depth)
statespaces.append((contract, get_serializable_statespace(sym)))
return statespaces return get_serializable_statespace(sym)
def graph_html(self, contract, address, max_depth=12, enable_physics=False, phrackify=False): def graph_html(self, contract, address, max_depth=12, enable_physics=False, phrackify=False):
sym = SymExecWrapper(contract, address, sym = SymExecWrapper(contract, address,

Loading…
Cancel
Save