Filter known results using their ID

pull/367/head
Josselin 5 years ago
parent be3bd84630
commit 38077ce077
  1. 9
      slither/core/slither_core.py
  2. 2
      slither/utils/output.py

@ -32,11 +32,13 @@ class Slither(Context):
self._previous_results_filename = 'slither.db.json'
self._results_to_hide = []
self._previous_results = []
self._previous_results_ids = set()
self._paths_to_filter = set()
self._crytic_compile = None
self._generate_patches = False
self._exclude_dependencies = False
self._markdown_root = ""
@ -216,6 +218,9 @@ class Slither(Context):
if r['elements'] and self._exclude_dependencies:
return not all(element['source_mapping']['is_dependency'] for element in r['elements'])
if r['id'] in self._previous_results_ids:
return False
# Conserve previous result filtering. This is conserved for compatibility, but is meant to be removed
return not r['description'] in [pr['description'] for pr in self._previous_results]
def load_previous_results(self):
@ -224,6 +229,10 @@ class Slither(Context):
if os.path.isfile(filename):
with open(filename) as f:
self._previous_results = json.load(f)
if self._previous_results:
for r in self._previous_results:
if 'id' in r:
self._previous_results_ids.add(r['id'])
except json.decoder.JSONDecodeError:
logger.error(red('Impossible to decode {}. Consider removing the file'.format(filename)))

@ -186,7 +186,7 @@ class Output:
self._data['elements'] = []
self._data['description'] = ''.join(_convert_to_description(d) for d in info)
self._data['markdown'] = ''.join(_convert_to_markdown(d, markdown_root) for d in info)
id_txt = ''.join(_convert_to_id(d) for d in info)
self._data['id'] = hashlib.sha3_256(id_txt.encode('utf-8')).hexdigest()

Loading…
Cancel
Save