Plugin architecture works

pull/17/head
disconnect3d 6 years ago
parent 0d13cdf7c7
commit 96e8da1411
  1. 2
      setup.py
  2. 22
      slither/__main__.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',

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

Loading…
Cancel
Save