You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add new "evaluations" format support to Anchorectl parser (#12425)
* Fix AnchoreCTL Policies parser to support new format with evaluations array
This commit updates the AnchoreCTL Policies parser to support both the legacy and new format reports generated by the AnchoreCTL tool.
Changes:
- Added detection for the new format which has an object with evaluations array instead of a root-level list
- Implemented conversion logic to transform the new format into a compatible structure for parsing
- Improved error handling with more descriptive messages
- Made field extraction more robust with proper fallbacks between formats
The parser now successfully processes both:
- Legacy format (list at root level)
- New format from anchorectl policy evaluate -o json (object with evaluations array)
* Added tests for the new format to verify correct parsing
* Fixed linter errors
* Update AnchoreCTL Policies Report documentation for clarity and format support
* Removed unnecessary text from anchorectl_policies
Sample AnchoreCTL Policies Report scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/anchorectl_policies).
return"AnchoreCTLs JSON policies report format. Both legacy list-based format and new evaluation-based format (from anchorectl policy evaluate -o json) are supported."
msg="This doesn't look like a valid Anchore CTRL Policies report: Expected a list with image data at the root of the JSON data"
60
+
msg="This doesn't look like a valid Anchore CTRL Policies report: Expected a list with image data at the root of the JSON data or an object with 'evaluations' array"
msg=f"Invalid format or missing key: {err}. This parser supports both legacy AnchoreCTL format and the new format from 'anchorectl policy evaluate -o json'."
126
+
logger.warning(msg)
127
+
# Continue processing other findings instead of failing completely
0 commit comments