Set filename when mapping Solidity code to issues

pull/88/head
Bernhard Mueller 7 years ago
parent a603772956
commit 6e8eb8c0d2
  1. 1
      myth
  2. 2
      mythril/analysis/report.py
  3. 11
      mythril/support/signatures.py

@ -426,6 +426,7 @@ elif (args.graph) or (args.fire_lasers):
codeinfo = contract.get_source_info(issue.pc) codeinfo = contract.get_source_info(issue.pc)
issue.filename = codeinfo.filename
issue.code = codeinfo.code issue.code = codeinfo.code
issue.lineno = codeinfo.lineno issue.lineno = codeinfo.lineno

@ -61,7 +61,7 @@ class Report:
text += issue.description + "\n--------------------\n" text += issue.description + "\n--------------------\n"
if issue.filename and issue.lineno: if issue.filename and issue.lineno:
text += "In file: " + issue.filename + ":" + str(issue.lineno) text += "In file: " + issue.filename + ":" + str(issue.lineno)
if issue.code: if issue.code:
text += "\n\n" + issue.code + "\n\n--------------------\n" text += "\n\n" + issue.code + "\n\n--------------------\n"

@ -1,20 +1,21 @@
import re import re
from ethereum import utils from ethereum import utils
def add_signatures_from_file(file, sigs={}): def add_signatures_from_file(file, sigs={}):
funcs = [] funcs = []
with open(file, encoding="utf-8") as f: with open(file, encoding="utf-8") as f:
for line in f:
m = re.search(r'function\s+(.*\))', line) code = f.read()
if m: funcs = re.findall(r'function[\s]+(.*?\))', code, re.DOTALL)
funcs.append(m.group(1))
for f in funcs: for f in funcs:
f = re.sub(r'[\n]', '', f)
m = re.search(r'^([A-Za-z0-9_]+)', f) m = re.search(r'^([A-Za-z0-9_]+)', f)
if (m): if (m):
@ -38,4 +39,6 @@ def add_signatures_from_file(file, sigs={}):
typelist = ",".join(types) typelist = ",".join(types)
signature += "(" + typelist + ")" signature += "(" + typelist + ")"
signature = re.sub(r'\s', '', signature)
sigs["0x" + utils.sha3(signature)[:4].hex()] = signature sigs["0x" + utils.sha3(signature)[:4].hex()] = signature

Loading…
Cancel
Save