-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add new "evaluations" format support to Anchorectl parser #12425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Maffooch
merged 5 commits into
DefectDojo:bugfix
from
cosmel-dojo:sc-11051-fix-anchorectl-parser-support
May 22, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fe7a8e7
Fix AnchoreCTL Policies parser to support new format with evaluations…
cosmel-dojo 49a2459
Added tests for the new format to verify correct parsing
cosmel-dojo 65c916f
Fixed linter errors
cosmel-dojo f9bc57b
Update AnchoreCTL Policies Report documentation for clarity and forma…
cosmel-dojo 202011f
Removed unnecessary text from anchorectl_policies
cosmel-dojo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
46 changes: 46 additions & 0 deletions
46
unittests/scans/anchorectl_policies/new_format_many_violations.json
This file contains hidden or 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,46 @@ | ||
| { | ||
| "evaluatedTag": "test/testimage:testtag", | ||
| "policyId": "9e104ade-7b57-4cdc-93fb-4949bf3b36b6", | ||
| "imageDigest": "sha256:8htz0bf942cfcd6hg8cf6435afd318b65d23e4c1a80044304c6e3ed20", | ||
| "evaluations": [ | ||
| { | ||
| "evaluationTime": "2022-09-20T08:25:52Z", | ||
| "status": "fail", | ||
| "finalAction": "stop", | ||
| "finalActionReason": "policy_evaluation", | ||
| "numberOfFindings": 3, | ||
| "details": [ | ||
| { | ||
| "description": "HIGH Vulnerability found in non-os package type (test) - /usr/local/bin/testbinary (CVE-2022-1234)", | ||
| "gate": "vulnerabilities", | ||
| "imageId": "d26f0119b9634091a541b081dd8bdca435ab52e114e4b4328575c0bc2c69768b", | ||
| "policyId": "SoftwareChecks", | ||
| "status": "stop", | ||
| "tag": "test/testimage:testtag", | ||
| "triggerId": "CVE-2022-1234+test", | ||
| "triggerName": "package" | ||
| }, | ||
| { | ||
| "description": "MEDIUM Vulnerability found in non-os package type (test2) - /usr/local/bin/testbinary (fixed in: 1.2.3)(GHSA-1234-abcd-5678)", | ||
| "gate": "vulnerabilities", | ||
| "imageId": "d26f0119b9634091a541b081dd8bdca435ab52e114e4b4328575c0bc2c69768b", | ||
| "policyId": "SoftwareChecks", | ||
| "status": "stop", | ||
| "tag": "test/testimage:testtag", | ||
| "triggerId": "GHSA-1234-abcd-5678+test2", | ||
| "triggerName": "package" | ||
| }, | ||
| { | ||
| "description": "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" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
15 changes: 15 additions & 0 deletions
15
unittests/scans/anchorectl_policies/new_format_no_violation.json
This file contains hidden or 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,15 @@ | ||
| { | ||
| "evaluatedTag": "test/testimage:testtag", | ||
| "policyId": "9e104ade-7b57-4cdc-93fb-4949bf3b36b6", | ||
| "imageDigest": "sha256:8htz0bf942cfcd6hg8cf6435afd318b65d23e4c1a80044304c6e3ed20", | ||
| "evaluations": [ | ||
| { | ||
| "evaluationTime": "2022-09-20T08:25:52Z", | ||
| "status": "pass", | ||
| "finalAction": "go", | ||
| "finalActionReason": "policy_evaluation", | ||
| "numberOfFindings": 0, | ||
| "details": [] | ||
| } | ||
| ] | ||
| } |
26 changes: 26 additions & 0 deletions
26
unittests/scans/anchorectl_policies/new_format_one_violation.json
This file contains hidden or 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,26 @@ | ||
| { | ||
| "evaluatedTag": "test/testimage:testtag", | ||
| "policyId": "9e104ade-7b57-4cdc-93fb-4949bf3b36b6", | ||
| "imageDigest": "sha256:8htz0bf942cfcd6hg8cf6435afd318b65d23e4c1a80044304c6e3ed20", | ||
| "evaluations": [ | ||
| { | ||
| "evaluationTime": "2022-09-20T08:25:52Z", | ||
| "status": "fail", | ||
| "finalAction": "stop", | ||
| "finalActionReason": "policy_evaluation", | ||
| "numberOfFindings": 1, | ||
| "details": [ | ||
| { | ||
| "description": "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" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
26 changes: 26 additions & 0 deletions
26
unittests/scans/anchorectl_policies/new_format_one_violation_description_severity.json
This file contains hidden or 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,26 @@ | ||
| { | ||
| "evaluatedTag": "test/testimage:testtag", | ||
| "policyId": "9e104ade-7b57-4cdc-93fb-4949bf3b36b6", | ||
| "imageDigest": "sha256:8htz0bf942cfcd6hg8cf6435afd318b65d23e4c1a80044304c6e3ed20", | ||
| "evaluations": [ | ||
| { | ||
| "evaluationTime": "2022-09-20T08:25:52Z", | ||
| "status": "fail", | ||
| "finalAction": "stop", | ||
| "finalActionReason": "policy_evaluation", | ||
| "numberOfFindings": 1, | ||
| "details": [ | ||
| { | ||
| "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" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.