Skip to main content

CLI tool for applying security patches to dependencies

Project description

Socket Patch CLI

Apply security patches to npm, Python, and Rust dependencies without waiting for upstream fixes.

Installation

One-line install (recommended)

curl -fsSL https://raw.githubusercontent.com/SocketDev/socket-patch/main/scripts/install.sh | sh

Detects your platform (macOS/Linux, x64/ARM64), downloads the latest binary, and installs to /usr/local/bin or ~/.local/bin. Use sudo sh instead of sh if /usr/local/bin requires root.

Manual download

Download a prebuilt binary from the latest release:

# macOS (Apple Silicon)
curl -fsSL https://github.com/SocketDev/socket-patch/releases/latest/download/socket-patch-aarch64-apple-darwin.tar.gz | tar xz

# macOS (Intel)
curl -fsSL https://github.com/SocketDev/socket-patch/releases/latest/download/socket-patch-x86_64-apple-darwin.tar.gz | tar xz

# Linux (x86_64)
curl -fsSL https://github.com/SocketDev/socket-patch/releases/latest/download/socket-patch-x86_64-unknown-linux-musl.tar.gz | tar xz

# Linux (ARM64)
curl -fsSL https://github.com/SocketDev/socket-patch/releases/latest/download/socket-patch-aarch64-unknown-linux-gnu.tar.gz | tar xz

Then move the binary onto your PATH:

sudo mv socket-patch /usr/local/bin/

npm

npx @socketsecurity/socket-patch

Or install globally:

npm install -g @socketsecurity/socket-patch

pip

pip install socket-patch

Cargo

cargo install socket-patch-cli

Quick Start

You can pass a patch UUID directly to socket-patch as a shortcut:

socket-patch 550e8400-e29b-41d4-a716-446655440000
# equivalent to: socket-patch get 550e8400-e29b-41d4-a716-446655440000

Commands

All commands support --json for structured JSON output and --cwd <dir> to set the working directory (default: .). Every JSON response includes a "status" field ("success", "error", "no_manifest", etc.) for reliable programmatic consumption.

get

Get security patches from Socket API and apply them. Accepts a UUID, CVE ID, GHSA ID, PURL, or package name. The identifier type is auto-detected but can be forced with a flag.

Alias: download

Usage:

socket-patch get <identifier> [options]

Options:

Flag Description
--org <slug> Organization slug (required when using SOCKET_API_TOKEN)
--id Force identifier to be treated as a UUID
--cve Force identifier to be treated as a CVE ID
--ghsa Force identifier to be treated as a GHSA ID
-p, --package Force identifier to be treated as a package name
-y, --yes Skip confirmation prompt for multiple patches
--save-only Download patch without applying it (alias: --no-apply)
--one-off Apply patch immediately without saving to .socket folder
-g, --global Apply to globally installed packages
--global-prefix <path> Custom path to global node_modules
--json Output results as JSON
--api-token <token> Socket API token (overrides SOCKET_API_TOKEN)
--api-url <url> Socket API URL (overrides SOCKET_API_URL)
--cwd <dir> Working directory (default: .)

Examples:

# Get patch by UUID
socket-patch get 550e8400-e29b-41d4-a716-446655440000

# Get patch by CVE
socket-patch get CVE-2024-12345

# Get patch by GHSA
socket-patch get GHSA-xxxx-yyyy-zzzz

# Get patch by package name (fuzzy matches installed packages)
socket-patch get lodash

# Download only, don't apply
socket-patch get CVE-2024-12345 --save-only

# Apply to global packages
socket-patch get lodash -g

# JSON output for scripting
socket-patch get CVE-2024-12345 --json -y

scan

Scan installed packages for available security patches.

Usage:

socket-patch scan [options]

Options:

Flag Description
--org <slug> Organization slug
--json Output results as JSON
--ecosystems <list> Restrict to specific ecosystems (comma-separated: npm,pypi,cargo)
-g, --global Scan globally installed packages
--global-prefix <path> Custom path to global node_modules
--batch-size <n> Packages per API request (default: 100)
--api-token <token> Socket API token (overrides SOCKET_API_TOKEN)
--api-url <url> Socket API URL (overrides SOCKET_API_URL)
--cwd <dir> Working directory (default: .)

