Go & Container Security Audit Skill
Overview
This skill provides a repeatable workflow and zero-dependency scanner to audit, upgrade, and harden Go backend repositories and their container images before Cloud Run or production deployment.
It covers four layers of Go and container security:
- Go Toolchain & Module Floor (
go >= 1.26.0): Detecting whengo.modis ongo 1.25.xor older, which causesgo get -u ./...to fail against current Google Cloud, gRPC, OpenTelemetry, andgolang.org/x/{crypto,net,oauth2,sys,text}releases unless thegodirective ingo.modis bumped first. - Call-Graph vs. Module Vulnerability Triage (
govulncheck): Runninggo run golang.org/x/vuln/cmd/govulncheck@latest ./...to separate reachable symbol vulnerabilities (which must be0) from uncalled module-level notices (such asGO-2026-5932on deprecatedgolang.org/x/crypto/openpgpingolang.org/x/crypto@v0.58.0). - Container Toolchain & Base OS Hardening (
Dockerfile): Verifying thatFROM golang:<ver>-bookworminDockerfilematches thegodirective ingo.mod(preventing Cloud Build failures or uncached toolchain downloads) and that runtime stages (debian:bookworm-slim) applyapt-get update && apt-get upgrade -y. - Source Upload & Ignore Hygiene (
.gitignore/.gcloudignore): Ensuring local agent and issue-tracker state directories (.serena,.beads,.dolt,docs-bundle) are excluded from git and Cloud Build source uploads.
Bundled Resources
scripts/audit-go-repo.mjs— Scans a repository or workspace directory (up to depth 5) forgo.modsubprojects, checkinggodirective floors,Dockerfilebuilder/runtime alignment,.gitignore/.gcloudignorehygiene, git remote tracking status, and optionalgovulnchecksummaries.- Go & Container Remediation Playbook (
references/go-remediation-playbook.md) — Detailed runbook for resolvinggo >= 1.26.0upgrade cascades, triaginggovulncheckoutput, upgradingmcp-go/genkit/genai/go-sqlite3, and hardening multi-stage Dockerfiles.
Workflow
Step 1: Sync with origin & Run the Go Security Audit
Always fetch and verify git tracking status before modifying go.mod or go.sum, then run ./scripts/audit-go-repo.mjs against a single repository or workspace:
git fetch origin./scripts/audit-go-repo.mjs ~/projects/my-go-repo --vulncheck./scripts/audit-go-repo.mjs ~/projects --vulncheck --jsonFor each discovered Go module (go.mod), scripts/audit-go-repo.mjs inspects:
- Go Directive & Stdlib Security Floor: Checks both whether
goingo.modmeets>= 1.26.0(required for late-2026 module resolution) and whether it meets>= 1.26.10(preventingGOTOOLCHAIN=autofrom pinning to an unpatchedgo1.26.0–1.26.9stdlib with 36 reachable CVEs). - Optional
govulncheckCall-Graph Triage (--vulncheck): Runsgovulncheck -json ./...and separates reachable Symbol, Package, and Module advisories while auto-identifyingGO-2026-5932(x/crypto/openpgp) as an uncalled deprecation notice. - Dockerfile Alignment: Compares
FROM golang:<ver>in any repositoryDockerfileagainstgo.mod'sgomajor.minor version, and checks whetherapt-get upgrade -yis present in Debian/Ubuntu stages. - Ignore File Parity: Checks
.gitignoreand.gcloudignorefor line-anchored.serena,.beads, and.doltrules. - Git Sync Status: Warns if the local branch is behind
originbefore dependency files are edited.
Step 2: Upgrade Go Modules Without Toolchain Deadlock
Consult Go & Container Remediation Playbook for stack-specific upgrade guidance:
- Bump
goDirective First:- If
go.moddeclaresgo 1.25.xor older, updatego.modtogo 1.26.10(or rungo get go@1.26.10) before runninggo get -u ./.... Otherwise,go get -u ./...aborts when encounteringcloud.google.com/go/auth@v0.24.2,golang.org/x/crypto@v0.58.0, orgoogle.golang.org/grpc@v1.85.0.
- If
- Upgrade & Tidy:
Terminal window go get -u ./...go mod tidy - Align
DockerfileBuilder & OS Patching:- Update
FROM golang:1.25-bookwormtoFROM golang:1.26-bookwormto matchgo 1.26.x. - Ensure
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends ...is present in both builder and runtime (debian:bookworm-slim) stages.
- Update
Step 3: Build, Test & Run govulncheck
After upgrading go.mod and Dockerfile:
- Build and run the full test suite (including CGO tags like
-tags "sqlite_fts5"if applicable):Terminal window go test -tags "sqlite_fts5" ./... - Run
govulncheckacross all packages:Terminal window go run golang.org/x/vuln/cmd/govulncheck@latest ./... - Confirm
Your code is affected by 0 vulnerabilities(0 reachable symbol vulnerabilities and 0 imported package vulnerabilities).