/shipyard:cve-fixfrom shipyard
Scans Go repositories for CVEs using Grype, updates go.mod to fix findings, verifies fixes with a rescan gate, and prints a ready-to-run PR command.
Ships in shipyard. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill scans Go modules for CVEs using grype, updates go.mod to fix each
one, verifies fixes with a rescan gate, and prints a ready-to-run PR command.
Use it on any Go repository with a .grype.yaml or standard layout.
The workflow uses the following tools. Install the command-line prerequisites; Grype can be installed automatically and the LLM reviewer is optional.
grype — the skill installs a checksum-verified latest release into
skills/cve-fix/bin/ when needed; no manual install or sudo is required. Set
CVE_FIX_GRYPE_VERSION=vX.Y.Z to pin a reproducible version.
The fallback uses the same requested version and checks the container's
reported version before accepting its scan. Without an explicit version,
the default fallback pins Grype v0.112.0 to a reviewed multi-architecture
SHA256 digest. Set CVE_FIX_GRYPE_IMAGE to a reviewed digest for a mirror.
Other explicitly requested versions use their release tag; set an image
digest as well when those versions require identical images across runs.
Advance the default digest in the helper and this example only after
regression checks and live scan comparisons pass. A Docker/Podman fallback remains
usable when local installation is unavailable:
scanner_digest='sha256:391bfda62888fb4e98ff5c4c81598f7431a3c1eac3f8519d69d1ff00df247c1d'
scanner_image="anchore/grype:v0.112.0@$scanner_digest"
docker volume create grype-db && \
docker run --rm -e GRYPE_DB_CACHE_DIR=/root/.cache/grype/db \
-v grype-db:/root/.cache/grype "$scanner_image" db update
bash 4+ — mapfile and other builtins require bash 4+. macOS ships
bash 3.2 (GPLv2); install a newer version:
brew install bash
Linux (Ubuntu 22.04+) ships bash 5.1 and is unaffected.
claude or codex CLI — optional; used for LLM-assisted review of unresolved
CVEs. The Make interface uses Claude by default for compatibility; select
Codex with CVE_FIX_AGENT=codex. The remediation and verification gates
remain usable without the selected CLI: the workflow falls back to
deterministic companion evidence and does not report an unconfirmed result
as clean. Install either optional reviewer via:
npm install -g @anthropic-ai/claude-code
npm install -g @openai/codex
go — Go toolchain (go get, go mod tidy); install from https://go.dev/dl/
jq — used to read Go's JSON module graph output and scanner results.
python3 — used by the configuration parser and verification helpers.
base64 — used to pass structured CVE requirements between the scripts.
make — used for make clean, make unit, and make -C skills/cve-fix
timeout — GNU coreutils; bounds builds, tests, and optional reviewers.
On macOS, install coreutils and add its libexec/gnubin directory to PATH
so the scripts can invoke timeout (the prefixed gtimeout name alone is insufficient).
Invoke the documented entry points instead of reproducing individual remediation steps ad hoc. The scripts own mutation, verification, and rollback behavior.
If the arguments do NOT contain all, resolve the actual loaded SKILL.md
path, then use its sibling scripts/ directory. In the source checkout that
directory is skills/cve-fix/scripts; in an installed plugin it is next to the
loaded skill. Set CVE_SCRIPTS to that resolved absolute directory and verify
that fix-all.sh exists there.
For Claude Code's existing standalone installation, if the runtime does not
expose the loaded path, retain the established fallback: use
skills/cve-fix/scripts from the current checkout when present, otherwise
~/.claude/plugins/cve-fix/scripts. Do not use this fallback to select an
arbitrary second copy when the loaded path is known.
Take the optional repository and branch directly from the user's invocation,
preserving their order. Invoke the script once with quoted positional arguments.
Do not depend on $ARGUMENTS, a manifest-injected environment variable, or a
home-directory search. The script already accepts zero, one, or two arguments
and validates them itself:
# CVE_SCRIPTS is the resolved absolute scripts directory.
# Current repository and branch
bash "$CVE_SCRIPTS/fix-all.sh"
# Current repository, specified branch
bash "$CVE_SCRIPTS/fix-all.sh" "0.23"
# Named or absolute-path repository, specified branch
bash "$CVE_SCRIPTS/fix-all.sh" "myrepo" "0.24"
fix-all.sh does everything: detect config, create fix branch, scan for CVEs, fix each deterministically, run tests, agent-review all results, and print the PR command.
When a project build is configured, each dependency update must pass it before commit. An incompatible update rolls back and leaves its CVEs actionable for review. Findings already removed by another dependency update require current scanner evidence before being reported as fixed.
Vendoring belongs to each tracked module. A scoped dependency update regenerates and commits that module's vendor tree, including nested trees when the root is not vendored; rejected updates restore the original trees and untracked files. Unchanged sibling module and vendor files remain outside the update.
Exit code 0: All CVEs addressed. Review commits and run the printed PR command.
Exit code 2: The run needs attention:
GATE_REMAINING > 0: CVEs were confirmed present after
all fix attempts. The PR command is still emitted (with a "Partial CVE fix" title)
when the other verification and repository policy gates pass; merge when acceptable.Exit code 1: Error (skill setup or invocation problem).
These are script exit codes. GNU Make returns 2 when a recipe fails, including
setup errors. The all recipe keeps each script's status and gives setup errors
priority over partial results; read its error output or invoke the scripts
directly when the exact exit code is needed.
If the arguments contain all (e.g., /cve-fix all 0.23 or
$shipyard:cve-fix all 0.23), do NOT run the single-repository commands
above. Instead:
SKILL.md path and use its sibling scripts/
directory. When Claude Code does not expose that path, use the same
established standalone-install fallback as the single-repository flow.0.23).bash "$CVE_SCRIPTS/fix-all.sh" "NAME" "BRANCH" directly and must not
invoke this skill recursively.Report per repo: CVEs found, fixed, ignored, and PR command. Workers clean up their own child processes. Never run broad process/container cleanup from one worker because other repository runs may still be active.
To use the skill outside the shipyard source checkout, install the existing Shipyard plugin through its marketplace:
codex plugin marketplace add submariner-io/shipyard
codex plugin add shipyard@submariner
Codex invokes the installed skill as $shipyard:cve-fix. The existing Claude
installation remains supported:
cp -r skills/cve-fix ~/.claude/plugins/cve-fix
After installation, /cve-fix works in Claude Code and $shipyard:cve-fix
works in Codex. The make -C skills/cve-fix interface still works from the
source tree.
Claude Code uses /cve-fix; Codex uses $shipyard:cve-fix. In either runtime:
cve-fix - current repo, current branchcve-fix 0.23 - current repo, specified branchcve-fix master - current repo, OpenShift master branchcve-fix myrepo 0.24 - repo name from repos.yamlcve-fix /absolute/path/to/repo 0.24 - absolute pathcve-fix all 0.23 - all repos in repos.yamlBranches may precede or follow an explicit repository. In the current repo,
standard main/master names and locally known feature branches are supported.
Arguments are order-independent. Short versions like 0.23 auto-expand
to release-0.23. Repos are absolute paths or names from repos.yaml.
Registry resolution order (first match wins):
$CVE_FIX_REPOS environment variable (any path)${XDG_CONFIG_HOME:-~/.config}/cve-fix/repos.yamlrepos.yaml in the skill directory (git-ignored)repos.yaml.example is a template, not executable input.To use repo names, resolve CVE_SCRIPTS as described above, then create a
registry file and populate it with your repos:
# Option A: XDG location (shared across skill installations, recommended)
registry_dir="${XDG_CONFIG_HOME:-$HOME/.config}/cve-fix"
mkdir -p "$registry_dir"
cp "$CVE_SCRIPTS/../repos.yaml.example" "$registry_dir/repos.yaml"
# Edit "$registry_dir/repos.yaml"
# Option B: in-repo location (git-ignored)
cp "$CVE_SCRIPTS/../repos.yaml.example" "$CVE_SCRIPTS/../repos.yaml"
# Edit "$CVE_SCRIPTS/../repos.yaml"
Absolute paths always work without any registry.
From the source checkout:
make -C skills/cve-fix fix REPO=myrepo BRANCH=0.24 # Claude reviewer (default)
make -C skills/cve-fix fix REPO=myrepo BRANCH=0.24 CVE_FIX_AGENT=codex
make -C skills/cve-fix fix REPO=/absolute/path BRANCH=0.24 # absolute path
make -C skills/cve-fix all BRANCH=0.23 CVE_FIX_AGENT=codex # all repos with Codex
make -C skills/cve-fix test # run unit tests
CVE_FIX_AGENT accepts exactly claude or codex. It defaults to claude,
so existing Make invocations are unchanged. CVE_FIX_MODEL, when set, selects
the model for whichever reviewer is active. If the selected CLI is unavailable,
the existing deterministic-evidence fallback remains in effect.
Place a .cve-fix.yaml file in the repo root to override auto-detected settings.
All fields are optional — omitted fields use auto-detected defaults.
| Field | Default | Description |
|---|---|---|
build-command | detected build target | Build before scanning; Make builds force rebuilds; Dapper builds set BUILD_UPX=false |
clean-command | detected for non-Dapper repos | Clean artifacts before scan; Dapper consumers must opt in explicitly |
test-command | detected test target | Native unit, test, or test-unit; Shipyard Dapper uses in-container unit |
build-image | (none) | Container image for Go version detection |
k8s-version-guard | false | Treat K8s minor bumps as breaking changes |
upstream-org | (from git remote) | GitHub org for PR command generation |
unset-env | (none) | Env vars to unset before build/test; also scrubbed from optional agent review/subagent calls |
Grype can return zero findings after its cataloger skips the entire checkout,
including checkouts under /dev/shm on Linux. The workflow rejects a reported
zero-package catalog when tracked Go modules declare dependencies, and attempts
the container fallback. If both scans lack coverage, move the checkout to a
normal filesystem path or correct the cataloger exclusions before rerunning.
An unavailable selected fix version remains NEEDS_REVIEW. Failure to resolve one Go module candidate does not prove that an advisory lacks a published fix: product tags may differ from module versions, and grouped advisories may list other available fixes. The workflow adds no ignore for this lookup failure.
Dependency repairs compare current source findings before and after the update when a scanner is configured. New advisory/package/module findings, including ignored findings, roll back the transaction for review. A failed comparison also rolls back the update; fixing one advisory cannot justify introducing another. The final scan separately verifies compiled binaries and coverage. Executable text containing packer fixture strings is not a packed binary. Packed binaries and non-release compiler markers leave stdlib coverage unconfirmed.
The workflow signs commits it creates and performs a final base-branch refresh
before printing a PR command. If the base moved during the run, the refresh
failed, or any commit in the proposed range lacks Signed-off-by:, no PR
command is printed; rerun from the current base or add the required sign-off.
The workflow does not silently rebase, since that can rewrite operator edits
and obscure conflicts.
When a repository has an existing make licensecheck target, the workflow runs
it before printing a PR command. A license-policy failure suppresses the PR
command. The skill never adds license allowlist entries or changes licensing
policy; those decisions require repository maintainers and, where applicable,
CNCF approval. Unexpected files outside dependency and Grype policy files also
suppress the PR command so unrelated changes do not enter a CVE-only PR.
The license-gate timeout is configurable with CVE_FIX_LICENSE_TIMEOUT
(default 300 seconds).
Builds and tests are bounded as well: CVE_FIX_BUILD_TIMEOUT and
CVE_FIX_TEST_TIMEOUT default to 1800 seconds each. A timeout is treated as an
unverified result and suppresses the PR command.
| Issue | Solution |
|---|---|
| CVE persists after fix | Verify FIXED-IN version; check for replace directives |
| New CVE appears after fix | The update is rolled back; review the reported new finding |
| Tests fail | Try different version; check CI logs |
| Container "no route to host" | Retry; if it persists, restart the container runtime |
| Stdlib CVEs | Go bumps must not exceed the detected build image's Go version |
| UPX hides expected stdlib CVEs | Build with BUILD_UPX=false in .cve-fix.yaml or CVE_FIX_BUILD_CMD |
| Git fetch fails | Run git fetch manually to see the error; see Git remotes |
| Git checkout fails (untracked files) | Run git stash -u before checkout, git stash pop after |
| ENOSPC / temp directory not writable | /tmp is full; run df -h /tmp, then export TMPDIR=/path/with/space before re-running |
The workflow fetches origin exactly as configured and never rewrites its URL.
Fetches are non-interactive (SSH BatchMode, no credential prompts), so a
missing key fails fast instead of hanging. Private repositories need a working
SSH key or agent. Public repositories should use an HTTPS fetch URL with an SSH
push URL:
[remote "origin"]
url = https://github.com/org/repo
pushurl = [email protected]:org/repo.git
A configured core.sshCommand or GIT_SSH_COMMAND is kept.
Go/golangci-lint is generally not a required or gating CI job on Submariner
release branches. For CVE-only maintenance PRs targeting release-*, do not
spend time fixing Go lint findings or add unrelated source changes solely to
make that job green. General contribution and CI guidance is in
CONTRIBUTING.md.
This does not waive checks that establish whether the dependency change is
safe: investigate compilation/build failures, dependency-license violations,
missing or inconsistent go.sum entries, the final CVE scan, and any other
repository-specific required or gating checks. A lint failure is actionable
only when maintainers explicitly request it or when it is masking one of those
checks.
toolchain, never go: A stdlib fix sets the toolchain directive in
each affected go.mod and leaves the go directive alone. go is the minimum language version
and is inherited by every module that depends on this one, so raising it would force the bump on
consumers and break GOTOOLCHAIN=local builds; toolchain only selects the compiler for this
module and is ignored by local-only builds. The edit is file-only (no go mod tidy, vendor sync
or download) and never lowers a module's effective Go (the greater of go and toolchain). A
pinned builder image still compiles with its own Go, so when the detected builder is older than
the fix the workflow reports NEEDS_REVIEW: update the build image.
Build images older than Go 1.21 need review because they cannot read a toolchain directive.
Fix selection uses the builder's patched release stream when every grouped advisory provides
a fix there; otherwise it starts from the lowest effective Go among repository modules.
A library's older language directive does not force selection of an older compiler stream.build-image config: When the build image Go version is unknown,
same-minor patch bumps are auto-applied using each module's effective Go minor.
Cross-minor fixes route to NEEDS_REVIEW because builder compatibility cannot be proved; add
build-image to .cve-fix.yaml or set CVE_FIX_BUILD_IMAGE for the run.
Compatible modules may still receive their patch; a skipped older module keeps the run partial.
Dependency fixes restore existing toolchain names, including default and custom suffixes.
A vulnerable custom toolchain needs a vendor-supported fix; the workflow preserves its name
and reports NEEDS_REVIEW instead of replacing it with stock Go.go.mod location. Multiple no-fix findings at
distinct Grype-reported go.mod locations produce independent scoped entries;
dependency-graph presence alone does not invent an affected scan location.
Permanent or ambiguous policy is left for team review, and a clean Grype scan does
not override this YAML policy gate.go directive (Go enforces this) may advance it across minor versions when the detected build
image is already at or above the new directive, including its patch component. A same-minor
directive above the builder is rejected.
The build, tests, and final rescan must still pass before a PR command is emitted.fix-state and an
exact package selector. Direct use of ignore.sh requires either --fix-state/--no-fix or an
explicit --permanent; omission can no longer create a permanent ignore accidentally.
Retry handlers preserve the scanner's actual no-fix state. A generated binary's
duplicate is covered only by an ignored finding for the same advisory, package,
version, state and owning module. Original binary evidence is retained under
generatedBinaryDuplicates; unproven or stale binaries remain actionable.+incompatible) packages: Version comparison strips the
+incompatible suffix. A fix requiring a higher major is left actionable as
NEEDS_REVIEW; the workflow never converts a published but API-incompatible fix
into a permanent vulnerability ignore. Patch and minor bumps within the same
major are applied normally.GOWORK=off against each module.
Updates run bounded go work sync when go.work exists, then refresh changed
modules' checksums and vendor trees before the project build. Rejected updates
restore that metadata; the workspace file is preserved.GOPROXY defaults to https://proxy.golang.org,direct;
private proxy and checksum settings are inherited. GONOSUMDB skips matching
checksum-database lookups and GOSUMDB=off disables that database, but existing
go.sum hashes still constrain downloaded content.go list -m -json all graph determines
package presence, even without a textual requirement in go.mod. Scanner
locations scope the module to repair. A failed graph lookup remains unresolved
rather than proving the package absent.Makefile (opens in a new tab)agents/openai.yaml (opens in a new tab)repos.yaml.example (opens in a new tab)scripts/binary-module-locations.py (opens in a new tab)scripts/clean.sh (opens in a new tab)scripts/detect.sh (opens in a new tab)scripts/fix-all.sh (opens in a new tab)scripts/fix-package.sh (opens in a new tab)scripts/fix-stdlib.sh (opens in a new tab)scripts/ignore.sh (opens in a new tab)scripts/lib.sh (opens in a new tab)scripts/locate.sh (opens in a new tab)scripts/read-config.py (opens in a new tab)scripts/review-prompt.md (opens in a new tab)scripts/review.sh (opens in a new tab)scripts/scan.sh (opens in a new tab)scripts/test-lib.sh (opens in a new tab)scripts/write-subagent-report.sh (opens in a new tab)subagents/existing-entries.md (opens in a new tab)subagents/existing-entries.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub submariner-io/shipyard --plugin shipyardOther plugins' skills for the same job