Merge branch 'dev' into dev-ssa

pull/87/head
Josselin 6 years ago
commit d33c3e8b83
  1. 15
      slither/__main__.py
  2. 6
      slither/slithir/operations/return_operation.py
  3. 28
      slither/utils/command_line.py

@ -16,7 +16,7 @@ from slither.detectors.abstract_detector import (AbstractDetector,
from slither.printers.abstract_printer import AbstractPrinter
from slither.slither import Slither
from slither.utils.colors import red
from slither.utils.command_line import output_to_markdown, output_detectors, output_printers
from slither.utils.command_line import output_to_markdown, output_detectors, output_printers, output_detectors_json
logging.basicConfig()
logger = logging.getLogger("Slither")
@ -387,6 +387,12 @@ def parse_args(detector_classes, printer_classes):
nargs=0,
default=False)
parser.add_argument('--list-detectors-json',
help=argparse.SUPPRESS,
action=ListDetectorsJson,
nargs=0,
default=False)
parser.add_argument('--compact-ast',
help=argparse.SUPPRESS,
action='store_true',
@ -406,6 +412,12 @@ class ListDetectors(argparse.Action):
output_detectors(detectors)
parser.exit()
class ListDetectorsJson(argparse.Action):
def __call__(self, parser, *args, **kwargs):
detectors, _ = get_detectors_and_printers()
output_detectors_json(detectors)
parser.exit()
class ListPrinters(argparse.Action):
def __call__(self, parser, *args, **kwargs):
_, printers = get_detectors_and_printers()
@ -419,6 +431,7 @@ class OutputMarkdown(argparse.Action):
parser.exit()
def choose_detectors(args, all_detector_classes):
# If detectors are specified, run only these ones

@ -12,8 +12,10 @@ class Return(Operation):
# ex: return call()
# where call() dont return
if not isinstance(values, list):
assert is_valid_rvalue(values) or isinstance(values, TupleVariable) or values == None
if not values is None:
assert is_valid_rvalue(values) or isinstance(values, TupleVariable) or values is None
if values is None:
values = []
else:
values = [values]
else:
for value in values:

@ -1,3 +1,4 @@
import json
from prettytable import PrettyTable
from slither.detectors.abstract_detector import classification_txt
@ -70,6 +71,33 @@ def output_detectors(detector_classes):
idx = idx + 1
print(table)
def output_detectors_json(detector_classes):
detectors_list = []
for detector in detector_classes:
argument = detector.ARGUMENT
# dont show the backdoor example
if argument == 'backdoor':
continue
help_info = detector.HELP
impact = detector.IMPACT
confidence = classification_txt[detector.CONFIDENCE]
wiki = detector.WIKI
detectors_list.append((argument, help_info, impact, confidence, wiki))
# Sort by impact, confidence, and name
detectors_list = sorted(detectors_list, key=lambda element: (element[2], element[3], element[0]))
idx = 1
table = []
for (argument, help_info, impact, confidence, wiki) in detectors_list:
table.append({'index': idx,
'check': argument,
'description': help_info,
'impact': classification_txt[impact],
'confidence': confidence,
'wiki': wiki})
idx = idx + 1
print(json.dumps(table))
def output_printers(printer_classes):
printers_list = []
for printer in printer_classes:

Loading…
Cancel
Save