Add CFG Printer

pull/87/head
Josselin 6 years ago
parent c8952db2ed
commit 8452b32190
  1. 4
      slither/__main__.py
  2. 24
      slither/printers/functions/cfg.py

@ -168,6 +168,7 @@ def get_detectors_and_printers():
from slither.printers.functions.authorization import PrinterWrittenVariablesAndAuthorization from slither.printers.functions.authorization import PrinterWrittenVariablesAndAuthorization
from slither.printers.summary.slithir import PrinterSlithIR from slither.printers.summary.slithir import PrinterSlithIR
from slither.printers.summary.human_summary import PrinterHumanSummary from slither.printers.summary.human_summary import PrinterHumanSummary
from slither.printers.functions.cfg import CFG
printers = [FunctionSummary, printers = [FunctionSummary,
ContractSummary, ContractSummary,
@ -176,7 +177,8 @@ def get_detectors_and_printers():
PrinterCallGraph, PrinterCallGraph,
PrinterWrittenVariablesAndAuthorization, PrinterWrittenVariablesAndAuthorization,
PrinterSlithIR, PrinterSlithIR,
PrinterHumanSummary] PrinterHumanSummary,
CFG]
# Handle plugins! # Handle plugins!
for entry_point in iter_entry_points(group='slither_analyzer.plugin', name=None): for entry_point in iter_entry_points(group='slither_analyzer.plugin', name=None):

@ -0,0 +1,24 @@
"""
"""
from slither.printers.abstract_printer import AbstractPrinter
from slither.core.declarations.function import Function
class CFG(AbstractPrinter):
ARGUMENT = 'cfg'
HELP = 'Export the CFG of each functions'
def output(self, original_filename):
"""
_filename is not used
Args:
_filename(string)
"""
for contract in self.contracts:
for function in contract.functions + contract.modifiers:
filename = "{}-{}-{}.dot".format(original_filename, contract.name, function.full_name)
self.info('Export {}'.format(filename))
function.slithir_cfg_to_dot(filename)
Loading…
Cancel
Save