Clean import detectors/printer in slither/__main__.py

pull/169/head
Josselin 6 years ago
parent b7f50f852a
commit f8897c3f8f
  1. 96
      slither/__main__.py
  2. 32
      slither/detectors/all_detectors.py
  3. 12
      slither/printers/all_printers.py

@ -1,5 +1,7 @@
#!/usr/bin/env python3
import inspect
import argparse
import glob
import json
@ -11,6 +13,8 @@ import subprocess
from pkg_resources import iter_entry_points, require
from slither.detectors import all_detectors
from slither.printers import all_printers
from slither.detectors.abstract_detector import (AbstractDetector,
DetectorClassification)
from slither.printers.abstract_printer import AbstractPrinter
@ -115,92 +119,12 @@ def get_detectors_and_printers():
"""
NOTE: This contains just a few detectors and printers that we made public.
"""
from slither.detectors.examples.backdoor import Backdoor
from slither.detectors.variables.uninitialized_state_variables import UninitializedStateVarsDetection
from slither.detectors.variables.uninitialized_storage_variables import UninitializedStorageVars
from slither.detectors.variables.uninitialized_local_variables import UninitializedLocalVars
from slither.detectors.attributes.constant_pragma import ConstantPragma
from slither.detectors.attributes.incorrect_solc import IncorrectSolc
from slither.detectors.attributes.locked_ether import LockedEther
from slither.detectors.functions.arbitrary_send import ArbitrarySend
from slither.detectors.functions.suicidal import Suicidal
from slither.detectors.functions.complex_function import ComplexFunction
from slither.detectors.reentrancy.reentrancy_benign import ReentrancyBenign
from slither.detectors.reentrancy.reentrancy_read_before_write import ReentrancyReadBeforeWritten
from slither.detectors.reentrancy.reentrancy_eth import ReentrancyEth
from slither.detectors.variables.unused_state_variables import UnusedStateVars
from slither.detectors.variables.possible_const_state_variables import ConstCandidateStateVars
from slither.detectors.statements.tx_origin import TxOrigin
from slither.detectors.statements.assembly import Assembly
from slither.detectors.operations.low_level_calls import LowLevelCalls
from slither.detectors.operations.unused_return_values import UnusedReturnValues
from slither.detectors.naming_convention.naming_convention import NamingConvention
from slither.detectors.functions.external_function import ExternalFunction
from slither.detectors.statements.controlled_delegatecall import ControlledDelegateCall
from slither.detectors.attributes.const_functions import ConstantFunctions
from slither.detectors.shadowing.abstract import ShadowingAbstractDetection
from slither.detectors.shadowing.state import StateShadowing
from slither.detectors.shadowing.local import LocalShadowing
from slither.detectors.shadowing.builtin_symbols import BuiltinSymbolShadowing
from slither.detectors.operations.block_timestamp import Timestamp
from slither.detectors.statements.calls_in_loop import MultipleCallsInLoop
from slither.detectors.statements.incorrect_strict_equality import IncorrectStrictEquality
detectors = [Backdoor,
UninitializedStateVarsDetection,
UninitializedStorageVars,
UninitializedLocalVars,
ConstantPragma,
IncorrectSolc,
ReentrancyBenign,
ReentrancyReadBeforeWritten,
ReentrancyEth,
LockedEther,
ArbitrarySend,
Suicidal,
UnusedStateVars,
TxOrigin,
Assembly,
LowLevelCalls,
NamingConvention,
ConstCandidateStateVars,
#ComplexFunction,
UnusedReturnValues,
ExternalFunction,
ControlledDelegateCall,
ConstantFunctions,
ShadowingAbstractDetection,
StateShadowing,
Timestamp,
MultipleCallsInLoop,
IncorrectStrictEquality,
LocalShadowing,
BuiltinSymbolShadowing]
from slither.printers.summary.function import FunctionSummary
from slither.printers.summary.contract import ContractSummary
from slither.printers.inheritance.inheritance import PrinterInheritance
from slither.printers.inheritance.inheritance_graph import PrinterInheritanceGraph
from slither.printers.call.call_graph import PrinterCallGraph
from slither.printers.functions.authorization import PrinterWrittenVariablesAndAuthorization
from slither.printers.summary.slithir import PrinterSlithIR
from slither.printers.summary.slithir_ssa import PrinterSlithIRSSA
from slither.printers.summary.human_summary import PrinterHumanSummary
from slither.printers.functions.cfg import CFG
from slither.printers.summary.function_ids import FunctionIds
from slither.printers.summary.variables_order import VariablesOrder
printers = [FunctionSummary,
ContractSummary,
PrinterInheritance,
PrinterInheritanceGraph,
PrinterCallGraph,
PrinterWrittenVariablesAndAuthorization,
PrinterSlithIR,
PrinterSlithIRSSA,
PrinterHumanSummary,
CFG,
FunctionIds,
VariablesOrder]
detectors = [getattr(all_detectors, name) for name in dir(all_detectors)]
detectors = [d for d in detectors if inspect.isclass(d) and issubclass(d, AbstractDetector)]
printers = [getattr(all_printers, name) for name in dir(all_printers)]
printers = [p for p in printers if inspect.isclass(p) and issubclass(p, AbstractPrinter)]
# Handle plugins!
for entry_point in iter_entry_points(group='slither_analyzer.plugin', name=None):

