Add plugin skeleton

pull/21/head
Josselin 6 years ago
parent 14643f5eca
commit 5930e4ca6b
  1. 19
      plugin_example/README.md
  2. 17
      plugin_example/setup.py
  3. 8
      plugin_example/slither_my_plugin/__init__.py
  4. 18
      plugin_example/slither_my_plugin/detectors/example.py

@ -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/)).

@ -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',
}
)

@ -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

@ -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 []
Loading…
Cancel
Save