-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
516 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
e867e64eee20010c4d3463df0119d6bdf7c588324a722df01abfda7cd01cd8ec | ||
ea62fff7e384d73568e1293c739ce1a116e090cd4550a403ac272821a7785e0b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from dojo.models import Finding | ||
|
||
TRIVY_SEVERITIES = { | ||
"CRITICAL": "Critical", | ||
"HIGH": "High", | ||
"MEDIUM": "Medium", | ||
"LOW": "Low", | ||
"UNKNOWN": "Info", | ||
} | ||
|
||
|
||
class TrivyClusterComplianceHandler: | ||
def handle_clustercompliance(self, controls, clustercompliance, test): | ||
findings = [] | ||
for result in clustercompliance.get("controlCheck"): | ||
if int(result.get("totalFail", 0)) > 0: | ||
description = "" | ||
result_id = result.get("id", "") | ||
vulnerabilityids = [] | ||
for control in controls: | ||
if control.get("id") == result_id: | ||
vulnids = control.get("checks", []) | ||
for vulnid in vulnids: | ||
vulnerabilityids.append(vulnid.get("id")) | ||
description += "**description:** " + control.get("description") + "\n" | ||
result_name = result.get("name", "") | ||
result_severity = result.get("severity", "") | ||
result_totalfail = str(result.get("totalFail", "")) | ||
severity = TRIVY_SEVERITIES[result_severity] | ||
description += "**id:** " + result_id + "\n" | ||
description += "**name:** " + result_name + "\n" | ||
description += "**totalfail:** " + result_totalfail + "\n" | ||
title = "TrivyClusterCompliance " + result_id + " totalFail: " + result_totalfail | ||
finding = Finding( | ||
test=test, | ||
title=title, | ||
description=description, | ||
severity=severity, | ||
static_finding=False, | ||
dynamic_finding=True, | ||
) | ||
if vulnerabilityids != []: | ||
finding.unsaved_vulnerability_ids = vulnerabilityids | ||
findings.append(finding) | ||
return findings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
unittests/scans/anchorectl_policies/one_violation_description_severity.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[ | ||
{ | ||
"detail": [ | ||
{ | ||
"description": "CRITICAL User root found as effective user, which is not on the allowed list", | ||
"gate": "dockerfile", | ||
"imageId": "d26f0119b9634091a541b081dd8bdca435ab52e114e4b4328575c0bc2c69768b", | ||
"policyId": "RootUser", | ||
"status": "warn", | ||
"tag": "test/testimage:testtag", | ||
"triggerId": "b2605c2ddbdb02b8e2365c9248dada5a", | ||
"triggerName": "effective_user" | ||
} | ||
], | ||
"digest": "sha256:8htz0bf942cfcd6hg8cf6435afd318b65d23e4c1a80044304c6e3ed20", | ||
"finalAction": "stop", | ||
"finalActionReason": "policy_evaluation", | ||
"lastEvaluation": "2022-09-20T08:25:52Z", | ||
"policyId": "9e104ade-7b57-4cdc-93fb-4949bf3b36b6", | ||
"status": "fail", | ||
"tag": "test/testimage:testtag" | ||
} | ||
] |
Oops, something went wrong.