diff --git a/setup.py b/setup.py index 8ab6a4b2f..9b2010206 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages setup( - name='slither-sol', + name='slither-analyzer', description='Slither is a Solidity static analysis framework written in Python 3.', url='https://github.com/trailofbits/slither', author='Trail of Bits', diff --git a/slither/__main__.py b/slither/__main__.py index b465a4cbf..bd8c787a2 100644 --- a/slither/__main__.py +++ b/slither/__main__.py @@ -8,9 +8,11 @@ import os import sys import traceback -from slither.slither import Slither +from pkg_resources import iter_entry_points -from slither.detectors.abstract_detector import DetectorClassification +from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification +from slither.printers.abstract_printer import AbstractPrinter +from slither.slither import Slither logging.basicConfig() logger = logging.getLogger("Slither") @@ -77,6 +79,22 @@ def main(): printers = [PrinterSummary, PrinterQuickSummary, PrinterInheritance, PrinterWrittenVariablesAndAuthorization] + # Handle plugins! + for entry_point in iter_entry_points(group='slither_analyzer.plugin', name=None): + make_plugin = entry_point.load() + + plugin_detectors, plugin_printers = make_plugin() + + if not all(issubclass(d, AbstractDetector) for d in plugin_detectors): + raise Exception('Error when loading plugin %s, %r is not a detector' % (entry_point, d)) + + if not all(issubclass(p, AbstractPrinter) for p in plugin_printers): + raise Exception('Error when loading plugin %s, %r is not a printer' % (entry_point, p)) + + # We convert those to lists in case someone returns a tuple + detectors += list(plugin_detectors) + printers += list(plugin_printers) + main_impl(all_detector_classes=detectors, all_printer_classes=printers)