From 09a9b907afd22c22f92db3ecc046a2565e0dbb4a Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Wed, 8 Mar 2023 23:00:35 -0600 Subject: [PATCH 1/2] restrict variable-scope detector to only solc 0.4.x close https://github.com/crytic/slither/issues/1424 --- .../detectors/variables/predeclaration_usage_local.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/slither/detectors/variables/predeclaration_usage_local.py b/slither/detectors/variables/predeclaration_usage_local.py index 2ba539a91..2a24eed84 100644 --- a/slither/detectors/variables/predeclaration_usage_local.py +++ b/slither/detectors/variables/predeclaration_usage_local.py @@ -7,7 +7,11 @@ from slither.core.cfg.node import Node from slither.core.declarations import Function from slither.core.declarations.contract import Contract from slither.core.variables.local_variable import LocalVariable -from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification +from slither.detectors.abstract_detector import ( + AbstractDetector, + DetectorClassification, + ALL_SOLC_VERSIONS_04, +) from slither.utils.output import Output @@ -53,7 +57,9 @@ Additionally, the for-loop uses the variable `max`, which is declared in a previ # endregion wiki_exploit_scenario WIKI_RECOMMENDATION = "Move all variable declarations prior to any usage of the variable, and ensure that reaching a variable declaration does not depend on some conditional if it is used unconditionally." - + + VULNERABLE_SOLC_VERSIONS = ALL_SOLC_VERSIONS_04 + def detect_predeclared_local_usage( self, node: Node, From 20ca59946d21718f4f7625936cb042b29e0f78f8 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Fri, 10 Mar 2023 08:06:35 -0600 Subject: [PATCH 2/2] lint --- slither/detectors/variables/predeclaration_usage_local.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slither/detectors/variables/predeclaration_usage_local.py b/slither/detectors/variables/predeclaration_usage_local.py index 2a24eed84..177035ef4 100644 --- a/slither/detectors/variables/predeclaration_usage_local.py +++ b/slither/detectors/variables/predeclaration_usage_local.py @@ -57,9 +57,9 @@ Additionally, the for-loop uses the variable `max`, which is declared in a previ # endregion wiki_exploit_scenario WIKI_RECOMMENDATION = "Move all variable declarations prior to any usage of the variable, and ensure that reaching a variable declaration does not depend on some conditional if it is used unconditionally." - + VULNERABLE_SOLC_VERSIONS = ALL_SOLC_VERSIONS_04 - + def detect_predeclared_local_usage( self, node: Node,