Add the predictable vars dependence

pull/536/head^2
Nikhil Parasaram 6 years ago
parent e0b955b745
commit 326ed24403
  1. 12
      mythril/analysis/modules/dependence_on_predictable_vars.py
  2. 2
      mythril/analysis/swc_data.py

@ -3,7 +3,7 @@ from z3 import *
from mythril.analysis.ops import VarType
from mythril.analysis import solver
from mythril.analysis.report import Issue
from mythril.analysis.swc_data import TIMESTAMP_DEPENDENCE
from mythril.analysis.swc_data import TIMESTAMP_DEPENDENCE, PREDICTABLE_VARS_DEPENDENCE
from mythril.exceptions import UnsatError
import logging
@ -56,8 +56,12 @@ def execute(statespace):
for item in found:
description += "- block.{}\n".format(item)
if solve(call):
if item == 'timestamp':
swc_type = TIMESTAMP_DEPENDENCE
else:
swc_type = PREDICTABLE_VARS_DEPENDENCE
issue = Issue(contract=call.node.contract_name, function=call.node.function_name, address=address,
swc_id=TIMESTAMP_DEPENDENCE, title="Dependence on predictable environment variable",
swc_id=swc_type, title="Dependence on predictable environment variable",
_type="Warning", description=description)
issues.append(issue)
@ -87,7 +91,7 @@ def execute(statespace):
issue = Issue(contract=call.node.contract_name, function=call.node.function_name,
address=address, title="Dependence on predictable variable",
_type="Warning", description=description, swc_id=TIMESTAMP_DEPENDENCE)
_type="Warning", description=description, swc_id=PREDICTABLE_VARS_DEPENDENCE)
issues.append(issue)
break
else:
@ -108,7 +112,7 @@ def execute(statespace):
'at index {}'.format(index)
issue = Issue(contract=call.node.contract_name, function=call.node.function_name,
address=address, title="Dependence on predictable variable",
_type="Informational", description=description, swc_id=TIMESTAMP_DEPENDENCE)
_type="Informational", description=description, swc_id=PREDICTABLE_VARS_DEPENDENCE)
issues.append(issue)
break
return issues

@ -21,3 +21,5 @@ SHADOWING_STATE_VARIABLES = '119'
WEAK_RANDOMNESS = '120'
SIGNATURE_REPLAY = '121'
IMPROPER_VERIFICATION_BASED_ON_MSG_SENDER = '122'
PREDICTABLE_VARS_DEPENDENCE = 'N/A' # TODO: Add the swc id when this is added to the SWC Registry

Loading…
Cancel
Save