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

deregister_detector #1722

Merged
merged 6 commits into from
Mar 10, 2023
Merged

deregister_detector #1722

merged 6 commits into from
Mar 10, 2023

Conversation

sidarth16
Copy link
Contributor

This function would be helpful to de-register a detector class from the list of detectors already registered with the slither object.

This function would be helpful to de-register a detector class from the list of detectors already registered with the slither object
return on removing the first hit itself, as there can't be multiple objects of the same detector class in the _detectors.
@sidarth16
Copy link
Contributor Author

sidarth16 commented Mar 8, 2023

The major issue it solves is the reusing of the same slither Object for multiple detector classes.
Example:

from slither.detectors.all_detectors import *
from slither.slither import Slither

sl = Slither("<contract_address>")

detectors = [TxOrigin, ReentrancyBenign, ReentrancyEth, UncheckedTransfer, UncheckedSend]
for d in detectors:
    sl.register_detector(d)  
r1 = sl.run_detectors()

# Now I no more want TxOrigin in the context slither object detectors

sl.unregister_detector(TxOrigin)

r2 = sl.run_detectors()

Thus, We are now able to re-run detectors , reusing the same slither object. We don't need to declare new slither object for each combination of detector classes.

Here r1, contains results of TxOrigin , while r2 does not contain results of TxOrigin .

slither/slither.py Outdated Show resolved Hide resolved
slither/slither.py Outdated Show resolved Hide resolved
@0xalpharush
Copy link
Contributor

It would be great to have a test case. I haven't looked into it but this might have weird effects on detector result filtering.

@montyly
Copy link
Member

montyly commented Mar 10, 2023

Note that some detectors cache the results (ex: the reentrancies detectors), so running multiple times will not lead to a fresh run.

I am not sure what is your goal with this API, but you should be aware that detectors are not side-effects free ;)

@montyly montyly merged commit 462da76 into crytic:dev Mar 10, 2023
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

Successfully merging this pull request may close these issues.

3 participants