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)
issue.filename = codeinfo.filename
issue.code = codeinfo.code
issue.lineno = codeinfo.lineno

@ -61,7 +61,7 @@ class Report:
text += issue.description + "\n--------------------\n"
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:
text += "\n\n" + issue.code + "\n\n--------------------\n"

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

Loading…
Cancel
Save