Make debugging output nicer

pull/852/head
Bernhard Mueller 6 years ago
parent badaaa7709
commit ca34b3aa19
  1. 3
      mythril/analysis/modules/ether_thief.py
  2. 4
      mythril/analysis/modules/exceptions.py
  3. 5
      mythril/analysis/modules/external_calls.py
  4. 24
      mythril/analysis/modules/integer.py
  5. 3
      mythril/analysis/modules/suicide.py
  6. 2
      mythril/analysis/templates/report_as_text.jinja2

@ -1,6 +1,7 @@
"""This module contains the detection code for unauthorized ether
withdrawal."""
import logging
import json
from copy import copy
from mythril.analysis import solver
@ -88,7 +89,7 @@ class EtherThief(DetectionModule):
transaction_sequence = solver.get_transaction_sequence(state, constraints)
debug = str(transaction_sequence)
debug = json.dumps(transaction_sequence, indent=4)
issue = Issue(
contract=node.contract_name,

@ -1,5 +1,6 @@
"""This module contains the detection code for reachable exceptions."""
import logging
import json
from mythril.analysis import solver
from mythril.analysis.modules.base import DetectionModule
@ -33,7 +34,8 @@ def _analyze_state(state) -> list:
"Use `require()` for regular input checking."
)
debug = str(solver.get_transaction_sequence(state, node.constraints))
transaction_sequence = solver.get_transaction_sequence(state, node.constraints)
debug = json.dumps(transaction_sequence, indent=4)
issue = Issue(
contract=node.contract_name,

@ -9,6 +9,7 @@ from mythril.laser.smt import UGT, symbol_factory
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.exceptions import UnsatError
import logging
import json
log = logging.getLogger(__name__)
@ -45,7 +46,7 @@ def _analyze_state(state):
constraints += [to == 0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF]
transaction_sequence = solver.get_transaction_sequence(state, constraints)
debug = str(transaction_sequence)
debug = json.dumps(transaction_sequence, indent=4)
description_head = "A call to a user-supplied address is executed."
description_tail = (
"The callee address of an external message call can be set by "
@ -74,7 +75,7 @@ def _analyze_state(state):
"[EXTERNAL_CALLS] Callee address cannot be modified. Reporting informational issue."
)
debug = str(transaction_sequence)
debug = json.dumps(transaction_sequence, indent=4)
description_head = "The contract executes an external message call."
description_tail = (
"An external function call to a fixed contract address is executed. Make sure "

@ -1,14 +1,15 @@
"""This module contains the detection code for integer overflows and
underflows."""
import json
from mythril.analysis import solver
from mythril.analysis.report import Issue
from mythril.analysis.swc_data import INTEGER_OVERFLOW_AND_UNDERFLOW
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.taint_analysis import TaintRunner
from mythril.analysis.modules.base import DetectionModule
from mythril.laser.smt import (
BVAddNoOverflow,
BVSubNoUnderflow,
@ -19,7 +20,6 @@ from mythril.laser.smt import (
Expression,
)
import copy
import logging
@ -169,11 +169,13 @@ class IntegerOverflowUnderflowModule(DetectionModule):
)
try:
issue.debug = str(
solver.get_transaction_sequence(
transaction_sequence = olver.get_transaction_sequence(
state, node.constraints + [annotation.constraint]
)
)
issue.debug = json.dumps(transaction_sequence, indent=4)
except UnsatError:
return
self._issues.append(issue)
@ -211,11 +213,13 @@ class IntegerOverflowUnderflowModule(DetectionModule):
)
try:
issue.debug = str(
solver.get_transaction_sequence(
state, node.constraints + [annotation.constraint]
)
transaction_sequence = solver.get_transaction_sequence(
state, node.constraints + [annotation.constraint]
)
issue.debug = json.dumps(transaction_sequence, indent=4)
except UnsatError:
return
self._issues.append(issue)

@ -5,6 +5,7 @@ from mythril.exceptions import UnsatError
from mythril.analysis.modules.base import DetectionModule
from mythril.laser.ethereum.state.global_state import GlobalState
import logging
import json
log = logging.getLogger(__name__)
@ -40,7 +41,7 @@ def _analyze_state(state):
"the contract balance is sent."
)
debug = str(transaction_sequence)
debug = json.dumps(transaction_sequence, indent=4)
issue = Issue(
contract=node.contract_name,

@ -20,7 +20,7 @@ In file: {{ issue.filename }}:{{ issue.lineno }}
{% endif %}
{% if verbose and issue.debug %}
--------------------
DEBUGGING INFORMATION:
Transaction Sequence:
{{ issue.debug }}
{% endif %}

Loading…
Cancel
Save