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

filter_paths filters results only after running detector #2026

Open
Yhtiyar opened this issue Jul 4, 2023 · 3 comments
Open

filter_paths filters results only after running detector #2026

Yhtiyar opened this issue Jul 4, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@Yhtiyar
Copy link

Yhtiyar commented Jul 4, 2023

The problem:
On projects with large amounts of dependencies and especially in foundry projects (if there are lots of tests/scripts), sometimes it takes a lot of time to run the detectors.

Even though the directory/contracts might be specified in filter_paths, the slither first runs the detector on these contracts and filters out only afterward.
https://github.com/crytic/slither/blob/977d7bfeabff6ed90faadbe2ee1423bfe04ff5cb/slither/core/slither_core.py#L413C9-L421C1

It seems like we cannot just filter out the contracts from detector.contracts, because some detectors might need access to these contracts. However, is it possible to build some kind of dependency graph and filter out the contracts that are not depended on, by the contracts which are not in filter_paths?

Or some kind of do_not_run/ignore parameter, which totally removes the contracts from running detectors?

@0xalpharush
Copy link
Contributor

0xalpharush commented Jul 4, 2023

This is being worked on. Instead of implementing a dependency graph, we've created a PR upstream in Foundry that allows skipping building scripts and tests (foundry-rs/foundry#5267). We still need to expose this as a flag/ config and appreciate input on that (crytic/crytic-compile#435)

In the meantime, you can run forge build --build-info --skip '*/test/**' --skip '*/script/**' --force && slither . --ignore-compile to achieve this behavior (this requires upgrading Foundry to include the recently merged PR).

@Yhtiyar
Copy link
Author

Yhtiyar commented Jul 4, 2023

Thanks!
Also, I have made a PR on crytic-compile: crytic/crytic-compile#466

@0xmichalis
Copy link

@0xalpharush I guess for Hardhat you'd need support for NomicFoundation/hardhat#2306 ?

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

No branches or pull requests

3 participants