socket-patch scan

Find the patches that apply to a project and apply them

socket-patch scan finds the patches that apply to a project's dependencies and applies them. It reads the project's lockfiles, so dependencies don't need to be installed first.

  • It applies patches without asking. Use --dry-run to preview. --json is not a preview: it applies patches and prints a machine-readable result.
  • Mode. A project keeps the mode it already uses. A project with no patches yet gets hosted mode. Pass --mode vendored or --mode agent to choose another.
  • Monorepos. Run from the repository root, a hosted or vendored scan covers every directory that has its own lockfile, apart from test and fixture directories. Name directories to limit it, and quote globs. With --json, the scan reports on the current directory only.
  • One patch per package version. When a package has several patches, the scan applies the highest ranked one and names the advisories that stay open. Patches are ranked by severity, then by the number of advisories they fix, then by publication date.
  • Your own patches are left alone. A package you already patch with pnpm, Yarn, patch-package or a similar tool is skipped and reported. Pass --allow-patch-conflicts after you have reviewed the overlap.
  • Policy. A socket.yml at the repository root can limit what scan selects. See Scope patches with socket.yml.
socket-patch scan --dry-run                     # preview
socket-patch scan                               # apply in the project's mode, hosted for a new project
socket-patch scan --mode vendored               # commit the patched packages into the repository
socket-patch scan --package lodash,minimist     # only these packages
socket-patch scan --ecosystems npm,pypi         # only these ecosystems
socket-patch scan --min-severity high           # only patches that fix a high or critical advisory
socket-patch scan --max-new-patches 5           # add at most five newly patched packages
socket-patch scan 'apps/*'                      # only these project directories
socket-patch scan --vex socket.vex.json         # also write an OpenVEX document

socket-patch scan -h

-h prints the common options shown here. socket-patch scan --help prints every option.

$ socket-patch scan -h

Find and apply available patches (preview with --dry-run)

Usage: socket-patch scan [OPTIONS] [PATHS]...

Arguments:
  [PATHS]...  Scan these project directories, or installed-package paths in agent mode

Options:
      --mode <MODE>         Patch mode [default: the project's existing mode, else hosted] [possible
                            values: hosted, vendored, agent]
      --package <PACKAGES>  Select package names or PURLs (repeat or separate with commas) [env:
                            SOCKET_SCAN_PACKAGES=]
      --vex <VEX>           Write OpenVEX to this path after a successful run [env: SOCKET_VEX=]
  -h, --help                Print help (see more with '--help')
  -V, --version             Print version

Global options:
      --cwd <CWD>                Working directory [env: SOCKET_CWD=] [default: .]
  -e, --ecosystems <ECOSYSTEMS>  Restrict to these ecosystems (comma-separated): npm, pypi, cargo,
                                 gem, golang, maven, composer, nuget, deno [env: SOCKET_ECOSYSTEMS=]
      --offline                  Disable network access; fail if remote data is needed [env:
                                 SOCKET_OFFLINE=]
  -j, --json                     Emit machine-readable JSON output [env: SOCKET_JSON=]
      --dry-run                  Preview the operation without making any mutations [env:
                                 SOCKET_DRY_RUN=]

Did this page help you?