Add type hints to functions in the predictable vars module and the call helpers

pull/803/head
Nikhil Parasaram 6 years ago
parent c603b4fa7c
commit 29fe835401
  1. 7
      mythril/analysis/call_helpers.py
  2. 11
      mythril/analysis/modules/dependence_on_predictable_vars.py

@ -1,7 +1,10 @@
from typing import Union
from mythril.analysis.ops import VarType, Call, get_variable
from mythril.laser.ethereum.state.global_state import GlobalState
def get_call_from_state(state):
def get_call_from_state(state: GlobalState) -> Union[Call, None]:
instruction = state.get_current_instruction()
op = instruction["opcode"]
@ -20,7 +23,7 @@ def get_call_from_state(state):
)
if to.type == VarType.CONCRETE and to.val < 5:
return
return None
if meminstart.type == VarType.CONCRETE and meminsz.type == VarType.CONCRETE:
return Call(

@ -1,5 +1,6 @@
import re
from mythril.analysis.ops import VarType
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.analysis.ops import Call, VarType
from mythril.analysis import solver
from mythril.analysis.report import Issue
from mythril.analysis.call_helpers import get_call_from_state
@ -25,10 +26,10 @@ class PredictableDependenceModule(DetectionModule):
self._issues = []
@property
def issues(self):
def issues(self) -> list:
return self._issues
def execute(self, state):
def execute(self, state: GlobalState) -> list:
self._issues.extend(_analyze_states(state))
return self.issues
@ -36,7 +37,7 @@ class PredictableDependenceModule(DetectionModule):
detector = PredictableDependenceModule()
def _analyze_states(state):
def _analyze_states(state: GlobalState) -> list:
issues = []
call = get_call_from_state(state)
if call is None:
@ -177,7 +178,7 @@ def _analyze_states(state):
return issues
def solve(call):
def solve(call: Call) -> bool:
try:
model = solver.get_model(call.node.constraints)
logging.debug("[DEPENDENCE_ON_PREDICTABLE_VARS] MODEL: " + str(model))

Loading…
Cancel
Save