Examples:

# Scan local project
socket-patch scan

# Scan with JSON output
socket-patch scan --json

# Scan only npm packages
socket-patch scan --ecosystems npm

# Scan global packages
socket-patch scan -g

apply

Apply security patches from the local manifest.

Usage:

socket-patch apply [options]

Options:

Flag Description
-d, --dry-run Verify patches without modifying files
-s, --silent Only output errors
-f, --force Skip pre-application hash verification (apply even if package version differs)
-m, --manifest-path <path> Path to manifest (default: .socket/manifest.json)
--offline Do not download missing blobs; fail if any are missing
-g, --global Apply to globally installed packages
--global-prefix <path> Custom path to global node_modules
--ecosystems <list> Restrict to specific ecosystems (comma-separated, e.g. npm,pypi)
--json Output results as JSON
-v, --verbose Show detailed per-file verification information
--cwd <dir> Working directory (default: .)

Examples:

# Apply patches
socket-patch apply

# Dry run
socket-patch apply --dry-run

# Apply only npm patches
socket-patch apply --ecosystems npm

# Apply in offline mode
socket-patch apply --offline

# JSON output for CI/CD
socket-patch apply --json

rollback

Rollback patches to restore original files. If no identifier is given, all patches are rolled back.

Usage:

socket-patch rollback [identifier] [options]

Options:

Flag Description
-d, --dry-run Verify rollback without modifying files
-s, --silent Only output errors
-m, --manifest-path <path> Path to manifest (default: .socket/manifest.json)
--offline Do not download missing blobs; fail if any are missing
-g, --global Rollback globally installed packages
--global-prefix <path> Custom path to global node_modules
--one-off Rollback by fetching original files from API (no manifest required)
--ecosystems <list> Restrict to specific ecosystems (comma-separated)
--json Output results as JSON
-v, --verbose Show detailed per-file verification information
--org <slug> Organization slug
--api-token <token> Socket API token (overrides SOCKET_API_TOKEN)
--api-url <url> Socket API URL (overrides SOCKET_API_URL)
--cwd <dir> Working directory (default: .)

Examples:

# Rollback all patches
socket-patch rollback

# Rollback a specific package
socket-patch rollback "pkg:npm/lodash@4.17.20"

# Rollback by UUID
socket-patch rollback 550e8400-e29b-41d4-a716-446655440000

# Dry run
socket-patch rollback --dry-run

# JSON output
socket-patch rollback --json

list

List all patches in the local manifest.

Usage:

socket-patch list [options]

Options:

Flag Description
--json Output as JSON
-m, --manifest-path <path> Path to manifest (default: .socket/manifest.json)
--cwd <dir> Working directory (default: .)

Examples:

# List patches
socket-patch list

# JSON output
socket-patch list --json

Sample Output:

Found 2 patch(es):

Package: pkg:npm/lodash@4.17.20
  UUID: 550e8400-e29b-41d4-a716-446655440000
  Tier: free
  License: MIT
  Vulnerabilities (1):
    - GHSA-xxxx-yyyy-zzzz (CVE-2024-12345)
      Severity: high
      Summary: Prototype pollution in lodash
  Files patched (1):
    - lodash.js

remove

Remove a patch from the manifest (rolls back files first by default).

Usage:

socket-patch remove <identifier> [options]

Arguments:

  • identifier - Package PURL (e.g., pkg:npm/package@version) or patch UUID

Options:

Flag Description
--skip-rollback Only update manifest, do not restore original files
-g, --global Remove from globally installed packages
--global-prefix <path> Custom path to global node_modules
--json Output results as JSON
-m, --manifest-path <path> Path to manifest (default: .socket/manifest.json)
--cwd <dir> Working directory (default: .)

Examples:

# Remove by PURL
socket-patch remove "pkg:npm/lodash@4.17.20"

# Remove by UUID
socket-patch remove 550e8400-e29b-41d4-a716-446655440000

# Remove without rolling back files
socket-patch remove "pkg:npm/lodash@4.17.20" --skip-rollback

# JSON output
socket-patch remove "pkg:npm/lodash@4.17.20" --json

setup

Configure package.json postinstall scripts to automatically apply patches after npm install.

Usage:

socket-patch setup [options]

