From 43833fa577e835008e85b10dfc246a3fe96c8c07 Mon Sep 17 00:00:00 2001 From: manuelsommer <47991713+manuel-sommer@users.noreply.github.com> Date: Fri, 22 Nov 2024 06:27:07 +0100 Subject: [PATCH] :bug: fix trivyoperator tags (#11276) * :bug: fix trivyoperator tags * ruff * fix unittest * review * ruff --- dojo/tools/trivy_operator/checks_handler.py | 3 ++- dojo/tools/trivy_operator/secrets_handler.py | 3 ++- dojo/tools/trivy_operator/vulnerability_handler.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dojo/tools/trivy_operator/checks_handler.py b/dojo/tools/trivy_operator/checks_handler.py index 2a260ff5680..66e4199cfb7 100644 --- a/dojo/tools/trivy_operator/checks_handler.py +++ b/dojo/tools/trivy_operator/checks_handler.py @@ -45,8 +45,9 @@ def handle_checks(self, labels, checks, test): static_finding=True, dynamic_finding=False, service=service, - tags=[resource_namespace], ) + if resource_namespace != "": + finding.tags = resource_namespace if check_id: finding.unsaved_vulnerability_ids = [UniformTrivyVulnID().return_uniformed_vulnid(check_id)] findings.append(finding) diff --git a/dojo/tools/trivy_operator/secrets_handler.py b/dojo/tools/trivy_operator/secrets_handler.py index 6509835b4f1..018c3650c39 100644 --- a/dojo/tools/trivy_operator/secrets_handler.py +++ b/dojo/tools/trivy_operator/secrets_handler.py @@ -53,7 +53,8 @@ def handle_secrets(self, labels, secrets, test): static_finding=True, dynamic_finding=False, service=service, - tags=[resource_namespace], ) + if resource_namespace != "": + finding.tags = resource_namespace findings.append(finding) return findings diff --git a/dojo/tools/trivy_operator/vulnerability_handler.py b/dojo/tools/trivy_operator/vulnerability_handler.py index 99faa009d1b..54a951cdc3f 100644 --- a/dojo/tools/trivy_operator/vulnerability_handler.py +++ b/dojo/tools/trivy_operator/vulnerability_handler.py @@ -83,7 +83,7 @@ def handle_vulns(self, labels, vulnerabilities, test): dynamic_finding=False, service=service, file_path=file_path, - tags=finding_tags, + tags=[tag for tag in finding_tags if tag != ""], ) if vuln_id: finding.unsaved_vulnerability_ids = [UniformTrivyVulnID().return_uniformed_vulnid(vuln_id)]