Skip to content

feat(vanir): add vanir-sandbox Cloud Run service and HTTP orchestrator - #6403

Merged
another-rex merged 8 commits into
google:masterfrom
another-rex:vanir-sandbox-pr1
Dec 3, 2026
Merged

another-rex merged 8 commits into
google:masterfrom
another-rex:vanir-sandbox-pr1

Conversation

@another-rex

@another-rex another-rex commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Overview

(AI-assisted PR)

PR 1 of 2 to isolate Vanir signature generation into a dedicated, zero-privilege Cloud Run Gen2 sandbox (vanir-sandbox).

  • PR 1 (this PR): Adds vanir-sandbox service, OIDC HTTP client, and Docker/Terraform/Cloud Deploy/Cloud Build wiring (backwards-compatible with local PythonGenerator).
  • PR 2 (follow-up): Switches the vanir-signatures CronJob to VANIR_SANDBOX_URL and moves it off the highend node pool.

Details

1. Untrusted Sandbox Server (go/cmd/vanir_sandbox)

  • Single-concurrency HTTP server (GET /healthz, POST /v1/generate)
  • Per-request non-root UID and isolated work directory
  • Fail-closed post-request process and temp cleanup
  • tini entrypoint for zombie reaping

2. Go Orchestrator (go/internal/vanir/http_generator.go, go/cmd/vanir_signatures)

  • OIDC-authenticated HTTP signature generator client
  • Optional -sandbox-url / VANIR_SANDBOX_URL flag with local fallback

Batch Size & Max Workers

In remote sandbox mode, batch-size controls how many vulnerabilities a single worker runs serially inside one processBatch call. When VANIR_SANDBOX_URL is set, -batch-size defaults to 1 and -max-workers defaults to 15 (unless overridden via flags):

  • Remote sandbox mode (-batch-size=1, -max-workers=15):
    • Each of the 15 workers pulls 1 vulnerability at a time → up to 15 parallel HTTP requests across 15 Cloud Run instances (with maxScale: 30 headroom; Cloud Run scales to 0 when idle).
    • Each vulnerability is persisted to GCS/Datastore immediately when it finishes.
    • If 1 vulnerability fails, only that 1 vulnerability goes onto retry_list (no other work is discarded).
  • Local Python mode (-batch-size=100, -max-workers=10):
    • Keeps existing defaults so a single generate_signatures.py process handles 100 vulnerabilities together with a shared git working directory.

3. Infra & Docs

  • vanir-sandbox target in go/Dockerfile
  • Terraform module and outputs (vanir_sandbox.tf, zero-IAM SA, no VPC, Cloud Run Gen2)
  • Cloud Deploy manifests and Cloud Build pipeline steps
  • Updated AGENTS.md and Makefile

Rollout Note: Before the first build-and-stage run on master, apply the Cloud Deploy delivery pipeline once:

gcloud deploy apply --file=deployment/clouddeploy/vanir-sandbox/clouddeploy.yaml --region=us-central1 --project=oss-vdb

Gitter

Turns out this is way more complicated than expected. So probably not going to ever implement gitter integration.

@codecov-commenter

codecov-commenter commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.94406% with 189 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.01%. Comparing base (20d257f) to head (5ba0158).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
go/cmd/vanir_sandbox/main.go 49.09% 140 Missing ⚠️
go/internal/vanir/http_generator.go 78.94% 28 Missing ⚠️
go/cmd/vanir_signatures/main.go 0.00% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6403      +/-   ##
==========================================
+ Coverage   56.99%   57.01%   +0.01%     
==========================================
  Files         225      227       +2     
  Lines       23494    23922     +428     
==========================================
+ Hits        13391    13638     +247     
- Misses      10100    10281     +181     
  Partials        3        3              