Options:

Flag Description
-d, --dry-run Preview changes without modifying files
-y, --yes Skip confirmation prompt
--json Output results as JSON
--cwd <dir> Working directory (default: .)

Examples:

# Interactive setup
socket-patch setup

# Non-interactive
socket-patch setup -y

# Preview changes
socket-patch setup --dry-run

# JSON output for scripting
socket-patch setup --json -y

repair

Download missing blobs and clean up unused blobs.

Alias: gc

Usage:

socket-patch repair [options]

Options:

Flag Description
-d, --dry-run Show what would be done without doing it
--offline Skip network operations (cleanup only)
--download-only Only download missing blobs, do not clean up
--json Output results as JSON
-m, --manifest-path <path> Path to manifest (default: .socket/manifest.json)
--cwd <dir> Working directory (default: .)

Examples:

# Repair (download missing + clean up unused)
socket-patch repair

# Cleanup only, no downloads
socket-patch repair --offline

# Download missing blobs only
socket-patch repair --download-only

# JSON output
socket-patch repair --json

Scripting & CI/CD

All commands support --json for machine-readable output. JSON responses always include a "status" field for easy error detection:

# Check for available patches in CI
result=$(socket-patch scan --json --ecosystems npm)
patches=$(echo "$result" | jq '.totalPatches')

# Apply patches and check result
socket-patch apply --json | jq '.status'
# "success", "partial_failure", "no_manifest", or "error"

When stdin is not a TTY (e.g., in CI pipelines), interactive prompts auto-proceed instead of blocking. Progress indicators and ANSI colors are automatically suppressed when output is piped.

Environment Variables

