def contains_bad_PRNG_sources( func: Function, blockhash_ret_values: List[Variable]) -> List[Node]: """ Check if any node in function has a modulus operator and the first operand is dependent on block.timestamp, now or blockhash() Returns: (nodes) """ ret = set() # pylint: disable=too-many-nested-blocks for node in func.nodes: for ir in node.irs_ssa: if isinstance(ir, Binary) and ir.type == BinaryType.MODULO: if is_dependent_ssa( ir.variable_left, SolidityVariableComposed("block.timestamp"), func.contract) or is_dependent_ssa( ir.variable_left, SolidityVariable("now"), func.contract): ret.add(node) break for ret_val in blockhash_ret_values: if is_dependent_ssa(ir.variable_left, ret_val, func.contract): ret.add(node) break return list(ret)
def is_any_tainted(variables, taints, function) -> bool: return any( ( is_dependent_ssa(var, taint, function.contract) for var in variables for taint in taints ) )