feat(trivy_operator): add remediation, messages, category, and publishedDate mappings#14360
feat(trivy_operator): add remediation, messages, category, and publishedDate mappings#14360SergK wants to merge 1 commit intoDefectDojo:devfrom
Conversation
|
@SergK Thanks. Could you assess the possible impact on deduplication? |
|
@valentijnscholten The Trivy Operator parser uses hash-code based deduplication. The hash is computed from For For This is a one-time shift on the first reimport after upgrade. After that, the hashes stay stable. Worth noting that |
Maffooch
left a comment
There was a problem hiding this comment.
We are very sensitive about deduplication changes because we cannot guarantee that all users will read the release notes before upgrading. The least impacting breaking changes, the better. With that in mind, we should steer clear of updating the description when it is used in the dedupe hash codes
…hedDate mappings Add missing field mappings to the Trivy Operator parser: - checks_handler: extract remediation and messages → Finding.mitigation, category → Finding tag. These fields are defined on the Check struct (config_audit_types.go) and were already mapped in compliance_handler but missing from checks_handler. Messages and remediation are combined in the mitigation field since both provide actionable guidance. Category is stored as a tag for filterability rather than in description, to avoid affecting the deduplication hash. - vulnerability_handler: extract publishedDate → Finding.publish_date. Trivy provides CVE publication dates in VulnerabilityReport; map them to the existing nullable DateField with graceful handling of empty strings and malformed dates. Signed-off-by: Sergiy Kulanov <sergiy_kulanov@epam.com>
62ba09d to
0a8f05e
Compare
Description
Add missing field mappings to the Trivy Operator parser.
1. Add
remediation,messages,categoryto checks handlerThe Trivy Operator Go source defines these fields on the Check struct:
The
compliance_handler.pyalready mapsremediation→Finding.mitigation,messages, andcategoryfrom the same Check struct, butchecks_handler.py(used by ConfigAuditReport, RbacAssessmentReport, InfraAssessmentReport) does not. This PR brings parity:check.remediation→Finding.mitigationcheck.messages→ appended toFinding.descriptionas**messages:**check.category→ appended toFinding.descriptionas**category:**2. Add
publishedDateto vulnerability handlerTrivy provides
publishedDateon vulnerability findings. The existingvulnerabilityreport_extended.jsontest fixture already contains this field:{ "vulnerabilityID": "CVE-2024-0553", "publishedDate": "2024-01-16T12:15:45Z", ... }This maps it to
Finding.publish_date(existing nullableDateField), with graceful handling of empty strings and malformed dates viacontextlib.suppress(ValueError).Test results
test_vulnerabilityreport_extended— verifiespublish_date = date(2024, 1, 16)for first vuln,Nonefor vulns with emptypublishedDatetest_configauditreport_with_remediation— verifiesmitigation,category, andmessagesextractionruff checkpassesDocumentation
No documentation changes needed — additional field mappings for an existing parser.
Checklist
dev.