From 15fd5a3c02e488ec062adca2a2bde3d686e58768 Mon Sep 17 00:00:00 2001 From: Atikur Rahman Date: Tue, 17 Apr 2018 19:06:43 +0600 Subject: [PATCH 1/2] fix markdown report formatting --- mythril/analysis/report.py | 6 +++--- mythril/support/truffle.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mythril/analysis/report.py b/mythril/analysis/report.py index 9ec63493..3088d9d9 100644 --- a/mythril/analysis/report.py +++ b/mythril/analysis/report.py @@ -88,11 +88,11 @@ class Report: return json.dumps(result) def as_markdown(self): - text = "# Analysis Results\n" + text = "" for key, issue in self.issues.items(): - text += "## " + issue.title + "\n" + text += "\n\n## " + issue.title + "\n\n" text += "- Type: " + issue.type + "\n" if len(issue.contract): @@ -103,7 +103,7 @@ class Report: text += "- Function name: `" + issue.function + "`\n" text += "- PC address: " + str(issue.pc) + "\n\n" - text += "### Description\n" + issue.description + "\n" + text += "\n\n### Description\n\n" + issue.description + "\n" if issue.filename and issue.lineno: text += "\nIn *%s:%d*\n" % (issue.filename, issue.lineno) diff --git a/mythril/support/truffle.py b/mythril/support/truffle.py index a90a7858..992aff43 100644 --- a/mythril/support/truffle.py +++ b/mythril/support/truffle.py @@ -46,7 +46,7 @@ def analyze_truffle_project(args): if not len(issues): if (args.outform == 'text' or args.outform == 'markdown'): - print("Analysis result for " + name + ": No issues found.") + print("\n\n# Analysis result for " + name + "\n\nNo issues found.") else: result = {'contract': name, 'result': {'success': True, 'error': None, 'issues': []}} print(json.dumps(result)) @@ -105,4 +105,4 @@ def analyze_truffle_project(args): if (args.outform == 'text'): print("Analysis result for " + name + ":\n" + report.as_text()) elif (args.outform == 'markdown'): - print("Analysis result for " + name + ":\n" + report.as_markdown()) + print("\n\n# Analysis result for " + name + "\n\n" + report.as_markdown()) From fa920872cb96f450bf95cd51aa5bdfb4604ef3c1 Mon Sep 17 00:00:00 2001 From: Atikur Rahman Date: Tue, 17 Apr 2018 19:17:32 +0600 Subject: [PATCH 2/2] wrap function in back ticks --- mythril/analysis/modules/dependence_on_predictable_vars.py | 4 ++-- mythril/analysis/modules/ether_send.py | 2 +- mythril/analysis/modules/integer.py | 4 ++-- mythril/analysis/modules/suicide.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mythril/analysis/modules/dependence_on_predictable_vars.py b/mythril/analysis/modules/dependence_on_predictable_vars.py index 720e384e..c5da486d 100644 --- a/mythril/analysis/modules/dependence_on_predictable_vars.py +++ b/mythril/analysis/modules/dependence_on_predictable_vars.py @@ -39,7 +39,7 @@ def execute(statespace): address = call.state.get_current_instruction()['address'] - description = "In the function '" + call.node.function_name + "' " + description = "In the function `'" + call.node.function_name + "'` " description += "the following predictable state variables are used to determine Ether recipient:\n" # First check: look for predictable state variables in node & call recipient constraints @@ -64,7 +64,7 @@ def execute(statespace): for constraint in call.node.constraints + [call.to]: if "blockhash" in str(constraint): - description = "In the function '" + call.node.function_name + "' " + description = "In the function `'" + call.node.function_name + "'` " if "number" in str(constraint): m = re.search('blockhash\w+(\s\-\s(\d+))*', str(constraint)) if m and solve(call): diff --git a/mythril/analysis/modules/ether_send.py b/mythril/analysis/modules/ether_send.py index 602c8dac..ad7f22a3 100644 --- a/mythril/analysis/modules/ether_send.py +++ b/mythril/analysis/modules/ether_send.py @@ -39,7 +39,7 @@ def execute(statespace): interesting = False - description = "In the function '" + call.node.function_name + "' " + description = "In the function `'" + call.node.function_name + "'` " if re.search(r'caller', str(call.to)): description += "a non-zero amount of Ether is sent to msg.sender.\n" diff --git a/mythril/analysis/modules/integer.py b/mythril/analysis/modules/integer.py index 4e63a919..d3f5a442 100644 --- a/mythril/analysis/modules/integer.py +++ b/mythril/analysis/modules/integer.py @@ -76,7 +76,7 @@ def _check_integer_overflow(statespace, state, node): issue = Issue(node.contract_name, node.function_name, instruction['address'], "Integer Overflow ", "Warning") - issue.description = "A possible integer overflow exists in the function {}.\n" \ + issue.description = "A possible integer overflow exists in the function `{}`.\n" \ "The addition may result in a value higher than the maximum representable integer.".format(node.function_name) issue.debug = solver.pretty_print_model(model) issues.append(issue) @@ -134,7 +134,7 @@ def _check_integer_underflow(state, node): issue = Issue(node.contract_name, node.function_name, instruction['address'], "Integer Underflow", "Warning") - issue.description = "A possible integer underflow exists in the function " + node.function_name + ".\n" \ + issue.description = "A possible integer underflow exists in the function `" + node.function_name + "`.\n" \ "The subtraction may result in a value < 0." issue.debug = solver.pretty_print_model(model) diff --git a/mythril/analysis/modules/suicide.py b/mythril/analysis/modules/suicide.py index 8e603590..5a5e4683 100644 --- a/mythril/analysis/modules/suicide.py +++ b/mythril/analysis/modules/suicide.py @@ -32,7 +32,7 @@ def execute(statespace): logging.debug("[UNCHECKED_SUICIDE] suicide in function " + node.function_name) - description = "The function " + node.function_name + " executes the SUICIDE instruction. " + description = "The function `" + node.function_name + "` executes the SUICIDE instruction. " stack = copy.deepcopy(state.mstate.stack) to = stack.pop()