From 8feae1c5ddc77dacea46a082a7f0c075b9b22ed7 Mon Sep 17 00:00:00 2001 From: Yhtyyar Sahatov Date: Wed, 29 May 2024 09:27:17 +0300 Subject: [PATCH] obsolete detectors --- slitherin/__init__.py | 33 ++++++++++++++----- slitherin/consts.py | 1 + slitherin/detectors/obsolete/README.md | 4 +++ .../call_forward_to_protected.py | 2 +- .../{ => obsolete}/read_only_reentrancy.py | 0 5 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 slitherin/detectors/obsolete/README.md rename slitherin/detectors/{ => obsolete}/call_forward_to_protected.py (98%) rename slitherin/detectors/{ => obsolete}/read_only_reentrancy.py (100%) diff --git a/slitherin/__init__.py b/slitherin/__init__.py index 7298975..773fc00 100644 --- a/slitherin/__init__.py +++ b/slitherin/__init__.py @@ -1,3 +1,5 @@ +import os + from slitherin.detectors.arbitrary_call.arbitrary_call import ArbitraryCall from slitherin.detectors.double_entry_token_possibility import ( DoubleEntryTokenPossiblity, @@ -9,12 +11,14 @@ from slitherin.detectors.unprotected_setter import UnprotectedSetter from slitherin.detectors.nft_approve_warning import NftApproveWarning from slitherin.detectors.inconsistent_nonreentrant import InconsistentNonreentrant -from slitherin.detectors.call_forward_to_protected import CallForwardToProtected +from slitherin.detectors.obsolete.call_forward_to_protected import ( + CallForwardToProtected, +) from slitherin.detectors.multiple_storage_read import MultipleStorageRead from slitherin.detectors.timelock_controller import TimelockController from slitherin.detectors.tx_gasprice_warning import TxGaspriceWarning from slitherin.detectors.unprotected_initialize import UnprotectedInitialize -from slitherin.detectors.read_only_reentrancy import ReadOnlyReentrancy +from slitherin.detectors.obsolete.read_only_reentrancy import ReadOnlyReentrancy from slitherin.detectors.event_setter import EventSetter from slitherin.detectors.before_token_transfer import BeforeTokenTransfer from slitherin.detectors.uni_v2 import UniswapV2 @@ -29,19 +33,28 @@ from slitherin.detectors.arbitrum.block_number_timestamp import ( ArbitrumBlockNumberTimestamp, ) -from slitherin.detectors.arbitrum.arbitrum_chainlink_price_feed import ArbitrumChainlinkPriceFeed +from slitherin.detectors.arbitrum.arbitrum_chainlink_price_feed import ( + ArbitrumChainlinkPriceFeed, +) from slitherin.detectors.potential_arith_overflow import PotentialArithmOverflow from slitherin.detectors.curve.curve_readonly_reentrancy import CurveReadonlyReentrancy -from slitherin.detectors.balancer.balancer_readonly_reentrancy import BalancerReadonlyReentrancy -from slitherin.detectors.vyper.reentrancy_curve_vyper_version import CurveVyperReentrancy +from slitherin.detectors.balancer.balancer_readonly_reentrancy import ( + BalancerReadonlyReentrancy, +) +from slitherin.detectors.vyper.reentrancy_curve_vyper_version import ( + CurveVyperReentrancy, +) from slitherin.detectors.price_manipulation import PriceManipulationDetector +from .consts import OBSOLETE_FLAG artbitrum_detectors = [ ArbitrumPrevrandaoDifficulty, ArbitrumBlockNumberTimestamp, - ArbitrumChainlinkPriceFeed + ArbitrumChainlinkPriceFeed, ] +obsolete_detectors = [CallForwardToProtected, ReadOnlyReentrancy] + plugin_detectors = artbitrum_detectors + [ DoubleEntryTokenPossiblity, UnprotectedSetter, @@ -51,12 +64,10 @@ OnlyEOACheck, MagicNumber, DubiousTypecast, - CallForwardToProtected, MultipleStorageRead, TimelockController, TxGaspriceWarning, UnprotectedInitialize, - ReadOnlyReentrancy, EventSetter, BeforeTokenTransfer, UniswapV2, @@ -70,8 +81,12 @@ CurveReadonlyReentrancy, BalancerReadonlyReentrancy, CurveVyperReentrancy, - PriceManipulationDetector + PriceManipulationDetector, ] + +if os.getenv(OBSOLETE_FLAG): + plugin_detectors += obsolete_detectors + plugin_printers = [] diff --git a/slitherin/consts.py b/slitherin/consts.py index 441c3d0..f13202b 100644 --- a/slitherin/consts.py +++ b/slitherin/consts.py @@ -1,2 +1,3 @@ ARBITRUM_KEY = "SLITHERIN_ARBITRUM" +OBSOLETE_FLAG = "SLITHERIN_OBSOLETE" SLITHERIN_VERSION = "0.7.0" diff --git a/slitherin/detectors/obsolete/README.md b/slitherin/detectors/obsolete/README.md new file mode 100644 index 0000000..270f610 --- /dev/null +++ b/slitherin/detectors/obsolete/README.md @@ -0,0 +1,4 @@ +# Obsolete detectors +These detectors are deprecated. +## How to still use it +Set a flag `SLITHERIN_OBSOLETE=true` \ No newline at end of file diff --git a/slitherin/detectors/call_forward_to_protected.py b/slitherin/detectors/obsolete/call_forward_to_protected.py similarity index 98% rename from slitherin/detectors/call_forward_to_protected.py rename to slitherin/detectors/obsolete/call_forward_to_protected.py index 1464c45..911800d 100644 --- a/slitherin/detectors/call_forward_to_protected.py +++ b/slitherin/detectors/obsolete/call_forward_to_protected.py @@ -50,7 +50,7 @@ def _detect_low_level_custom_address_call(self, fun: Function) -> bool: return True return False - def _pess_is_excluded_from_detector(self, contract: "Contract") -> bool: + def _pess_is_excluded_from_detector(self, contract) -> bool: path = Path(contract.source_mapping.filename.absolute).parts is_zep = "openzeppelin-solidity" in path or \ ("@openzeppelin" in path and path[path.index("@openzeppelin") + 1] == "contracts") or \ diff --git a/slitherin/detectors/read_only_reentrancy.py b/slitherin/detectors/obsolete/read_only_reentrancy.py similarity index 100% rename from slitherin/detectors/read_only_reentrancy.py rename to slitherin/detectors/obsolete/read_only_reentrancy.py