Flag Coverage Δ
go 60.98% <55.94%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread go/cmd/gitter/git.go Fixed
@another-rex another-rex changed the title feat(vanir): add vanir-sandbox service, gitter commit-pack relay, and input/output hardening feat(vanir): add vanir-sandbox Cloud Run service and HTTP orchestrator Nov 24, 2026
Comment thread go/cmd/gitter/git.go Fixed
@another-rex
another-rex marked this pull request as ready for review November 25, 2026 23:14

@jess-lowe jess-lowe 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.

bot found some stuff

Comment thread go/internal/vanir/http_generator.go Resolved
Comment thread go/cmd/vanir_sandbox/main.go Resolved
Comment thread go/cmd/vanir_sandbox/main.go Resolved
Comment thread go/cmd/vanir_sandbox/main.go Resolved
Comment thread go/cmd/vanir_sandbox/main.go Resolved
}, nil
}

func (g *HTTPSignatureGenerator) GenerateBatch(ctx context.Context, vulns []*osvschema.Vulnerability, _ string) (SignatureMap, error) {

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.

Throughput question: the old path ran a batch of 100 in one Python process with a shared git working dir, on a node with 12–28 CPUs. This runs one request, one interpreter start, and one fresh fetch per vuln, serially within the batch. With the default 10 workers we use at most 10 of the 30 instances, and the 30-minute timeout now applies per vuln rather than per batch. Is that acceptable for the full backfill when there is no last-run timestamp? A bounded fan-out here (or tuning -max-workers=30 -batch-size=1 in the CronJob in PR 2) would use the remaining instances.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are using batches of 1 now when running in cloud. (Running in parallel with 15 workers by default)

Comment thread go/internal/vanir/http_generator.go Resolved
Comment thread go/cmd/vanir_sandbox/main.go Resolved
Comment thread go/cmd/vanir_sandbox/main.go Resolved
@another-rex
another-rex requested a review from cuixq November 26, 2026 23:51
Comment thread go/cmd/vanir_sandbox/main.go Resolved
Comment thread go/internal/vanir/http_generator.go Resolved
@another-rex
another-rex merged commit 9c03a38 into google:master Dec 3, 2026
30 of 31 checks passed
another-rex added a commit that referenced this pull request Dec 4, 2026
…le local execution (#6504)

## Overview

*(AI-assisted PR)*

**PR 2 of 2** (follow-up to #6403) to switch `vanir-signatures` to the
Cloud Run Gen2 `vanir-sandbox` service and remove local unsandboxed
Python execution.

## Details

- **Disable local execution (`go/cmd/vanir_signatures`,
`go/internal/vanir`):**
- Require `VANIR_SANDBOX_URL` / `-sandbox-url` and remove
`PythonGenerator` fallback
  - Default `-batch-size=1` and `-max-workers=15` directly
- Remove unused per-batch temp dir creation in `Runner`
(distroless-safe)
- **Distroless Go image (`go/Dockerfile`,
`deployment/build-and-stage.yaml`):**
- Switch `vanir-signatures` target to
`gcr.io/distroless/static-debian12` (no Python or `git` in the
orchestrator image)
  - Drop unused `--build-context poetry` from `build-vanir-signatures`
- **GKE CronJob cutover (`deployment/clouddeploy/gke-workers/`):**
- Remove `highend` nodeSelector/tolerations and downsize resources to `1
CPU / 2Gi` (`2 CPU / 4Gi` limit)
- Set `VANIR_SANDBOX_URL` to the deterministic Cloud Run URLs for
`oss-vdb-test` and `oss-vdb`
- **Docs:** Update `AGENTS.md`

> **Prod Rollout Note:** `vanir-sandbox` is already live and healthy on
`oss-vdb-test`. Before unpausing `vanir-signatures` on prod (`oss-vdb`),
make sure prod Terraform (`vanir-sandbox` + `roles/run.invoker`), the
Cloud Deploy promotion of `vanir-sandbox` to `production-vanir-sandbox`,
and the prod `osv-worker` Workload Identity ServiceAccount are applied.

agy
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.

5 participants