Add truffle.py, fire_lasers returns report

pull/53/head
Bernhard Mueller 7 years ago
parent 5972788393
commit 75dbbe6ae9
  1. 10
      myth
  2. 6
      mythril/analysis/security.py
  3. 23
      mythril/support/truffle.py

10
myth

@ -12,6 +12,7 @@ from mythril.rpc.client import EthJsonRpc
from mythril.ipc.client import EthIpc
from mythril.rpc.exceptions import ConnectionError
from mythril.support import signatures
from mythril.support.truffle import analyze_truffle_project
from mythril.support.loader import DynLoader
from mythril.exceptions import CompilerError
from mythril.analysis.symbolic import StateSpace
@ -286,7 +287,14 @@ elif (args.graph) or (args.fire_lasers):
else:
states = StateSpace(contracts, max_depth=args.max_depth)
fire_lasers(states)
report = fire_lasers(states)
if (len(report.issues)):
print(report.as_text())
else:
print("The analysis was completed successfully. No issues were detected.")
else:
parser.print_help()

@ -25,8 +25,6 @@ def fire_lasers(statespace):
for i in range(0, len(issues)):
report.append_issue(issues[i])
print(report.as_text())
return report
else:
print("The analysis was completed successfully. No issues were detected.")

@ -0,0 +1,23 @@
import os
import json
def analyze_truffle_project():
project_root = os.getcwd()
build_dir = os.path.join(project_root, "build", "contracts")
contract_files = os.listdir(build_dir)
for contract_file in contract_files:
with open(os.path.join(build_dir, contract_file)) as cf:
contract = json.load(cf)
name = contract['contractName']
bytecode = contract['deployedBytecode']
deployedSourceMap = contract['deployedSourceMap']
Loading…
Cancel
Save