# Add govulncheck to a Go CLI's CI

Yes. An agent adds a govulncheck workflow that fails only on vulnerabilities your Go CLI can reach, runs on every push and weekly, and reports its first scan.

[Run this on Rush](https://cloud.getrush.ai/run/add-govulncheck-to-ci/go-cli/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and reads what CI already does before adding a job. In a CLI like muesli/duf, `go.mod` declares module `github.com/muesli/duf` on `go 1.23.0` with ten direct dependencies, among them `github.com/jedib0t/go-pretty/v6`, `github.com/spf13/pflag`, `github.com/muesli/termenv`, `golang.org/x/sys` and `golang.org/x/term`. `.github/workflows/build.yml` runs `go build -v ./...` and `go test ./...` on a matrix of Go `~1.23` and `^1` across Ubuntu, macOS and Windows with `actions/setup-go@v6.0.0`; `lint.yml` and `lint-soft.yml` run `golangci-lint-action@v8` against `.golangci.yml` (version 2, with `gosec`, `revive`, `unparam` and others) and a softer config; `manpage.yml` builds with `-tags mango` and commits `duf.1`; `goreleaser.yml` publishes releases; and `.github/dependabot.yml` opens daily update pull requests for Go modules and Actions. Nothing checks the dependency graph or the standard library against the Go vulnerability database.

The agent adds `.github/workflows/govulncheck.yml`. It runs on `push`, on `pull_request` and on a weekly `schedule`, because a vulnerability can be published against a module version the repository has not changed in months. The job sets `permissions: contents: read`, checks out the code, installs Go with `go-version-file: go.mod` and `check-latest: true` so the toolchain matches the oldest version the build matrix supports, and runs `golang/govulncheck-action` pinned to a release with `go-package: ./...`. In source mode govulncheck builds a call graph and reports a vulnerability only when a path from the CLI's code reaches the affected function, so an advisory against a function the CLI never calls is listed as informational and does not fail the job.

Before writing the workflow the agent runs `go install golang.org/x/vuln/cmd/govulncheck@latest` and `govulncheck ./...` in the sandbox against the current `go.sum` and the Go toolchain the module declares, and copies the output into the pull request as the baseline. If the scan reports a reachable finding, the agent bumps that one module with `go get` and re-runs `go build ./...` and `go test ./...`; the bump goes in the same pull request only when both pass, otherwise the finding is left as a listed item for a maintainer to decide. No finding is invented and no module is upgraded without a reason in the scan.

Because Dependabot already covers `github-actions`, the new action's pin will get its own update pull requests like `setup-go` and `checkout` do. The agent adds the workflow's status badge next to the build badge at the top of `README.md`, following the existing shields.io pattern, and runs `actionlint` on the new file so the YAML is valid before it is pushed.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add govulncheck to this Go CLI's GitHub Actions. Read go.mod and every workflow under .github/workflows first. Add a workflow that runs govulncheck in source mode against ./... on push, pull request and a weekly schedule, using the Go version from go.mod, with read-only permissions. Run govulncheck in your sandbox first and put its output in the pull request; if it reports a reachable vulnerability, upgrade only that module and only if build and tests still pass. Add the workflow badge to the README beside the build badge. Open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request on its own branch that adds `.github/workflows/govulncheck.yml` and a badge line in `README.md`, plus changes to `go.mod` and `go.sum` only if the baseline scan found a reachable vulnerability that a passing upgrade fixed. The description contains the scan output from the sandbox, with each finding marked reachable or informational, and the `go build` and `go test` output if anything was bumped.

The run's record keeps the govulncheck install, the scan, and any build and test runs, so a reviewer can see what the database said on that day without running the tool. The new workflow runs on the pull request itself once it is opened, so its first result appears as a check before merging.

Before merging, a reviewer confirms the weekly cron time suits them, decides whether a scheduled failure should also open an issue, and checks whether the release workflow should scan the built binaries in binary mode as a second pass, which the pull request mentions as a follow-up.

## Run it on every repository you hand off

Start it from a terminal with `POST /o/{org}/sessions`, this body and the repository in `resources`, then move on; the pull request shows up when the agent is done. A follow-up through `POST /o/{org}/sessions/{id}/messages` wakes the parked sandbox for a second step, such as adding binary-mode scanning to the release workflow or opening an issue automatically when the scheduled run fails.

A team with many Go repositories can start one run per repository, each in its own sandbox with its own pull request. Send a `request_id`, a UUID per repository, so running the script twice returns the run already started instead of opening a second pull request.

## Why run it on Rush?

Adding the workflow file is five minutes; knowing what it will report on day one, and whether a reachable finding can be fixed by an upgrade that keeps the build green, is the part people skip. The agent runs the scan first, tries the upgrade only when the scan calls for it, and writes down what it found, so the pull request arrives with its first result rather than a surprise on the next push.

The sandbox runs govulncheck, the build and the tests for real and keeps the output in the run's record. Several repositories can be scanned at once in separate sandboxes, each with its own pull request and its own baseline.

## Frequently asked questions

### Dependabot already updates my modules. Why add govulncheck?

Dependabot proposes newer versions; it does not say whether your binary is affected by a published vulnerability or whether the vulnerable function is ever called. govulncheck reads the Go vulnerability database and your call graph and fails the job only when a reachable path exists, so it tells you what matters today and stays quiet about the rest.

### Will it fail my build on a vulnerability my code never calls?

No. In source mode, an advisory against a function your packages do not reach is reported as informational and the job passes. Only a reachable finding fails it. The workflow runs against `./...`, so every package in the module is part of the graph.

### Why run it on a schedule as well as on pushes?

Because the database changes without your code changing. A module version that was clean on Monday can have an advisory on Friday, and a weekly run surfaces that on a repository nobody has pushed to. The cron time is in the workflow and easy to change.

### Does it scan the released binaries too?

Not in this pull request. Source mode on the module covers what the release builds compile. govulncheck also has a binary mode that inspects a built executable, which fits in the release workflow after goreleaser runs, and the pull request lists that as a follow-up.

## More Go CLI jobs

- [Add HTTP Timeouts to a Go CLI](https://getrush.ai/run/add-http-timeouts/go-cli/)
- [Add JSON Output to a Go Command-Line Tool](https://getrush.ai/run/add-json-output/go-cli/)
- [Add a Man Page to a Go CLI](https://getrush.ai/run/add-man-page/go-cli/)

## The same job on other stacks

- [Add govulncheck to a Cobra CLI's CI](https://getrush.ai/run/add-govulncheck-to-ci/cobra/)
- [Add govulncheck to CI for a Fiber Multi-Module Repository](https://getrush.ai/run/add-govulncheck-to-ci/fiber/)

## More jobs like this: Hand off a long task

- [Add Graceful Shutdown to an Actix Web App](https://getrush.ai/run/add-graceful-shutdown/actix/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
