From 5c99005211935f357a61e6a7eb9fee4ea31ab602 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Tue, 27 Feb 2018 14:59:17 +0700 Subject: [PATCH] Add source code info to JSON output --- mythril/analysis/report.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mythril/analysis/report.py b/mythril/analysis/report.py index e0132f3c..09b82ca5 100644 --- a/mythril/analysis/report.py +++ b/mythril/analysis/report.py @@ -19,7 +19,16 @@ class Issue: def as_dict(self): - return {'title': self.title, 'description':self.description, 'function': self.function, 'type': self.type, 'address': self.pc, 'debug': self.debug} + issue = {'title': self.title, 'description':self.description, 'function': self.function, 'type': self.type, 'address': self.pc, 'debug': self.debug} + + if self.filename and self.lineno: + issue['filename'] = self.filename + issue['lineno'] = self.lineno + + if self.code: + issue['code'] = self.code + + return issue class Report: @@ -51,7 +60,7 @@ class Report: text += issue.description + "\n--------------------\n" - if issue.filename: + if issue.filename and issue.lineno: text += "In file: " + issue.filename + ":" + str(issue.lineno) if issue.code: