incorrect-equality: do not check addresses

pull/1713/head
Yordan Miladinov 2 years ago
parent cb376503b7
commit 3a1c7cb065
  1. 15
      slither/detectors/statements/incorrect_strict_equality.py

@ -72,6 +72,14 @@ contract Crowdsale{
def is_direct_comparison(ir: Operation) -> bool:
return isinstance(ir, Binary) and ir.type == BinaryType.EQUAL
@staticmethod
def is_not_comparing_addresses(ir: Binary) -> bool:
"""
Comparing addresses strictly should not be flagged.
"""
addr = ElementaryType("address")
return ir.variable_left.type != addr or ir.variable_right.type != addr
@staticmethod
def is_any_tainted(
variables: List[
@ -145,7 +153,12 @@ contract Crowdsale{
for ir in node.irs_ssa:
# Filter to only tainted equality (==) comparisons
if self.is_direct_comparison(ir) and self.is_any_tainted(ir.used, taints, func):
if (
self.is_direct_comparison(ir)
and self.is_not_comparing_addresses(ir)
and self.is_any_tainted(ir.used, taints, func)
):
#
if func not in results:
results[func] = []
results[func].append(node)

Loading…
Cancel
Save