diff --git a/plugin_example/README.md b/plugin_example/README.md new file mode 100644 index 000000000..fc711f5d1 --- /dev/null +++ b/plugin_example/README.md @@ -0,0 +1,19 @@ +# Slither, Plugin Example + +This repo contains an example of plugin for Slither. + +See the [detector documentation](https://github.com/trailofbits/slither/wiki/Adding-a-new-detector). + +## Architecture + +- `setup.py`: Contain the plugin information +- `slither_my_plugin/__init__.py`: Contain `make_plugin()`. The function must return the list of new detectors and printers +- `slither_my_plugin/detectors/example.py`: Detector plugin skeleton. + +Once these files are updated with your plugin, you can install it: +``` +python setup.py develop +``` + +We recommend to use a Python virtual environment (for example: [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/)). + diff --git a/plugin_example/setup.py b/plugin_example/setup.py new file mode 100644 index 000000000..2890e224f --- /dev/null +++ b/plugin_example/setup.py @@ -0,0 +1,17 @@ +from setuptools import setup, find_packages + +setup( + name='slither-my-plugins', + description='This is an example of detectors and printers to Slither.', + url='https://github.com/trailofbits/slither-plugins', + author='Trail of Bits', + version='0.0', + packages=find_packages(), + python_requires='>=3.6', + install_requires=[ + 'slither-analyzer==0.1' + ], + entry_points={ + 'slither_analyzer.plugin': 'slither my-plugin=slither_my_plugin:make_plugin', + } +) diff --git a/plugin_example/slither_my_plugin/__init__.py b/plugin_example/slither_my_plugin/__init__.py new file mode 100644 index 000000000..eabdb147e --- /dev/null +++ b/plugin_example/slither_my_plugin/__init__.py @@ -0,0 +1,8 @@ +from slither_my_plugin.detectors.example import Example + + +def make_plugin(): + plugin_detectors = [Example] + plugin_printers = [] + + return plugin_detectors, plugin_printers diff --git a/plugin_example/slither_my_plugin/detectors/example.py b/plugin_example/slither_my_plugin/detectors/example.py new file mode 100644 index 000000000..20e249e28 --- /dev/null +++ b/plugin_example/slither_my_plugin/detectors/example.py @@ -0,0 +1,18 @@ + +from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification + + +class Example(AbstractDetector): + """ + Documentation + """ + + ARGUMENT = 'mydetector' # slither will launch the detector with slither.py --mydetector + HELP = 'Help printed by slither' + CLASSIFICATION = DetectorClassification.HIGH + + def detect(self): + + self.logger('Nothing to detect!') + + return []