Merge pull request #120 from atikur/tc-30064536

Improve Markdown report formatting
pull/126/head
Bernhard Mueller 7 years ago committed by GitHub
commit 96f9384b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      mythril/analysis/modules/dependence_on_predictable_vars.py
  2. 2
      mythril/analysis/modules/ether_send.py
  3. 4
      mythril/analysis/modules/integer.py
  4. 2
      mythril/analysis/modules/suicide.py
  5. 6
      mythril/analysis/report.py
  6. 4
      mythril/support/truffle.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):

@ -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"

@ -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)

@ -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()

@ -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)

@ -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())

Loading…
Cancel
Save