Variable Description
SOCKET_API_TOKEN API authentication token
SOCKET_ORG_SLUG Default organization slug
SOCKET_API_URL API base URL (default: https://api.socket.dev)

Manifest Format

Downloaded patches (for npm, Python, and Rust packages) are stored in .socket/manifest.json:

{
  "patches": {
    "pkg:npm/package-name@1.0.0": {
      "uuid": "unique-patch-id",
      "exportedAt": "2024-01-01T00:00:00Z",
      "files": {
        "path/to/file.js": {
          "beforeHash": "git-sha256-before",
          "afterHash": "git-sha256-after"
        }
      },
      "vulnerabilities": {
        "GHSA-xxxx-xxxx-xxxx": {
          "cves": ["CVE-2024-12345"],
          "summary": "Vulnerability summary",
          "severity": "high",
          "description": "Detailed description"
        }
      },
      "description": "Patch description",
      "license": "MIT",
      "tier": "free"
    }
  }
}

Patched file contents are in .socket/blob/ (named by git SHA256 hash).

Supported Platforms

Platform Architecture
macOS ARM64 (Apple Silicon), x86_64 (Intel)
Linux x86_64, ARM64
Windows x86_64

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

socket_patch-1.6.1-py3-none-win_arm64.whl (2.4 MB view details)

Uploaded Python 3Windows ARM64

socket_patch-1.6.1-py3-none-win_amd64.whl (2.6 MB view details)

Uploaded Python 3Windows x86-64

socket_patch-1.6.1-py3-none-win32.whl (2.2 MB view details)

Uploaded Python 3Windows x86

socket_patch-1.6.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl (2.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64musllinux: musl 1.1+ x86-64

socket_patch-1.6.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (2.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

socket_patch-1.6.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

socket_patch-1.6.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

socket_patch-1.6.1-py3-none-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

socket_patch-1.6.1-py3-none-macosx_10_12_x86_64.whl (2.5 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file socket_patch-1.6.1-py3-none-win_arm64.whl.

File metadata

  • Download URL: socket_patch-1.6.1-py3-none-win_arm64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for socket_patch-1.6.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 4054ee0ea2bf22308caa2c052b4587baafbbdcc597098863d621d4c958c967c6
MD5 5ea0deb3f992fa5f384f3d89efac19f3
BLAKE2b-256 4b56ecc8325fc7cdc0650acc496acc02b75999f5818ac8948abaabb8c0b7be50

See more details on using hashes here.

Provenance

The following attestation bundles were made for socket_patch-1.6.1-py3-none-win_arm64.whl:

Publisher: release.yml on SocketDev/socket-patch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file socket_patch-1.6.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: socket_patch-1.6.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for socket_patch-1.6.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 091d5d7a82a780855824833218801833085f2a2b309c2df2913f7db51852cb6b
MD5 f54d326d665ef87831f25de2d8b8c0d4
BLAKE2b-256 30ed56615f8be1e5985d2a037e4cadaa8ce0b0a270e7770e1a3bdc62cb490ad5

See more details on using hashes here.

Provenance

The following attestation bundles were made for socket_patch-1.6.1-py3-none-win_amd64.whl:

Publisher: release.yml on SocketDev/socket-patch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file socket_patch-1.6.1-py3-none-win32.whl.

File metadata

  • Download URL: socket_patch-1.6.1-py3-none-win32.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for socket_patch-1.6.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 945686c7ea723be7e15f0d90ea23bfab770e7b9a19450e06c3155f5ae0ef7263
MD5 94a5ee1938b9a60710e780831faf1f8e
BLAKE2b-256 e386266ff2d903aa4ac7e96159d6e716d5e1c7678d50b3dc8ccef646807b139d

See more details on using hashes here.

Provenance

The following attestation bundles were made for socket_patch-1.6.1-py3-none-win32.whl:

Publisher: release.yml on SocketDev/socket-patch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file socket_patch-1.6.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for socket_patch-1.6.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 68c9d429a4b26d7936f79def6d637f404e05d9da1fdfce67df7f30155c63859c
MD5 7d3eb38e3c7db02a10561ff42c393d38
BLAKE2b-256 4c59eee9bb90fe198e9a5d51d73b0a3aeef39da033275d43c3f922f8d6a80953

See more details on using hashes here.

Provenance

The following attestation bundles were made for socket_patch-1.6.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl:

Publisher: release.yml on SocketDev/socket-patch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file socket_patch-1.6.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for socket_patch-1.6.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7ea01d6b4c362eaa966855ac225b10bdc3adab19da80640b2e494b00f29bbcfc
MD5 3934ac0c5700706af5de70a0b6f88c26
BLAKE2b-256 be9b69084a67550d697f6e4330c153e73443e51144bbc04506a59ec3fe8ad7f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for socket_patch-1.6.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: release.yml on SocketDev/socket-patch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file socket_patch-1.6.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for socket_patch-1.6.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 b0ebac142177aad87fd56d3f0e27f6c7563b5f217b490105ccb6eb29a9a6261e
MD5 e742e02f96317b7c13918dad0f935ca2
BLAKE2b-256 b08422a7e9add38bec33a8ecedf8808e83094eb37d2bf891d3d78bc0de59f243

See more details on using hashes here.

Provenance

The following attestation bundles were made for socket_patch-1.6.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl:

Publisher: release.yml on SocketDev/socket-patch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file socket_patch-1.6.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for socket_patch-1.6.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d499cd3724d75040ab606380cc5c6091d3f04654c7ac32e2043d1e31e73882d2
MD5 2809d8db7970e0f23ee66a7d62691d80
BLAKE2b-256 0fb8eb6ec779a748a7e7283803e63dd636e3e4fa0d013d821ad5306358bc44fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for socket_patch-1.6.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on SocketDev/socket-patch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file socket_patch-1.6.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for socket_patch-1.6.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a850c9884ce640240a38f41b88b43c587c19d4f0f1471714f4cd93ad3229586f
MD5 5b1f278686973626e5027ea2125e63b8
BLAKE2b-256 9f9f23e64ebd2c564bcdf0276165595618e2bbb09b02bc2f2133015ac7d19037

See more details on using hashes here.

Provenance

The following attestation bundles were made for socket_patch-1.6.1-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on SocketDev/socket-patch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file socket_patch-1.6.1-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for socket_patch-1.6.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4a7d15d6a0158538ed83fe6ae70d47508b9ffda6ce23597b19eeec793d2562b7
MD5 d9a8106715fa5b786817c64b18e1f6f7
BLAKE2b-256 5c3fd7a4f5ce107f65dba730d2e8c363213791c610fe49e2f8bd1b1db5418852

See more details on using hashes here.

Provenance

The following attestation bundles were made for socket_patch-1.6.1-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on SocketDev/socket-patch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page