Skip to content

feat(vulnerabilities): add parallel v0s API integration - #638

Draft
jhrv wants to merge 1 commit into
mainfrom
feat/v0s-api
Draft

jhrv wants to merge 1 commit into
mainfrom
feat/v0s-api

Conversation

@jhrv

@jhrv jhrv commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces a major migration in the vulnerability data model by integrating the new "v0s" service for vulnerability queries, coverage, and suppressions, while keeping legacy (v13s) support for backward compatibility. It updates configuration, code, tests, and documentation to support v0s-based reads and (optionally) writes, and exposes new GraphQL fields for applications and jobs. The changes are grouped as follows:

1. v0s Integration and Configuration

  • Added v0s as a new internal module, with its manager initialized and injected into the API runtime. New configuration options (V0S_ENDPOINT, V0S_SUPPRESSIONS_ENABLED) are introduced and documented, with logic ensuring v0s is optional and independent of legacy vulnerability endpoints. [1] [2] [3] [4] [5] [6] [7]

2. GraphQL API Enhancements

  • Exposed new GraphQL fields on applications and jobs for vulnerabilityFindings, vulnerabilityFindingSummary, and vulnerabilityCoverage, all powered by v0s. Added argument parsing, field context, and resolver stubs for these fields in the generated code. [1] [2] [3]
  • Updated the GraphQL schema and codegen config to include v0s models and field mappings, such as mapping totalCount to Count in PageInfo.

3. Context and Loader Wiring

  • Injected the v0s manager and workload inventory loader into the GraphQL context, ensuring new queries have access to up-to-date inventory and fail gracefully if inventory is not ready. [1] [2]

4. Protobuf and Build Pipeline

  • Added a build step to generate Go code from the pinned v0s protobuf schema, decoupling the API from the upstream scanner module.

5. Documentation

  • Added a detailed migration guide to README.md, explaining the new fields, configuration, migration process, and operational caveats for v0s adoption.

These changes collectively enable the API to read vulnerability findings, summaries, and coverage from v0s, paving the way for a smooth migration from legacy v13s data and supporting future enhancements.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Same-named applications and jobs collide in the workload map, undercounting coverage and potentially returning a job’s findings or coverage for an application.

1 open issue
4 files not reviewed
  • internal/graph/gengql/activitylog.generated.go: Generated file
  • internal/graph/gengql/applications.generated.go: Generated file
  • internal/graph/gengql/jobs.generated.go: Generated file
  • internal/graph/gengql/schema.generated.go: Generated file
What changed in this PR

Adds v0s as a parallel vulnerability backend for Nais API while retaining legacy v13s support.

Changes:

  • Adds optional v0s configuration, client initialization and request-scoped inventory loaders.
  • Exposes GraphQL findings, summaries, coverage and assessments, with gated suppression writes and activity logging.
  • Adds cursor pagination, protobuf generation, migration documentation and tests.
File Description
README.md Documents migration, configuration and rollout requirements.
internal/​v0s/​queries.go Implements scoped vulnerability reads and summaries.
internal/​v0s/​queries_test.go Tests filtering, inventory reconciliation, pagination and authorization.
internal/​v0s/​protoapi/​v0s_grpc.pb.go Adds generated gRPC service bindings.
internal/​v0s/​protoapi/​schema/​v0s.proto Pins the v0s protobuf contract.
internal/​v0s/​pagination.go Implements filter-bound, forward-only cursors.
internal/​v0s/​node.go Adds global IDs and node lookups.
internal/​v0s/​mutations.go Implements gated, authorized suppression batches.
internal/​v0s/​mutations_integration_test.go Tests authorized writes and activity recording.
internal/​v0s/​models.go Defines v0s domain models and enums.
internal/​v0s/​errors.go Maps backend errors to API responses.
internal/​v0s/​dataloader.go Caches inventory, grouped counts and advisories.
internal/​v0s/​convert.go Converts backend values into API models.
internal/​v0s/​client.go Creates and manages the optional gRPC client.
internal/​v0s/​client_test.go Tests gRPC reads and lazy initialization.
internal/​v0s/​activitylog.go Registers and records assessment activity.
internal/​integration/​manager.go Updates integration setup for the new manager argument.
internal/​graph/​v0s.resolvers.go Connects GraphQL fields to v0s operations.
internal/​graph/​v0s.resolvers_test.go Tests GraphQL behavior and legacy coexistence.
internal/​graph/​schema/​v0s.graphqls Defines public v0s queries, types and mutations.
internal/​graph/​pagination/​relay.go Rejects v0s cursors in offset pagination.
internal/​graph/​pagination/​models.go Supports deferred total-count loading.
internal/​graph/​pagination/​cursor.go Adds opaque v0s cursor encoding.
internal/​graph/​pagination/​cursor_test.go Tests cursor compatibility and separation.
internal/​graph/​gengql/​schema.generated.go Adds generated query, mutation and node wiring.
internal/​graph/​gengql/​jobs.generated.go Adds generated job vulnerability fields.
internal/​graph/​gengql/​applications.generated.go Adds generated application vulnerability fields.
internal/​graph/​gengql/​activitylog.generated.go Supports assessment activity entries.
internal/​cmd/​api/​http.go Injects v0s loaders and checks inventory readiness.
internal/​cmd/​api/​config.go Adds endpoint and suppression-write settings.
internal/​cmd/​api/​config_test.go Tests independent v0s configuration and write defaults.
internal/​cmd/​api/​api.go Initializes, injects and closes the v0s manager.
.mise-tasks/​generate/​proto Generates bindings from the pinned schema.
.configs/​gqlgen.yaml Binds v0s models and deferred page counts.

Review effort: Balanced

if err == nil {
for _, env := range resp.GetEnvironments() {
for _, w := range env.GetWorkloads() {
result[workloadKey{env.GetEnvironment(), w.GetTeamSlug(), w.GetName()}] = w.GetImage()
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