-
Notifications
You must be signed in to change notification settings - Fork 975
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
slither-function-filter tool #2238
base: dev
Are you sure you want to change the base?
Conversation
I had wanted something similar and made a note to myself:
I think that this is a decent start but I would imagine showing the source and line info so that it can be quickly examined or jumped to in the editor would be better. Wdyt? |
Some time passed from this PR but I remember that choosing exact So you won't need this part of the command:
Current version was designed as query contract to find function. It's an interesting direction to also allow some grepping at the level of Function itself (has_require, has_loop, etc.). I noticed you also included I also agree on adding one more string input flag to allow to find a specific function by Showing source code of a Function is trickier UX-wise. Some functions will be long and cli output will get cluttered. Hence why I resorted to displaying structured info (it tends to be more or less the same length). Displaying a line reference is a great idea, most IDEs will just allow to jump automatically and we could avoid displaying source code in terminal. To have a full grep like tool we could allow to actually grep the function's source code without cluttering the cli though!
I can ofc bring this PR home. |
Also, wouldn't it be cool to have it as PythonAPI? This is how I actually implemented it for my own use, as an external class taking a list of Function to filter, returning Function(s) matching. I needed to resort to writing an external query class because there's no API (and this PR also doesn't propose it in the current state) |
Important Auto Review SkippedAuto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Added Added more filters:
slither-function-filter.webmI think that covers most immediate needs we've seen mentioned by developers? PS. It works best with the crytic-compile patch that's already merged but not yet released. If |
reference: #2233
slither-function-filter
tool. for the time being it supports basic flag-based filtering (no way to specify details of search, only true/false)two example inputs:
slither-function-filter contract.sol --visibility external --modifiers --ext-calls
orslither-function-filter contract.sol --read-only
etc.so, it's possible to:
"Return all functions that are {visibility}, have/don't have internal OR external calls , have/don't have modifiers, are/aren't mutable (involve a potential state change)"
all allowed flags:
every flag is optional, if none is specified, all contract functions will be returned, all flags are allowed to be mixed
implementation is focused around output of function.get_summary() but filter_functions() is easy to extend.
output is formatted in logger and with coloring.