Rename interactive-mode to triage-mode

Improve triage input robustness
pull/172/head
Josselin 6 years ago
parent 018eb8f7c0
commit 8298c11bc8
  1. 12
      slither/__main__.py
  2. 22
      slither/detectors/abstract_detector.py
  3. 1
      slither/detectors/examples/backdoor.py
  4. 10
      slither/slither.py

@ -49,7 +49,7 @@ def process(filename, args, detector_classes, printer_classes):
solc_arguments=args.solc_args,
ast_format=ast,
filter_paths=parse_filter_paths(args),
interactive_mode=args.interactive_mode)
triage_mode=args.triage_mode)
return _process(slither, detector_classes, printer_classes)
@ -107,7 +107,7 @@ def process_truffle(dirname, args, detector_classes, printer_classes):
solc_arguments=args.solc_args,
is_truffle=True,
filter_paths=parse_filter_paths(args),
interactive_mode=args.interactive_mode)
triage_mode=args.triage_mode)
return _process(slither, detector_classes, printer_classes)
@ -125,7 +125,7 @@ def process_files(filenames, args, detector_classes, printer_classes):
disable_solc_warnings=args.disable_solc_warnings,
solc_arguments=args.solc_args,
filter_paths=parse_filter_paths(args),
interactive_mode=args.interactive_mode)
triage_mode=args.triage_mode)
return _process(slither, detector_classes, printer_classes)
@ -399,10 +399,10 @@ def parse_args(detector_classes, printer_classes):
dest='ignore_truffle_compile',
default=defaults_flag_in_config['ignore_truffle_compile'])
group_misc.add_argument('--interactive-mode',
help='Run interactive mode (save results in slither.db.json)',
group_misc.add_argument('--triage-mode',
help='Run triage mode (save results in slither.db.json)',
action='store_true',
dest='interactive_mode',
dest='triage_mode',
default=False)
group_misc.add_argument('--config-file',

@ -108,23 +108,29 @@ class AbstractDetector(metaclass=abc.ABCMeta):
if self.logger:
info = '\n'
for idx, result in enumerate(results):
if self.slither.interactive_mode:
if self.slither.triage_mode:
info += '{}: '.format(idx)
info += result['description']
info += 'Reference: {}'.format(self.WIKI)
self._log(info)
if results and self.slither.interactive_mode:
not_well_formed = True
while not_well_formed:
indexes = input('Results to hide "0,1,..." or "All" (enter to not hide results): '.format(len(results)))
if results and self.slither.triage_mode:
while True:
indexes = input('Results to hide during next runs: "0,1,..." or "All" (enter to not hide results): '.format(len(results)))
if indexes == 'All':
self.slither.save_results_to_hide(results)
return []
if indexes == '':
return results
indexes = [int(i) for i in indexes.split(',')]
self.slither.save_results_to_hide([r for (idx, r) in enumerate(results) if idx in indexes])
return [r for (idx, r) in enumerate(results) if idx not in indexes]
if indexes.startswith('['):
indexes = indexes[1:]
if indexes.endswith(']'):
indexes = indexes[:-1]
try:
indexes = [int(i) for i in indexes.split(',')]
self.slither.save_results_to_hide([r for (idx, r) in enumerate(results) if idx in indexes])
return [r for (idx, r) in enumerate(results) if idx not in indexes]
except ValueError:
self.logger.error(yellow('Malformed input. Example of valid input: 0,1,2,3'))
return results

@ -33,5 +33,4 @@ class Backdoor(AbstractDetector):
self.add_function_to_json(f, json)
results.append(json)
return results

@ -30,7 +30,7 @@ class Slither(SlitherSolc):
ast_format (str): ast format (default '--ast-compact-json')
is_truffle (bool): is a truffle directory (default false)
filter_paths (list(str)): list of path to filter (default [])
interactive_mode (bool): if true, switch to interactive mode (default false)
triage_mode (bool): if true, switch to triage mode (default false)
'''
is_truffle = kwargs.get('is_truffle', False)
@ -52,8 +52,8 @@ class Slither(SlitherSolc):
for p in filter_paths:
self.add_path_to_filter(p)
interactive_mode = kwargs.get('interactive_mode', False)
self._interactive_mode = interactive_mode
triage_mode = kwargs.get('triage_mode', False)
self._triage_mode = triage_mode
self._analyze_contracts()
@ -217,5 +217,5 @@ class Slither(SlitherSolc):
return stdout
@property
def interactive_mode(self):
return self._interactive_mode
def triage_mode(self):
return self._triage_mode

Loading…
Cancel
Save