Slither's plugin architecture lets you integrate new detectors that run from the command-line.
Detector Skeleton
The skeleton for a detector is:
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
class Skeleton(AbstractDetector):
    """
    Documentation
    """
    ARGUMENT = 'mydetector' # slither will launch the detector with slither.py --detect mydetector
    HELP = 'Help printed by slither'
    IMPACT = DetectorClassification.HIGH
    CONFIDENCE = DetectorClassification.HIGH
    WIKI = ''
    WIKI_TITLE = ''
    WIKI_DESCRIPTION = ''
    WIKI_EXPLOIT_SCENARIO = ''
    WIKI_RECOMMENDATION = ''
    def _detect(self):
        info = ['This is an example']
        res = self.generate_result(info)
        return [res]
- ARGUMENTlets you run the detector from the command-line
- HELPis the information printed from the command-line
- IMPACTindicates the impact of the issue. Allowed values are:- DetectorClassification.OPTIMIZATION: printed in green
- DetectorClassification.INFORMATIONAL: printed in green
- DetectorClassification.LOW: printed in green
- DetectorClassification.MEDIUM: printed in yellow
- DetectorClassification.HIGH: printed in red
 
- CONFIDENCEindicates your confidence in the analysis. Allowed values are:- DetectorClassification.LOW
- DetectorClassification.MEDIUM
- DetectorClassification.HIGH
 
- WIKIconstants are used to generate automatically the documentation.
_detect() needs to return a list of findings. A finding is an element generated with self.generate_result(info), where info is a list of text or contract's object (contract, function, node, ...)
An AbstractDetector object has the slither attribute, which returns the current Slither object.
Integration
You can integrate your detector into Slither by:
- Adding it in slither/detectors/all_detectors.py
- or, by creating a plugin package (see the skeleton example).
Test the detector
See CONTRIBUTING.md#development-environment
Example
backdoor.py will detect any function with backdoor in its name.