Skip to content

Commit 6512079

Browse files
committed
fix(exclusions): excluding results against files in the scanners directory
1 parent d589712 commit 6512079

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

automated_security_helper/core/phases/scan_phase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,6 @@ def _process_results(
962962
)
963963
sanitized_sarif = apply_suppressions_to_sarif(
964964
sarif_report=sanitized_sarif,
965-
plugin_context=self.plugin_context,
966965
ignore_paths=self.plugin_context.config.global_settings.ignore_paths
967966
or [],
968967
)

automated_security_helper/utils/sarif_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import os
44
from pathlib import Path
5+
import re
56
from typing import List
6-
from automated_security_helper.base.plugin_context import PluginContext
77
from automated_security_helper.schemas.sarif_schema_model import (
88
Kind,
99
Level,
@@ -235,7 +235,6 @@ def path_matches_pattern(path: str, pattern: str) -> bool:
235235

236236
def apply_suppressions_to_sarif(
237237
sarif_report: SarifReport,
238-
plugin_context: PluginContext,
239238
ignore_paths: List[IgnorePathWithReason] = [],
240239
) -> SarifReport:
241240
"""
@@ -255,7 +254,6 @@ def apply_suppressions_to_sarif(
255254
or len(ignore_paths) == 0
256255
):
257256
return sarif_report
258-
scanners_path = plugin_context.output_dir.joinpath("scanners")
259257
for run in sarif_report.runs:
260258
if not run.results:
261259
continue
@@ -271,7 +269,9 @@ def apply_suppressions_to_sarif(
271269
):
272270
uri = location.physicalLocation.root.artifactLocation.uri
273271
if uri:
274-
if Path(uri).relative_to(scanners_path):
272+
if re.match(
273+
pattern=r"scanners[\/\\]+[\w-]+[\/\\]+(source|converted)[\/\\]+"
274+
):
275275
ASH_LOGGER.verbose(
276276
f"Excluding result, location is in scanners path and should not have been included: {uri}"
277277
)

0 commit comments

Comments
 (0)