Refactor module logging

pull/1047/head
Bernhard Mueller 6 years ago
parent a0c6fecb86
commit ab940af8b7
  1. 18
      mythril/analysis/modules/base.py
  2. 4
      mythril/analysis/modules/delegatecall.py
  3. 4
      mythril/analysis/modules/dependence_on_predictable_vars.py
  4. 2
      mythril/analysis/modules/deprecated_ops.py
  5. 3
      mythril/analysis/modules/dos.py
  6. 2
      mythril/analysis/modules/ether_thief.py
  7. 2
      mythril/analysis/modules/exceptions.py
  8. 2
      mythril/analysis/modules/external_calls.py
  9. 2
      mythril/analysis/modules/integer.py
  10. 2
      mythril/analysis/modules/multiple_sends.py
  11. 2
      mythril/analysis/modules/state_change_external_calls.py
  12. 2
      mythril/analysis/modules/suicide.py
  13. 2
      mythril/analysis/modules/unchecked_retval.py
  14. 6
      mythril/analysis/security.py
  15. 2
      mythril/interfaces/cli.py

@ -49,12 +49,28 @@ class DetectionModule:
"""
self._issues = []
def execute(self, statespace):
def execute(self, statespace) -> list:
"""The entry point for execution, which is being called by Mythril.
:param statespace:
:return:
"""
log.debug("Entering analysis module: {}".format(self.__class__.__name__))
issues = self._execute(statespace)
log.debug("Exiting analysis module: {}".format(self.__class__.__name__))
return issues
def _execute(self, statespace):
"""The entry point for execution, which is being called by Mythril.
:param statespace:
:return:
"""
raise NotImplementedError()
def __repr__(self) -> str:

@ -12,7 +12,6 @@ from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.annotation import StateAnnotation
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import symbol_factory, UGT
from mythril.laser.smt import symbol_factory, UGT
log = logging.getLogger(__name__)
@ -80,13 +79,12 @@ class DelegateCallModule(DetectionModule):
pre_hooks=["DELEGATECALL", "RETURN", "STOP"],
)
def execute(self, state: GlobalState) -> list:
def _execute(self, state: GlobalState) -> list:
"""
:param state:
:return:
"""
log.debug("Executing module: DELEGATE_CALL")
self._issues.extend(_analyze_states(state))
return self.issues

@ -64,15 +64,13 @@ class PredictableDependenceModule(DetectionModule):
post_hooks=["BLOCKHASH"] + predictable_ops,
)
def execute(self, state: GlobalState) -> list:
def _execute(self, state: GlobalState) -> list:
"""
:param state:
:return:
"""
log.debug("Executing module: DEPENDENCE_ON_PREDICTABLE_VARS")
self._issues.extend(_analyze_states(state))
return self.issues

@ -76,7 +76,7 @@ class DeprecatedOperationsModule(DetectionModule):
pre_hooks=["ORIGIN", "CALLCODE"],
)
def execute(self, state: GlobalState):
def _execute(self, state: GlobalState):
"""
:param state:

@ -43,13 +43,12 @@ class DOS(DetectionModule):
"""Keeps track of how often jump destinations are reached."""
self._jumpdest_count = {} # type: Dict[object, dict]
def execute(self, state: GlobalState) -> None:
def _execute(self, state: GlobalState) -> None:
"""
:param state:
:return:
"""
log.debug("Executing module: DOS")
self._issues.extend(self._analyze_states(state))

@ -51,7 +51,7 @@ class EtherThief(DetectionModule):
super().reset_module()
self._cache_addresses = {}
def execute(self, state: GlobalState):
def _execute(self, state: GlobalState):
"""
:param state:

@ -72,7 +72,7 @@ class ReachableExceptionsModule(DetectionModule):
pre_hooks=["ASSERT_FAIL"],
)
def execute(self, state: GlobalState) -> list:
def _execute(self, state: GlobalState) -> list:
"""
:param state:

@ -137,7 +137,7 @@ class ExternalCalls(DetectionModule):
pre_hooks=["CALL"],
)
def execute(self, state: GlobalState):
def _execute(self, state: GlobalState):
"""
:param state:

@ -84,7 +84,7 @@ class IntegerOverflowUnderflowModule(DetectionModule):
self._overflow_cache = {}
self._underflow_cache = {}
def execute(self, state: GlobalState):
def _execute(self, state: GlobalState):
"""Executes analysis module for integer underflow and integer overflow.
:param state: Statespace to analyse

@ -43,7 +43,7 @@ class MultipleSendsModule(DetectionModule):
],
)
def execute(self, state: GlobalState):
def _execute(self, state: GlobalState):
self._issues.extend(_analyze_state(state))
return self.issues

@ -84,7 +84,7 @@ class StateChange(DetectionModule):
],
)
def execute(self, state: GlobalState):
def _execute(self, state: GlobalState):
self._issues.extend(self._analyze_state(state))
return self.issues

@ -37,7 +37,7 @@ class SuicideModule(DetectionModule):
super().reset_module()
self._cache_address = {}
def execute(self, state: GlobalState):
def _execute(self, state: GlobalState):
"""
:param state:

@ -49,7 +49,7 @@ class UncheckedRetvalModule(DetectionModule):
post_hooks=["CALL", "DELEGATECALL", "STATICCALL", "CALLCODE"],
)
def execute(self, state: GlobalState) -> list:
def _execute(self, state: GlobalState) -> list:
"""
:param state:

@ -52,6 +52,10 @@ def get_detection_modules(entrypoint, include_modules=()):
:param include_modules:
:return:
"""
module = importlib.import_module("mythril.analysis.modules.base")
module.log.setLevel(log.level)
include_modules = list(include_modules)
_modules = []
@ -62,12 +66,14 @@ def get_detection_modules(entrypoint, include_modules=()):
module = importlib.import_module(
"mythril.analysis.modules." + module_name
)
module.log.setLevel(log.level)
if module.detector.entrypoint == entrypoint:
_modules.append(module)
else:
for module_name in include_modules:
module = importlib.import_module("mythril.analysis.modules." + module_name)
if module.__name__ != "base" and module.detector.entrypoint == entrypoint:
module.log.setLevel(log.level)
_modules.append(module)
log.info("Found %s detection modules", len(_modules))

@ -24,8 +24,6 @@ from mythril.mythril import (
)
from mythril.version import VERSION
# logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)

Loading…
Cancel
Save