socket-patch CLI
Apply Socket Certified Patches from the command line
socket-patch applies Socket Certified Patches to the dependency versions your project already uses. It is a standalone binary, separate from the Socket CLI. For a step-by-step walkthrough, start with Patch what you can't upgrade.
Install
curl -fsSL https://install.socket.dev/patch | sh # macOS and Linux
npm install -g @socketsecurity/socket-patch # any platform, including Windows
cargo install socket-patch-cli # from crates.ioThe installer verifies the release checksums and puts the binary in /usr/local/bin or ~/.local/bin. Windows archives are also on the GitHub releases page. socket-patch --update updates a standalone install.
Quick start
Run these from the root of a project with a supported lockfile. Dependencies don't need to be installed.
socket-patch scan --dry-run # preview the patches and the files that would change
socket-patch scan # apply them; this never prompts
socket-patch list # show what is patchedCommit the files the scan reports, then install with your normal package manager.
Patch modes
| Mode | How to choose it | What gets committed | What installs need |
|---|---|---|---|
| Hosted | The default for a new project | The lockfile, and for some package managers one registry setting | Network access to patch.socket.dev |
| Vendored | --mode vendored, or socket-patch vendor | .socket/vendor/ and the lockfile | Nothing from Socket |
| Agent | --mode agent | .socket/manifest.json and .socket/blobs/ | socket-patch apply after every install |
A project keeps the mode it already uses until you pass --mode. Hosted and vendored modes cover every ecosystem except Deno, which supports agent mode only. The support matrix lists each package manager.
Commands
Find and apply patches:
socket-patch scan: find the patches that apply to a project and apply themsocket-patch get: apply the patch for one CVE, GHSA, package or patch UUID
Inspect and prove:
socket-patch list: show the project's patches and the mode each one usessocket-patch vex: write an OpenVEX document for the CVEs your patches cover
Vendor:
socket-patch vendor: move hosted patches into.socket/vendor/socket-patch repair: restore vendored packages or agent patch data that are missing or damaged
Undo:
socket-patch rollback: put one package, or every package, back on the upstream releasesocket-patch remove: roll back and forget the patches for one package or patch UUID
Agent mode:
socket-patch apply: reapply agent mode patches after installing dependencies
Options every command accepts
| Option | Environment variable | What it does |
|---|---|---|
--dry-run | SOCKET_DRY_RUN | Preview without changing anything |
-j, --json | SOCKET_JSON | Print a machine-readable result |
--cwd <DIR> | SOCKET_CWD | Run in another directory |
-e, --ecosystems <LIST> | SOCKET_ECOSYSTEMS | Limit the run to npm, pypi, cargo, gem, golang, maven, composer, nuget or deno |
--api-token <TOKEN> | SOCKET_API_TOKEN | Use this API token. Without one, only free patches are available |
-o, --org <SLUG> | SOCKET_ORG_SLUG | Choose the organization. It is worked out from the token when you leave it off |
--offline | SOCKET_OFFLINE | Never use the network, and fail if something has to be downloaded. scan and get can't run offline |
-y, --yes | SOCKET_YES | Skip confirmation prompts |
-v, --verbose | Show more detail | |
-s, --silent | Print errors only | |
--no-telemetry | SOCKET_TELEMETRY_DISABLED | Don't send usage telemetry |
Authentication
- Free patches need no token. The CLI reads them from the public patch service at
patches-api.socket.dev. - Paid patches need an API token for an organization with Socket Patches. Set
SOCKET_API_TOKEN, or runsocket loginwith the Socket CLI, whichsocket-patchpicks up. Any organization-wide token works, and no particular scope is needed. A token limited to certain repositories is refused.
Output and exit status
With --json, every command prints one object with command, status, dryRun, events and summary. Check the exit status before you read it: an argument error exits with status 2 and prints no JSON.
The CLI reports each command's outcome to Socket as usage telemetry: the command, the CLI version, the operating system, counts such as patches applied and, for get, the patch UUID. It sends no package names, file paths or file contents, apart from what an error message quotes. --no-telemetry, SOCKET_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1 turns it off.
socket patch in the Socket CLI
socket patch in the Socket CLIThe socket patch command that ships with the Socket CLI runs an earlier release of this tool. It has no hosted or vendored mode, and its options and JSON output differ. Use the standalone socket-patch binary for the commands in this section.
More
- About Socket Certified Patches: what a patch is, how it is tested and how it reaches your project
- Socket Patch FAQ
socket-patchon GitHub, with the full usage and configuration guides
Updated about 3 hours ago