From c1a1675259abf5ebf191176b2176fa6a50b96e2f Mon Sep 17 00:00:00 2001 From: Tigran Avagyan Date: Tue, 24 Oct 2023 18:42:29 +0400 Subject: [PATCH 1/3] added update reachability to modifiers --- slither/solc_parsing/declarations/modifier.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slither/solc_parsing/declarations/modifier.py b/slither/solc_parsing/declarations/modifier.py index c4c5c7177..77b326945 100644 --- a/slither/solc_parsing/declarations/modifier.py +++ b/slither/solc_parsing/declarations/modifier.py @@ -92,7 +92,9 @@ class ModifierSolc(FunctionSolc): self._rewrite_ternary_as_if_else() self._remove_alone_endif() - + + if self._function.entry_point: + self._update_reachability(self._function.entry_point) # self._analyze_read_write() # self._analyze_calls() From 0994edf110c33723f0f31713c8d5b52a4c90d198 Mon Sep 17 00:00:00 2001 From: Tigran Avagyan Date: Tue, 24 Oct 2023 18:49:05 +0400 Subject: [PATCH 2/3] Update modifier.py removed trailing whitespace --- slither/solc_parsing/declarations/modifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/solc_parsing/declarations/modifier.py b/slither/solc_parsing/declarations/modifier.py index 77b326945..dfacc8703 100644 --- a/slither/solc_parsing/declarations/modifier.py +++ b/slither/solc_parsing/declarations/modifier.py @@ -92,7 +92,7 @@ class ModifierSolc(FunctionSolc): self._rewrite_ternary_as_if_else() self._remove_alone_endif() - + if self._function.entry_point: self._update_reachability(self._function.entry_point) # self._analyze_read_write() From 052a30a191162fb18884e5a3fb426270162eb3db Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 19 Feb 2024 22:06:35 -0600 Subject: [PATCH 3/3] add regression test for https://github.com/crytic/slither/issues/2313 --- examples/scripts/data_dependency.py | 14 ++++++++++++++ examples/scripts/data_dependency.sol | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/examples/scripts/data_dependency.py b/examples/scripts/data_dependency.py index 23c82cae1..5edbe4923 100644 --- a/examples/scripts/data_dependency.py +++ b/examples/scripts/data_dependency.py @@ -126,3 +126,17 @@ print(f"{var_tainted} is tainted: {is_tainted(var_tainted, contract)}") assert is_tainted(var_tainted, contract) print(f"{var_not_tainted} is tainted: {is_tainted(var_not_tainted, contract)}") assert not is_tainted(var_not_tainted, contract) + +print("SimpleModifier contract") +contracts = slither.get_contract_from_name("SimpleModifier") +assert len(contracts) == 1 +contract = contracts[0] +dependent_state_var = contract.get_state_variable_from_name("owner") +assert dependent_state_var +baz = contract.get_modifier_from_signature("baz()") +intermediate = baz.get_local_variable_from_name("intermediate") +assert intermediate +print( + f"{intermediate} depends on msg.sender: {is_dependent(intermediate, SolidityVariableComposed('msg.sender'), baz)}" +) +assert is_dependent(intermediate, SolidityVariableComposed("msg.sender"), baz) diff --git a/examples/scripts/data_dependency.sol b/examples/scripts/data_dependency.sol index a4f64870a..b4baf5c09 100644 --- a/examples/scripts/data_dependency.sol +++ b/examples/scripts/data_dependency.sol @@ -115,3 +115,12 @@ contract PropagateThroughReturnValue { return (var_state); } } + +contract SimpleModifier { + address owner; + modifier baz { + bool intermediate = msg.sender == owner; + require(intermediate); + _; + } +} \ No newline at end of file