@ -0,0 +1,32 @@
from .examples.backdoor import Backdoor
from .variables.uninitialized_state_variables import UninitializedStateVarsDetection
from .variables.uninitialized_storage_variables import UninitializedStorageVars
from .variables.uninitialized_local_variables import UninitializedLocalVars
from .attributes.constant_pragma import ConstantPragma
from .attributes.incorrect_solc import IncorrectSolc
from .attributes.locked_ether import LockedEther
from .functions.arbitrary_send import ArbitrarySend
from .functions.suicidal import Suicidal
#from .functions.complex_function import ComplexFunction
from .reentrancy.reentrancy_benign import ReentrancyBenign
from .reentrancy.reentrancy_read_before_write import ReentrancyReadBeforeWritten
from .reentrancy.reentrancy_eth import ReentrancyEth
from .variables.unused_state_variables import UnusedStateVars
from .variables.possible_const_state_variables import ConstCandidateStateVars
from .statements.tx_origin import TxOrigin
from .statements.assembly import Assembly
from .operations.low_level_calls import LowLevelCalls
from .operations.unused_return_values import UnusedReturnValues
from .naming_convention.naming_convention import NamingConvention
from .functions.external_function import ExternalFunction
from .statements.controlled_delegatecall import ControlledDelegateCall
from .attributes.const_functions import ConstantFunctions
from .shadowing.abstract import ShadowingAbstractDetection
from .shadowing.state import StateShadowing
from .shadowing.local import LocalShadowing
from .shadowing.builtin_symbols import BuiltinSymbolShadowing
from .operations.block_timestamp import Timestamp
from .statements.calls_in_loop import MultipleCallsInLoop
from .statements.incorrect_strict_equality import IncorrectStrictEquality

@ -0,0 +1,12 @@
from .summary.function import FunctionSummary
from .summary.contract import ContractSummary
from .inheritance.inheritance import PrinterInheritance
from .inheritance.inheritance_graph import PrinterInheritanceGraph
from .call.call_graph import PrinterCallGraph
from .functions.authorization import PrinterWrittenVariablesAndAuthorization
from .summary.slithir import PrinterSlithIR
from .summary.slithir_ssa import PrinterSlithIRSSA
from .summary.human_summary import PrinterHumanSummary
from .functions.cfg import CFG
from .summary.function_ids import FunctionIds
from .summary.variables_order import VariablesOrder
Loading…
Cancel
Save