From d7c5809ea884878f558144dd547e2ba644e89b89 Mon Sep 17 00:00:00 2001 From: Illia Bobyr Date: Fri, 3 Sep 2021 17:55:29 -0700 Subject: [PATCH 1/2] Handle ignore markers when `exclude-dependencies` is set `valid_results` behaviour is described in terms of "results are valid, unless ...". A matching implementation would be to only return `True` a the end of the function, and have all the cases only return `False` if they detect an invalid result. `show-ignored-findings` is the only exception to the rule above. --- slither/core/slither_core.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/slither/core/slither_core.py b/slither/core/slither_core.py index 77f64ccd2..d43430c42 100644 --- a/slither/core/slither_core.py +++ b/slither/core/slither_core.py @@ -46,7 +46,7 @@ class SlitherCore(Context): self._previous_results_ids: Set[str] = set() # Every slither object has a list of result from detector # Because of the multiple compilation support, we might analyze - # Multiple time the same result, so we remove dupplicate + # Multiple time the same result, so we remove duplicates self._currently_seen_resuts: Set[str] = set() self._paths_to_filter: Set[str] = set() @@ -207,7 +207,7 @@ class SlitherCore(Context): - There is an ignore comment on the preceding line """ - # Remove dupplicate due to the multiple compilation support + # Remove duplicate due to the multiple compilation support if r["id"] in self._currently_seen_resuts: return False self._currently_seen_resuts.add(r["id"]) @@ -240,7 +240,8 @@ class SlitherCore(Context): if r["elements"] and matching: return False if r["elements"] and self._exclude_dependencies: - return not all(element["source_mapping"]["is_dependency"] for element in r["elements"]) + if all(element["source_mapping"]["is_dependency"] for element in r["elements"]): + return False if self._show_ignored_findings: return True if r["id"] in self._previous_results_ids: @@ -248,7 +249,10 @@ class SlitherCore(Context): if self.has_ignore_comment(r): 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] + if r["description"] in [pr["description"] for pr in self._previous_results]: + return False + + return True def load_previous_results(self): filename = self._previous_results_filename From 3d7344e85fd105ce76648ed1d4d2e3d4e683b6c0 Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Mon, 1 Aug 2022 16:51:45 +0200 Subject: [PATCH 2/2] Re-order --- slither/core/slither_core.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/slither/core/slither_core.py b/slither/core/slither_core.py index 7d7d1ffb8..77f172c96 100644 --- a/slither/core/slither_core.py +++ b/slither/core/slither_core.py @@ -245,9 +245,7 @@ class SlitherCore(Context): if r["elements"] and matching: return False - if r["elements"] and self._exclude_dependencies: - if all(element["source_mapping"]["is_dependency"] for element in r["elements"]): - return False + if self._show_ignored_findings: return True if self.has_ignore_comment(r): @@ -255,7 +253,8 @@ class SlitherCore(Context): if r["id"] in self._previous_results_ids: return False if r["elements"] and self._exclude_dependencies: - return not all(element["source_mapping"]["is_dependency"] for element in r["elements"]) + if all(element["source_mapping"]["is_dependency"] for element in r["elements"]): + return False # Conserve previous result filtering. This is conserved for compatibility, but is meant to be removed if r["description"] in [pr["description"] for pr in self._previous_results]: return False