Repository navigation
feat(vulnerabilities): filter and sort team v0s workload overviews - #652
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Same-name applications and jobs can collide in overview caching and workload counting, causing incorrect scan status, image-based ordering, and pending coverage totals.
2 open issues
6 files not reviewed
internal/graph/gengql/applications.generated.go: Generated fileinternal/graph/gengql/jobs.generated.go: Generated fileinternal/graph/gengql/schema.generated.go: Generated fileinternal/graph/gengql/teams.generated.go: Generated fileinternal/graph/gengql/v0s.generated.go: Generated fileinternal/graph/gengql/workloads.generated.go: Generated file
What changed in this PR
Adds v0s-based filtering and severity ordering to team workload views in Nais API, sharing workload selection with vulnerability summaries while retaining legacy v13s behavior.
Changes:
- Shares environment and label selection across team findings, summaries, and workload lists.
- Adds five unique-severity sort fields, batch-loaded counts, and selection-bound pagination cursors.
- Adds tests, fixtures, generated GraphQL bindings, and migration guidance.
| File | Description |
|---|---|
| README.md | Documents selection and sorting behavior. |
| internal/workload/models.go | Adds finding filters and unique-severity order fields. |
| internal/v0s/workload_order.go | Implements sorting and selection-bound cursors. |
| internal/v0s/workload_order_test.go | Tests ordering, cache reuse, and pagination. |
| internal/v0s/summary.go | Accepts explicit selection totals for coverage. |
| internal/v0s/summary_test.go | Tests missing-image and empty selections. |
| internal/v0s/queries.go | Adds explicit workload selection for findings. |
| internal/v0s/overview.go | Adds batch overview loading. |
| internal/v0s/models.go | Aliases shared filter types. |
| internal/v0s/filter/models.go | Extracts reusable filters and enums. |
| internal/integration/v0s.go | Adds overview backend fixtures. |
| internal/graph/workloads.resolvers.go | Integrates unique-severity sorting and pagination. |
| internal/graph/workloads.go | Extracts shared team workload selection. |
| internal/graph/v0s.resolvers.go | Applies workload selection to team findings. |
| internal/graph/schema/workloads.graphqls | Exposes finding filters and sort fields. |
| internal/graph/schema/v0s.graphqls | Adds team finding workload selection. |
| internal/graph/gengql/workloads.generated.go | Regenerates workload filter parsing. |
| internal/graph/gengql/v0s.generated.go | Regenerates shared filter bindings. |
| internal/graph/gengql/teams.generated.go | Regenerates team resolver bindings. |
| internal/graph/gengql/schema.generated.go | Updates root query filter bindings. |
| internal/graph/gengql/root_.generated.go | Updates embedded schema and complexity bindings. |
| internal/graph/gengql/jobs.generated.go | Updates job filter bindings. |
| internal/graph/gengql/applications.generated.go | Updates application filter bindings. |
| integration_tests/v0s_workload_overview.lua | Tests shared selection, coverage, sorting, and cursors. |
| integration_tests/k8s_resources/v0s_overview/staging/v0s-overview/resources.yaml | Adds cross-environment selection fixture. |
| integration_tests/k8s_resources/v0s_overview/dev/v0s-overview/resources.yaml | Adds label and scan-state fixtures. |
| docs/v0s_console_migration.md | Updates migration semantics and query examples. |
Review effort: Balanced
Share environment and label selection across team findings, summaries and workload lists. Sort workloads by filtered unique-severity aggregates before pagination, keeping incomplete scans first and binding cursors to the selection and ordering. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep application and job overview cache entries separate and reconcile each selected workload against its own image. Deduplicate backend selectors independently while counting coverage for every selected API workload identity. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bcedde2 to
004caec
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the shared workload selection and unique-severity sorting changes.
No open issues 🎉
2 resolved since last review
6 files not reviewed
internal/graph/gengql/applications.generated.go: Generated fileinternal/graph/gengql/jobs.generated.go: Generated fileinternal/graph/gengql/schema.generated.go: Generated fileinternal/graph/gengql/teams.generated.go: Generated fileinternal/graph/gengql/v0s.generated.go: Generated fileinternal/graph/gengql/workloads.generated.go: Generated file
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Same-name applications and jobs are conflated, producing incorrect per-workload summary counts and resolving findings to workloads outside the requested filter.
2 open issues
6 files not reviewed
internal/graph/gengql/applications.generated.go: Generated fileinternal/graph/gengql/jobs.generated.go: Generated fileinternal/graph/gengql/schema.generated.go: Generated fileinternal/graph/gengql/teams.generated.go: Generated fileinternal/graph/gengql/v0s.generated.go: Generated fileinternal/graph/gengql/workloads.generated.go: Generated file
Review effort: Balanced
| if err := v0s.ValidateWorkloadFilter(workloadFilter); err != nil { | ||
| return nil, err | ||
| } | ||
| return v0s.FindingsForWorkloads(ctx, scope, selectTeamWorkloads(ctx, obj.Slug, workloadFilter), filter, first, after, orderBy) |
| if selected != nil { | ||
| coverageCounts, err = selectedWorkloadCoverage(selected, current) |
* vulnerabilities: migrate overviews and workload health to v0s Use v0s for tenant and team summaries and app/job vulnerability health when enabled. Keep team filters consistent across counts and rows, and distinguish incomplete scans from scanned workloads with zero findings. Uses the GraphQL contract from nais/api#652. Keep legacy views as the default until rollout. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * vulnerabilities: address v0s overview review feedback Distinguish empty pages from empty selections, describe the CISA-only v0s counts accurately, and use type-specific health queries for apps and jobs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * vulnerabilities: fix v0s workload health loading state Derive readiness from the active vulnerability source. With v0s enabled, unfetched legacy stores must not keep app and job health cards loading. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>


Summary
TeamWorkloadsFilter.vulnerabilityFilterand add fiveVULNERABILITY_UNIQUE_*order fields. Sort on the same filtered unique-severity aggregates returned per workload, before pagination.The migration contract and shared-filter query example describe counting, filtering, coverage and cursor semantics.
Validation
CGO_ENABLED=0; focused tests were rerun after final generation.mise run fmt ::: generatefails on the existing pnpm SQLite-store error;mise run testis blocked by the yq installation certificate error before alert tests. Equivalent Go checks and standalone generation were run; alert tests were not verified locally.