Skip to content

Commit

Permalink
🎉 All Trivy Operator findings in one json
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-sommer committed Nov 13, 2024
1 parent 7abf301 commit 797549d
Show file tree
Hide file tree
Showing 3 changed files with 685 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dojo/tools/trivy_operator/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def get_description_for_scan_types(self, scan_type):

def get_findings(self, scan_file, test):
scan_data = scan_file.read()

try:
data = json.loads(str(scan_data, "utf-8"))
except Exception:
Expand All @@ -29,6 +28,11 @@ def get_findings(self, scan_file, test):
if type(data) is list:
for listitems in data:
findings += self.output_findings(listitems, test)
elif type(data) is dict and bool(set(data.keys()) & set(["clustercompliancereports.aquasecurity.github.io", "clusterconfigauditreports.aquasecurity.github.io", "clusterinfraassessmentreports.aquasecurity.github.io", "clusterrbacassessmentreports.aquasecurity.github.io", "clustersbomreports.aquasecurity.github.io", "configauditreports.aquasecurity.github.io", "exposedsecretreports.aquasecurity.github.io", "infraassessmentreports.aquasecurity.github.io", "rbacassessmentreports.aquasecurity.github.io", "sbomreports.aquasecurity.github.io", "vulnerabilityreports.aquasecurity.github.io"])):

Check failure on line 31 in dojo/tools/trivy_operator/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (C405)

dojo/tools/trivy_operator/parser.py:31:61: C405 Unnecessary `list` literal (rewrite as a `set` literal)
for datakey in list(data.keys()):
# if datakey not in ["clustersbomreports.aquasecurity.github.io", "sbomreports.aquasecurity.github.io"]:
for listitems in (data[datakey]):
findings += self.output_findings(listitems, test)
else:
findings += self.output_findings(data, test)
return findings
Expand Down
Loading

0 comments on commit 797549d

Please sign in to comment.