-
Notifications
You must be signed in to change notification settings - Fork 982
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
Add support for filtering printer output #2233
Comments
regex is not needed, all of the listed information is available to slither as formatted py object (string) in either Function or Contract class. i think the Issue could be generalized to better control over any output as slither relies extensively on prettyTable for formatting cli display and on the other hand complex json data type for output with --json flag. both of those have drawbacks when integrating with other external to slither scripts. amazingly, as much as Slither allows for easy integration directly with Class objects, it's output pipeline is pretty "hardcoded" from what I've seen some middleware allowing for specifying custom ouput easily is good idea (say, simplified-json). either in form of a standalone method accessible from the core (by user or other slither classes) or as a separate util. |
hi @lucas-manuel 👋🏽 Great idea. We have talked about making Making I can work on this when I have some time (soon ™️) or if someone else wants to take a shot at implementing this we can provide guidance. |
@lucas-manuel @devtooligan @0xalpharush if you are fine with having this as a separate "tool" and not as a "printer", I can make a PR today, just green-light following logic and reasoning behind it:
example use case: "Return all functions without get* at the start that are external, have external calls, don't have any modifiers, and modify state." example input:
where, 1 or 0 for true/fals, if --ext-call 1 == include all functions that make AT LEAST 1 external call returns: functions matching criteria printed to cli (guidance as to this may be needed, i didn't spent that much time on Output class, PR will just print to cli initially) |
@shortdoom yes a tool would be totally fine with me, that sounds good! |
Just a heads up that we are likely moving towards subcommands and that work may conflict. We may be able to make the filter a global arg and pass that down to the
@shortdoom I've been thinking about a way to expose info in a way that's easier to query. If we replaced the printer table output with something more structured that can be parsed we can do something like the following. This example queries for writes to |
i made a "draft" PR. it doesn't include requested regex matching but it's straight forward to implement if needed. i followed existing implementation of parser without sub-commands for now as this is the current state of as for the better control of outputs, I'll comment in the referenced Issue after having some closer look. but I am of a biased opinion that Python API outputs should be prioritized over cli for restructuring. for larger codebases API integration is go-to solution over parsing cli output. for cli I think that standardization of output is enough - making output parsable ie. |
Describe the desired feature
It would be great to have more control over outputs from printers, specifically table formatted ones such as
function-summary
andvars-and-auth
.Using
function-summary
as an example, it would be great to be able to filter the following (regex would be sufficient for all probably):Using regex a user could have full flexibility to filter out based on specifics or based on whether something is empty
"Return all functions without
get*
at the start that are external, have external calls, don't have any modifiers, and modify state."The text was updated successfully, but these errors were encountered: