feat: hot CVE types and version constraint evaluator (SUB-7220)#629
feat: hot CVE types and version constraint evaluator (SUB-7220)#629kooomix wants to merge 5 commits into
Conversation
…ilure Add structured failure reason codes (enum-like strings) for scan failure notifications. UNS maps codes to human-friendly text via ReasonFriendlyText() at render time, so notification wording can change without redeploying scanners. Changes: - 12 Reason* constants (sbom_generation_failed, image_too_large, etc.) - ReasonFriendlyText() maps codes to user-facing notification text - Error field on ScanFailureReport for raw R&D debugging - Fix alignment of ImageHash/JobID fields Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Empty string now returns the unexpected error text instead of blank - Add unit tests: known code, unknown code, empty string, all codes mapped Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Empty codes fall back to unexpected error text. Unknown non-empty codes are returned as-is for forward-compat with newer scanner versions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add HotCVE, HotCVEAffectedPackage, HotCVEEndpointResponse, and HotCVEOnFinishedMessage types for hot CVE detection (SUB-7201). Add HotCVE field to NotificationParams for UNS integration. Add VersionConstraint with Matches() for evaluating SBOM components against affected version ranges, with comprehensive tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Compare() returns other.Compare(self), not self.Compare(other). Comments now accurately describe what cmp > 0 and cmp <= 0 mean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe PR adds data models for representing hot CVE information with affected packages, introduces version constraint matching logic, extends notification parameters with a HotCVE filter option, adds new scan failure reason codes (OOM killed, timeout), and includes corresponding tests for constraint matching and reason code behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for CI Build 24387005099Warning No base build found for commit Coverage: 41.998%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
Coverage Report for CI Build 24387039750Warning No base build found for commit Coverage: 41.998%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
This PR introduces data types and utilities to support “hot CVE” notifications and version-range evaluation, and extends scan-failure reason handling with new reason codes and friendlier text rendering.
Changes:
- Add new hot CVE API/message structs and related sentinel/status constants.
- Add
VersionConstraintwithMatches()implementing exact-match and[Start, End)range semantics using package-type-aware comparisons. - Extend scan-failure reason codes + friendly-text mapping, and add test coverage for reason text and version constraint matching.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
armotypes/hot_cve.go |
Introduces hot CVE feed types, endpoint response type, and UNS “finished” message payload + constants. |
package_versions/constraint.go |
Adds version constraint matcher for exact and range-based constraints. |
package_versions/constraint_test.go |
Adds table-driven tests for VersionConstraint.Matches() across multiple pkg types and semantics. |
notifications/usernotificationreporttypes.go |
Adds HotCVE notification parameter flag. |
scanfailure/types.go |
Adds new scan failure reason codes + friendly text; updates ReasonFriendlyText behavior for empty codes. |
scanfailure/types_test.go |
Adds tests for ReasonFriendlyText and ensures all known codes have non-empty friendly text. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // HotCVEEndpointResponse is the JSON response from the external hot CVE endpoint | ||
| type HotCVEEndpointResponse struct { | ||
| Version string `json:"version"` | ||
| HotCVEs []HotCVE `json:"hot_cves"` | ||
| } | ||
|
|
||
| // HotCVEOnFinishedMessage is the Pulsar message published for UNS after batch scan | ||
| type HotCVEOnFinishedMessage struct { | ||
| CustomerGUID string `json:"customerGUID"` | ||
| ClusterName string `json:"clusterName"` | ||
| Namespace string `json:"namespace"` | ||
| Kind string `json:"kind"` | ||
| WorkloadName string `json:"workloadName"` | ||
| CVEId string `json:"cveId"` | ||
| Severity string `json:"severity"` | ||
| Components []string `json:"components"` | ||
| } |
There was a problem hiding this comment.
PR description says the hot CVE types have JSON/BSON tags, but HotCVEEndpointResponse and HotCVEOnFinishedMessage currently have only JSON tags (no BSON). If these structs may be stored/read from Mongo anywhere, add bson tags for consistency; otherwise, update the PR description to reflect that only some structs are BSON-tagged.
| Namespace string `json:"namespace"` | ||
| Kind string `json:"kind"` | ||
| WorkloadName string `json:"workloadName"` | ||
| CVEId string `json:"cveId"` |
There was a problem hiding this comment.
Field name CVEId doesn’t follow the Go initialism convention used elsewhere in the repo (e.g., CVEID, GUID, ID). Consider renaming it to CVEID while keeping the JSON tag cveId unchanged, to improve consistency and avoid confusion for Go callers.
| CVEId string `json:"cveId"` | |
| CVEID string `json:"cveId"` |
Superseded by #630 (clean branch with only hot CVE changes).