slither icon indicating copy to clipboard operation
slither copied to clipboard

[Bug]: all statements with `.` are reported as external calls

Open mds1 opened this issue 2 years ago • 1 comments

Describe the issue:

I ran slither . --print function-summary to view external calls for functions. The resulting "External Calls" column treats any statement with a . as an external call. This includes solidity built-ins like abi.encode, library accesses like Address.sendValue, and struct field accesses.

Code example to reproduce the issue:

git clone https://github.com/scopelift/pooltogether-governor-upgrade/
cd pooltogether-governor-upgrade
forge install
slither . --print function-summary

Version:

0.9.6

Relevant log output:

No response

mds1 avatar Aug 01 '23 22:08 mds1

Instead of using all call expressions (which include members like abi.encode), we should use the expression of the HighLevelCall filtered from all the operations (https://crytic.github.io/slither/slither/core/declarations/function.html#Function.all_slithir_operations)

https://github.com/crytic/slither/blob/fdf54f624d8c468afb3d8197eb9e98e377dac440/slither/core/declarations/function_contract.py#L116

EDIT: What external_calls_as_expressions returns seems wrong as the comment says it should be calls which create a message (new call frame). Instead I think it would work to filter out SolidityVariable here https://github.com/crytic/slither/blob/fdf54f624d8c468afb3d8197eb9e98e377dac440/slither/vyper_parsing/cfg/node.py#L62 https://github.com/crytic/slither/blob/fdf54f624d8c468afb3d8197eb9e98e377dac440/slither/solc_parsing/yul/parse_yul.py#L95 https://github.com/crytic/slither/blob/fdf54f624d8c468afb3d8197eb9e98e377dac440/slither/solc_parsing/cfg/node.py#L66

0xalpharush avatar Apr 10 '24 16:04 0xalpharush