diff --git a/docs/dubious_typecast.md b/docs/dubious_typecast.md index 1f94df4..70d1e81 100644 --- a/docs/dubious_typecast.md +++ b/docs/dubious_typecast.md @@ -8,7 +8,7 @@ ## Description -Highlights nonstandard typecasts. E.g: `uint256(uint8(K))` +Highlights explicit typecasts, where the result value can differ from the original one. E.g., `uint8(uint256(1e18))`, `uint256(int256(-1))`. ## Vulnerable Scenario diff --git a/slitherin/detectors/dubious_typecast.py b/slitherin/detectors/dubious_typecast.py index 1c4e1aa..c030016 100644 --- a/slitherin/detectors/dubious_typecast.py +++ b/slitherin/detectors/dubious_typecast.py @@ -71,6 +71,8 @@ class DubiousTypecast(AbstractDetector): ) WIKI_RECOMMENDATION = "Use clear constants" + WHITELIST = ["SafeCast", "SignedMath"] # OZ + def analyze_irs(self, irs: List[Operation]) -> List[Tuple[str, str]]: results = [] for i in irs: @@ -98,6 +100,8 @@ def get_dubious_typecasts(self, fun: FunctionContract, params=None): def _detect(self): results = [] for contract in self.compilation_unit.contracts_derived: + if contract.name in self.WHITELIST: + continue for f in contract.functions: func_res = self.get_dubious_typecasts(f) if func_res: