---
title: "Fix pull requests"
description: "Open a pull request that bumps a vulnerable dependency to its fixed version, one per package, for npm, Go modules and pip requirements on github.com."
---

From a vulnerability finding, **Open fix PR** opens a pull request on the
repository that bumps the vulnerable package to a fixed version. The pull
request's description lists every open finding on the repository the bump
clears.

## What it changes

| Ecosystem | File edited | Lockfile |
| --- | --- | --- |
| npm | `package.json`: the package's version in `dependencies`, `devDependencies`, `optionalDependencies` or `peerDependencies`, keeping a `^` or `~` prefix | `package-lock.json` too, when that can be proved safe (below). Otherwise a command to run. |
| Go modules | `go.mod`: the version on the module's `require` line | `go.sum` too, when that can be proved safe (below). Otherwise `go mod tidy`. |
| pip | `requirements*.txt`: an exact `name==version` pin | That file is the lock, so the change is complete. Ranges (`>=`, `~=`) are not rewritten, and a pin with `--hash` is refused. |

Only the version string changes in the manifest; the rest of the file is
byte-for-byte the same.

## The lockfile

TRUSTIVAN runs no package manager and no build against your repository, because
one can execute install scripts and other code the repository names. So a
lockfile is edited only where the result is provably what the package manager
would have written. Where it cannot be, the pull request says which file, why,
and exactly what to run, and the dashboard shows the same sentence on the finding
and on the repository's page.

**`package-lock.json`** (or `npm-shrinkwrap.json`), lockfile version 2 or 3, moves
when all of this holds. The entry's `version`, `resolved` and `integrity` and the
root's copy of the range change, and nothing else:

- the lockfile resolves the package from `https://registry.npmjs.org`, so a
  private package that shares a public name is never replaced from the public
  registry;
- the new version declares the same dependencies, peer dependencies, binaries,
  platforms and install scripts as the entry it replaces;
- every other package that resolves to that copy still accepts the new version.

Otherwise, run on the pull request's branch:

| Lockfile | Command |
| --- | --- |
| `package-lock.json`, `npm-shrinkwrap.json` | `npm install --package-lock-only --ignore-scripts` |
| `pnpm-lock.yaml` | `pnpm install --lockfile-only` |
| `yarn.lock` | `yarn install --mode=update-lockfile` (Yarn 1: `yarn install --ignore-scripts`) |
| `bun.lock`, `bun.lockb` | `bun install --lockfile-only` |

A nested copy of the package, which another package requires at its own version,
is not moved by either route, and a finding on it stays open. The pull request
names those copies when it edited the lockfile.

**`go.sum`** gains the new version's two lines when both versions' `go.mod` files
require exactly the same modules, the new one asks for no newer Go than yours, and
your `go.mod` does not `replace` the module. The lines come from the Go checksum
database and are verified against its signed log, as the `go` command verifies
them. TRUSTIVAN reads no module's source, so if the new version imports a package
from a module your build never used, `go build` reports a missing `go.sum` entry;
run `go mod tidy`. The old lines stay until you do. In every other case, run
`go mod tidy` on the branch.

**pip.** A plain pin is complete, but if a tool generates the file (`pip-compile`,
`pip freeze`), change its source too, or its next run restores the old version.
TRUSTIVAN refuses a pin with `--hash`, because its hashes name the old version's
files: regenerate with `pip-compile --generate-hashes`. It also refuses a repository
with no `requirements*.txt` beside the finding, such as a Poetry, Pipenv or uv
project: their lockfiles are not edited.

Reading this data needs `registry.npmjs.org`, `proxy.golang.org` and
`sum.golang.org` to be reachable from the API. If they are not, the pull request
still opens, and says what to run.

The file is the manifest next to where the finding was observed (a lockfile
maps to the `package.json` or `go.mod` beside it), or the one at the
repository root when the finding names no path.

## One pull request per package

All open vulnerabilities in the same package on the repository are fixed by
one pull request, bumped to the **highest** fixed version any of them needs,
so one merge clears them all. Where an advisory lists several fixed versions,
the one on the installed version's major line is preferred.

Asking again for the same bump returns the pull request already opened. The
branch is `trustivan/fix/<ecosystem>/<package>-<version>`, created from the
default branch's current head, with one commit for each file changed. TRUSTIVAN never moves an
existing branch: if that branch already exists, the request is refused
(`409`) and nothing is committed.

## When it is not offered

The button is replaced with the reason when:

- the finding is not a vulnerable dependency, or its ecosystem is not npm, Go
  modules or pip (Maven, NuGet, RubyGems, Cargo, Composer and OS packages are
  not supported yet);
- the advisory names no fixed version;
- the package is not a direct dependency in the manifest (a transitive
  dependency needs a package manager), or is pinned to something that is not a
  version (a git URL, a tag, `workspace:*`);
- the repository is not on github.com (GitLab and Bitbucket fix pull requests
  are not supported yet);
- **Fix PRs** is off for the repository (it is off until you switch it on), or
  no GitHub App installation is linked to the organization.

## Set it up

1. Link the GitHub App installation, with **Contents: read and write** and
   **Pull requests: read and write**, as in
   [Pull request checks](/integrations/pull-request-checks#link-the-github-app).
2. On the repository's page, turn on **Fix PRs** in the **Pull requests** card,
   or `PATCH /api/v1/assets/{id}/code-settings` with `{"fix_prs_enabled": true}`.
3. On a finding, choose **Open fix PR**, or call
   `POST /api/v1/findings/{id}/fix-pr` (`findings:write`).
   `GET /api/v1/findings/{id}/fix-pr` reports what it would change, and the
   result's `lockfile_follow_up` is what is left to run. Empty means nothing;
   absent means the pull request predates this being recorded.

Review the package's release notes before merging: a version bump can change
behaviour, and TRUSTIVAN does not run your tests.

## Verification

The GitHub calls (default branch, branch head, file read, branch create, file
update, pull request search and create) are tested against **recorded API
responses** shaped from GitHub's published examples, through the same outbound
network guard production uses. They have not been run against a live GitHub
account. The same goes for the npm registry and the Go module proxy. The
checksum database client is the Go project's own, tested against its test server
with a real signed log. An edited lockfile of the shape these tests produce passes
`npm ci --dry-run --offline`, and an unedited one fails it.
