Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to judge whether there is a "if" in a expression #2620

Open
alexanderhawl opened this issue Dec 24, 2024 · 1 comment
Open

how to judge whether there is a "if" in a expression #2620

alexanderhawl opened this issue Dec 24, 2024 · 1 comment

Comments

@alexanderhawl
Copy link

alexanderhawl commented Dec 24, 2024

function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address, // initiator, bytes calldata params ) external returns (bool) { address pool = IAaveV2Provider(radiantV2Provider).getLendingPool(); if (msg.sender != pool) revert InvalidCaller(); bool charge;

in this code snippet, there is a if sentence about msg.sender, but how to use slither to find it? I tried use func.expressions, but it can't get the right answer.

@0xalpharush
Copy link
Contributor

See

def get_msg_sender_checks(function: Function) -> List[str]:
all_functions = (
[f for f in function.all_internal_calls() if isinstance(f, Function)]
+ [function]
+ [m for m in function.modifiers if isinstance(m, Function)]
)
all_nodes_ = [f.nodes for f in all_functions]
all_nodes = [item for sublist in all_nodes_ for item in sublist]
all_conditional_nodes = [
n for n in all_nodes if n.contains_if() or n.contains_require_or_assert()
]
all_conditional_nodes_on_msg_sender = [
str(n.expression)
for n in all_conditional_nodes
if "msg.sender" in [v.name for v in n.solidity_variables_read]
]
return all_conditional_nodes_on_msg_sender

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants