Skip to content

fix(vulnerability): adapt API to v13s risk-tier model#452

Draft
ybelMekk wants to merge 15 commits into
mainfrom
feat/cve-priority
Draft

fix(vulnerability): adapt API to v13s risk-tier model#452
ybelMekk wants to merge 15 commits into
mainfrom
feat/cve-priority

Conversation

@ybelMekk
Copy link
Copy Markdown
Contributor

@ybelMekk ybelMekk commented Jun 2, 2026

Scope

  • Adapt api to the latest v13s risk-tier model
  • Keep GraphQL/API naming stable while aligning behavior with tier-first semantics.
  • Expose CVE signal fields inline on ImageVulnerability for frontend use.

What changed

v13s dependency (github.com/nais/v13s/pkg/api)

  • Bumped to include the latest feat/risk-tier-summary-model updates (current branch tip includes 5ff2f40).
  • RiskTier proto enum uses explicit zero sentinel:
    • RISK_TIER_UNSPECIFIED=0, ACT_NOW=1, HIGH_RISK=2, ELEVATED_RISK=3, MONITOR=4
  • cve.priority is restored and used for per-CVE sorting (priority_asc / priority_desc).
  • top_risk_tier remains in the summary model and is used for summary-level filtering/sorting.

API behavior updates

  • CVE priority derivation remains signal-based:
    • KEV => ACT_NOW
    • ransomware or EPSS>=0.90 => HIGH
    • CRITICAL/HIGH + EPSS>=0.50 => ELEVATED
    • otherwise MONITOR
  • ImageVulnerability now exposes inline CVE signal fields:
    • hasKevEntry, knownRansomwareUse, epssScore, epssPercentile
    • plus fixVersion
  • Priority sort mapping fixes:
    • ImageVulnerabilityOrderField.PRIORITY -> OrderByPriority
    • CVEOrderField.PRIORITY -> OrderByPriority
  • RISK_TIER_UNSPECIFIED is handled explicitly (no silent fallback to MONITOR).

Validation

  • mise run generate:graphql
  • go build ./...
  • go test ./internal/vulnerability/... -count=1

Notes

  • Existing GraphQL field names are preserved for compatibility.
  • Pre-existing mise run check findings in unrelated areas (gosec/deadcode) are unchanged.

ybelMekk added 11 commits June 3, 2026 11:52
…checker

- Add priorityActNow, priorityHigh, priorityElevated, priorityMonitor fields to ImageVulnerabilitySummary model
- Expose priority fields in vulnerability.graphqls and GraphQL resolvers
- Add VULNERABILITY_PRIORITY_ACT_NOW and VULNERABILITY_PRIORITY_HIGH sort fields
- Add ExternalIngressActNowVulnerabilityIssue type and issue checker
- Map priority signals (EPSS, KEV, ransomware) via VulnerabilityPrioritySignals
- Bump golang.org/x/net to v0.55.0 and golang.org/x/crypto to v0.52.0 to fix known vulnerabilities
- Update v13s/pkg/api to v0.0.0-20260525171357-13563f32226d (priority_elevated, priority_monitor support)
…; fix ExternalIngressActNow resolver stubs; add priority sort fields
@ybelMekk ybelMekk force-pushed the feat/cve-priority branch from f9eb406 to 3a773f3 Compare June 3, 2026 09:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the vulnerability domain in nais/api to match the latest v13s “risk-tier” model, while keeping GraphQL/API naming stable and exposing additional CVE signal data needed by the frontend.

Changes:

  • Adds EPSS/KEV/ransomware signals (and fix version) to ImageVulnerability, and introduces derived CVEPriority on CVE.
  • Extends sorting/filtering to support priority-based ordering for image vulnerabilities, CVEs, and workload vulnerability summaries.
  • Updates issue generation to use tier counts (ACT_NOW/HIGH_RISK) and introduces a new issue type for external-ingress workloads with ACT_NOW vulnerabilities.

Reviewed changes

Copilot reviewed 15 out of 19 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
internal/vulnerability/transform.go Maps new CVE signal fields and tier summary fields into API models.
internal/vulnerability/transform_test.go Adds unit tests for CVE priority derivation.
internal/vulnerability/sortfilter.go Registers new sort fields for priority/tier counts.
internal/vulnerability/queries.go Adds priority ordering for CVEs and hardens totalCount → int32 conversion.
internal/vulnerability/models.go Extends models with CVE priority enum + new fields (EPSS/KEV/etc).
internal/vulnerability/fake/fakedata.go Updates fake vulnerability summaries/findings to include tier and signal fields.
internal/issue/queries.go Adds conversion support for the new issue type details payload.
internal/issue/model.go Defines the new issue type and its details struct.
internal/issue/checker/workload_v13s.go Updates issue logic to use tier counts; adds external-ingress ACT_NOW issue emission.
internal/graph/schema/vulnerability.graphqls Extends public GraphQL schema with new fields/enums/sort options.
internal/graph/schema/issues.graphqls Adds the new issue type + GraphQL type.
internal/graph/issues.resolvers.go Wires resolvers for the new issue GraphQL type.
internal/graph/gengql/vulnerability.generated.go Regenerates gqlgen output for vulnerability schema changes.
internal/graph/gengql/schema.generated.go Regenerates gqlgen output for schema/type additions.
internal/graph/gengql/root_.generated.go Regenerates gqlgen resolver root + complexity updates.
internal/graph/gengql/issues.generated.go Regenerates gqlgen output for the new issue type.
integration_tests/issues_for_team.lua Updates expected message/severity for vulnerable image issues.
go.mod Bumps v13s API dependency to include risk-tier summary model updates.
go.sum Updates dependency checksums accordingly.
Files not reviewed (3)
  • internal/graph/gengql/issues.generated.go: Language not supported
  • internal/graph/gengql/schema.generated.go: Language not supported
  • internal/graph/gengql/vulnerability.generated.go: Language not supported

Comment thread internal/vulnerability/transform_test.go
Comment thread internal/vulnerability/transform_test.go
Comment thread internal/vulnerability/transform_test.go
Comment thread internal/vulnerability/transform_test.go
Comment thread internal/vulnerability/transform_test.go
Comment thread internal/vulnerability/transform_test.go
Comment thread internal/graph/schema/vulnerability.graphqls
Comment thread internal/graph/schema/vulnerability.graphqls
Comment thread internal/vulnerability/fake/fakedata.go Outdated
Comment thread internal/vulnerability/fake/fakedata.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants