# Socket Dep Patch > Aplica los parches de seguridad a nivel binario de Socket sin cambiar versiones de dependencias, usando socket-patch apply, y verifica que el parcheo persista en cada instalación. Fuente: https://skillsagentes.com/skills/socketdev/sauce/socket-dep-patch Markdown: https://skillsagentes.com/skills/socketdev/sauce/socket-dep-patch.md Repositorio: https://github.com/SocketDev/sauce Autor: SocketDev Licencia: MIT Actualizado: hace 3 meses Coste de contexto: 56 tok instalada, 4k tok al activarse, 4k tok con todos los archivos del bundle Bundle: 1 archivo, 15 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add SocketDev/sauce --skill socket-dep-patch --agent claude-code # Cursor npx -y skills add SocketDev/sauce --skill socket-dep-patch --agent cursor # Codex npx -y skills add SocketDev/sauce --skill socket-dep-patch --agent codex # Gemini CLI npx -y skills add SocketDev/sauce --skill socket-dep-patch --agent gemini # Windsurf npx -y skills add SocketDev/sauce --skill socket-dep-patch --agent windsurf # Cline npx -y skills add SocketDev/sauce --skill socket-dep-patch --agent cline ``` ## Qué hace - Aplica parches binarios de seguridad de Socket a dependencias instaladas sin cambiar números de versión - Escanea con socket-patch scan los parches disponibles y los aplica con socket-patch apply - Comprueba si el proyecto mantiene los parches tras cada instalación (postinstall, CI, Dockerfile) - Configura hooks de postinstall, pasos de CI o capas de Dockerfile para que los parches persistan ## Cuándo usarla - Quieres corregir vulnerabilidades sin cambiar versiones de dependencias - Quieres aplicar los parches binarios de Socket a tu proyecto - Una vulnerabilidad no tiene aún parche oficial pero Socket ofrece uno - Quieres una solución de seguridad rápida y de bajo riesgo en todas las dependencias ## Cuándo no - Socket no tiene parches disponibles para las vulnerabilidades actuales: usa /socket-dep-upgrade para actualizar versiones en su lugar ## Qué la activa - "Aplica los parches de seguridad de Socket sin tocar las versiones" - "Comprueba si hay parches binarios disponibles para mis dependencias" - "Configura el postinstall para que los parches de Socket persistan" - "Revisa si mi CI mantiene aplicados los parches de socket-patch" ## Antes de instalar - No se necesita API key para socket-patch (funciona en el nivel gratuito), pero las dependencias deben estar instaladas (p. ej. node_modules/) antes de parchear. - makes network requests ## Archivos - SKILL.md — 15 KB ## SKILL.md Reproducido tal cual desde SocketDev/sauce bajo MIT. Esta sección es el documento original y está en inglés. # Dep Patch Apply Socket's binary-level security patches to vulnerable dependencies **without changing their version numbers**. This skill uses `socket-patch apply` to fix known vulnerabilities in-place. Patches are applied in bulk - `socket-patch apply` patches all available packages at once. After applying patches, this skill checks whether the project is set up to **keep patches applied automatically** (via postinstall hooks, CI steps, or Dockerfile layers). If not, it walks through configuring automated patching. ## How This Differs from `/socket-dep-upgrade` | | `/socket-dep-patch` (this skill) | `/socket-dep-upgrade` | | ------------------------ | --------------------------------------------------------------------------- | ----------------------------------------- | | **Primary tool** | `socket-patch apply` | `socket fix` | | **What it does** | Applies binary-level patches without changing versions | Upgrades dependency versions to fix CVEs | | **Version changes?** | No | Yes | | **Code changes needed?** | No | Possibly (API migration for major bumps) | | **Scope** | All patchable packages at once | One dependency at a time | | **When to use** | You need fixes without version churn, or the upstream fix doesn't exist yet | You want to bring dependencies up to date | Use `/socket-dep-patch` when you want to fix vulnerabilities without risking breaking changes from version upgrades. Use `/socket-dep-upgrade` when you want full version upgrades with automated code migration. ## When to Use - The user wants to fix vulnerabilities without changing dependency versions - The user wants to apply Socket's binary patches to their project - A vulnerability has no upstream fix yet but Socket provides a patch - The user wants a quick, low-risk security fix across all dependencies ## Prerequisites - No API key is required for `socket-patch`. It works on the free tier. - **Dependencies must be installed before patching.** `socket-patch` operates on installed packages (e.g. `node_modules/`). If dependencies are not yet installed, run the project's install command first (e.g. `npm install`, `pnpm install`, `bun install`, `pip install -r requirements.txt`). ## Step 1: Install socket-patch Choose the installation method for your ecosystem: | Method | Command | | ------------------------ | ------------------------------------------------------------------------------------------- | | npm (one-off) | `pnpm dlx @socketsecurity/socket-patch apply` | | npm (global) | `npm install -g @socketsecurity/socket-patch` | | pip | `pip install socket-patch` | | cargo | `cargo install socket-patch-cli` | | Standalone (macOS/Linux) | `curl -fsSL https://raw.githubusercontent.com/SocketDev/socket-patch/main/install.sh \| sh` | Verify installation: ```shell socket-patch --version ``` ## Step 2: Scan for Available Patches Run `socket-patch scan` to discover which installed packages have Socket patches available. This downloads patch metadata to the `.socket/` folder without modifying any packages. ```shell socket-patch scan ``` Review the output to see which packages have patches available and what vulnerabilities they address. ## Step 3: Apply Patches Apply all patches discovered by `socket-patch scan`: ```shell socket-patch apply ``` This applies patches from the `.socket/` folder to installed packages (e.g. within `node_modules/`). No version numbers change in your manifest or lock files. After patching, verify the project still works: 1. Build the project 2. Run the full test suite 3. Check `.socket/manifest.json` for a summary of applied patches ## Step 4: Verify 1. Run `socket-patch scan` to confirm all available patches were applied 2. Run the build to ensure nothing breaks 3. Commit `.socket/manifest.json` to version control to track which patches are applied ## Step 5: Check Patch Setup After patches are applied and verified, check whether the project is configured to **keep patches applied automatically** (i.e. after every dependency install). If not, patches will be lost the next time someone runs `npm install` or CI rebuilds `node_modules/`. ### What to Check Scan the project for evidence of automated patching in any of these locations: | Location | What Counts as Configured | | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | | `package.json` `scripts.postinstall` | Contains `socket-patch scan` and `socket-patch apply` (or `@socketsecurity/socket-patch`) | | `.github/workflows/*.yml` | Contains `SocketDev/action@v1` with `mode: patch`, OR a step running `socket-patch scan` / `socket-patch apply` | | `.gitlab-ci.yml` | Contains a step running `socket-patch scan` / `socket-patch apply` | | `bitbucket-pipelines.yml` | Contains a step running `socket-patch scan` / `socket-patch apply` | | `Dockerfile` / `docker-compose.yml` | Contains a `RUN` layer with `socket-patch scan` / `socket-patch apply` | | `Makefile` / `Justfile` | Contains a target that runs `socket-patch scan` / `socket-patch apply` | | Other CI configs (`.circleci/config.yml`, `Jenkinsfile`, `azure-pipelines.yml`, `.travis.yml`) | Contains a step running `socket-patch scan` / `socket-patch apply` | ### Report Results
The configured and not-configured report shapes, and where each leads If automated patching **is** configured, report where: ```text Patch setup check: OK Automated patching found in: - .github/workflows/ci.yml (SocketDev/action@v1 mode: patch) - package.json postinstall hook Patches will persist across installs. ``` If automated patching is **not** configured, warn the user and offer to set it up: ```text Patch setup check: NOT CONFIGURED No automated patching found in CI, postinstall hooks, or Dockerfiles. Patches will be lost the next time dependencies are reinstalled. Would you like to set up automated patching? [yes/no] ``` If the user says yes (or if they don't respond and you're running inside `/socket-fix` Fix All mode), proceed to the Automated Patch Setup section below. If the user says no, skip setup and finish.
--- ## Automated Patch Setup Set up automated patching so `socket-patch apply` runs after every dependency install, keeping patches persistent across installs and CI rebuilds. ### Scan Codebase for Install/Build Locations Before configuring automation, scan the project to find ALL places where dependencies are installed and builds happen: | Location | What to Look For | | ------------------------------- | --------------------------------------------- | | `package.json` scripts | `install`, `postinstall`, `build`, `prebuild` | | CI configs (all formats) | install steps, build steps | | `Makefile` / `Justfile` | install and build targets | | `Dockerfile` / `docker-compose` | `RUN install`, `RUN build` layers | | Shell scripts (`*.sh`) | install/build commands | | `pyproject.toml` / `setup.py` | build system config | | `Cargo.toml` | build scripts | For each location, record the file path, the install command, and where to insert `socket-patch scan` and `socket-patch apply` (after install, before build). Present findings to the user before making changes. ### Package Manager Reference Use the appropriate command to run `socket-patch` based on the project's package manager: | Package Manager | Run socket-patch | | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | npm | `npx @socketsecurity/socket-patch scan` then `npx @socketsecurity/socket-patch apply` | | pnpm | `pnpm dlx @socketsecurity/socket-patch scan` then `pnpm dlx @socketsecurity/socket-patch apply` | | yarn | `npx @socketsecurity/socket-patch scan` then `npx @socketsecurity/socket-patch apply` | | bun | `bunx @socketsecurity/socket-patch scan` then `bunx @socketsecurity/socket-patch apply` | | deno | `deno run npm:@socketsecurity/socket-patch scan` then `deno run npm:@socketsecurity/socket-patch apply` | | Python | `pipx run socket-patch scan && pipx run socket-patch apply` (if pipx available), else `pip install socket-patch && socket-patch scan && socket-patch apply` | | Standalone | `curl -fsSL https://raw.githubusercontent.com/SocketDev/socket-patch/main/install.sh \| sh` then `socket-patch scan && socket-patch apply` | | GitHub Actions | `SocketDev/action@v1` with `mode: patch` (preferred - handles scan+apply automatically) | Use the runner that matches the detected package manager in the sections below: `npx` for npm and yarn, `pnpm dlx` for pnpm, `bunx` for bun. ### GitHub Actions (Preferred for GitHub repos) Use `SocketDev/action@v1` with `mode: patch`: ```yaml - uses: SocketDev/action@v1 with: mode: patch # patch-ecosystems: npm,pypi (optional: limit to specific ecosystems) # patch-dry-run: false (optional: dry run mode) ``` Place after `actions/checkout`, before install steps. No `socket-token` is needed for patch mode. ### GitLab CI Add a step to install `socket-patch` and apply patches after dependency install. Use the appropriate package manager runner (see reference table above): ```yaml before_script: - curl -fsSL https://raw.githubusercontent.com/SocketDev/socket-patch/main/install.sh | sh - npm install - socket-patch scan - socket-patch apply ``` ### Bitbucket Pipelines Add a step to install `socket-patch` and apply patches. Use the appropriate package manager runner (see reference table above): ```yaml script: - curl -fsSL https://raw.githubusercontent.com/SocketDev/socket-patch/main/install.sh | sh - npm install - socket-patch scan - socket-patch apply ``` ### Other CI/CD Systems (Jenkins, CircleCI, Travis, Azure, etc.) Generic pattern for any CI system: 1. Install `socket-patch` via curl, npm, or the appropriate package manager runner (see reference table above) 2. Run your normal dependency install step 3. Run `socket-patch scan` to discover available patches 4. Run `socket-patch apply` after scan, before build ### Local Development (npm Projects) Run `socket-patch setup` to add a postinstall hook to `package.json`: ```shell socket-patch setup ``` This auto-adds a postinstall hook to your `package.json` scripts that runs `socket-patch scan && socket-patch apply` every time `npm install` runs. ### Dockerfile Patterns Add a `RUN socket-patch apply` layer after the install layer. Use the appropriate runner for the project's package manager (e.g. `pnpm dlx` for pnpm, `bunx` for bun): ```text FROM node:20-alpine WORKDIR /app COPY package*.json ./ RUN npm ci RUN pnpm dlx @socketsecurity/socket-patch scan RUN pnpm dlx @socketsecurity/socket-patch apply COPY . . RUN npm run build ``` ### Makefile Patterns Add a patch target that runs after install. Adapt commands to match the project's package manager: ```makefile install: npm ci socket-patch scan socket-patch apply build: install npm run build ``` ### Generic Fallback If the project uses an unusual build system, use the appropriate package manager runner (see reference table above): - **Interpreted projects** (Python, Ruby): add `socket-patch scan && socket-patch apply` after `pip install` / `bundle install` - **Compiled projects** (Rust, Go, Java): add `socket-patch scan && socket-patch apply` after dependency fetch, before compile - **Containers**: add `RUN socket-patch scan` and `RUN socket-patch apply` layers after the install layer ## Error Handling - **`socket-patch` not found**: Install it using one of the methods in Step 1. For CI, ensure the install step runs before `socket-patch apply`. - **"No .socket folder found, skipping patch application"**: Dependencies may not be installed, or `socket-patch scan` was not run first. Ensure dependencies are installed (e.g. `npm install`), then run `socket-patch scan` before `socket-patch apply`. - **No patches available**: Run `socket-patch scan` first to check. If scan finds nothing, Socket doesn't have binary patches for the current vulnerabilities. Consider using the `/socket-dep-upgrade` skill to upgrade versions instead. - **Build fails after patching**: Run `socket-patch scan` to identify which patches are available, then apply selectively. Report the failing patch so the user can decide whether to skip it. - **Permission errors**: Ensure write access to `node_modules/` or the equivalent dependency directory. ## Tips - `socket-patch apply` does not require an API key - it works on the free tier - Use `SocketDev/action@v1` (correct casing) in GitHub workflow files - For monorepos, use `patch-cwd` to target specific directories - Commit `.socket/manifest.json` to track which patches are applied - After patching, use the `/socket-scan` skill to verify no residual vulnerabilities remain - Combine with the `/socket-dep-upgrade` skill for vulnerabilities that don't have binary patches available ## Dónde encaja - Categoría: [Seguridad](https://skillsagentes.com/categorias/seguridad.md) — Auditorías, revisión de dependencias, manejo de secretos y modelado de amenazas. - Creador: [SocketDev](https://skillsagentes.com/creators/socketdev.md) — 15 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Socket Connect](https://skillsagentes.com/skills/socketdev/sauce/socket-connect.md): Conecta tu agente a Socket iniciando sesión por el navegador, sin copiar ni pegar una API key. Incluye el servidor Socket MCP alojado (OAuth), lista tus organizaciones y enlaza el Socket CLI para escaneos. - [Socket Fix](https://skillsagentes.com/skills/socketdev/sauce/socket-fix.md): Arregla problemas de seguridad en dependencias: escanea y corrige todo (requiere /socket-scan) o repara un paquete concreto, orquestando los subskills de limpieza, reemplazo, parcheo y actualización. - [Socket Dep Upgrade](https://skillsagentes.com/skills/socketdev/sauce/socket-dep-upgrade.md): Usa `socket fix` para encontrar y actualizar dependencias vulnerables, y luego corrige los cambios incompatibles en el código. Actualizaciones auditadas en seguridad con migración de código automatizada. - [Socket Inspect](https://skillsagentes.com/skills/socketdev/sauce/socket-inspect.md): Investiga un paquete antes de depender de él: extrae señales de Socket (scores, alertas, malware, CVEs, riesgo de cadena de suministro), revisa socket.dev, evalúa alternativas y muestra parches disponibles. - [Socket Scan](https://skillsagentes.com/skills/socketdev/sauce/socket-scan.md): Ejecuta un escaneo de dependencias con Socket CLI: pide login o cuenta si no estás autenticado, ofrece un SBOM local si lo rechazas, y añade reachability y auditoría de licencias para enterprise. ## Skills relacionadas - [Socket Connect](https://skillsagentes.com/skills/socketdev/sauce/socket-connect.md): Conecta tu agente a Socket iniciando sesión por el navegador, sin copiar ni pegar una API key. Incluye el servidor Socket MCP alojado (OAuth), lista tus organizaciones y enlaza el Socket CLI para escaneos. - [Socket Fix](https://skillsagentes.com/skills/socketdev/sauce/socket-fix.md): Arregla problemas de seguridad en dependencias: escanea y corrige todo (requiere /socket-scan) o repara un paquete concreto, orquestando los subskills de limpieza, reemplazo, parcheo y actualización. - [Socket Dep Upgrade](https://skillsagentes.com/skills/socketdev/sauce/socket-dep-upgrade.md): Usa `socket fix` para encontrar y actualizar dependencias vulnerables, y luego corrige los cambios incompatibles en el código. Actualizaciones auditadas en seguridad con migración de código automatizada. - [Socket Inspect](https://skillsagentes.com/skills/socketdev/sauce/socket-inspect.md): Investiga un paquete antes de depender de él: extrae señales de Socket (scores, alertas, malware, CVEs, riesgo de cadena de suministro), revisa socket.dev, evalúa alternativas y muestra parches disponibles. - [Socket Scan](https://skillsagentes.com/skills/socketdev/sauce/socket-scan.md): Ejecuta un escaneo de dependencias con Socket CLI: pide login o cuenta si no estás autenticado, ofrece un SBOM local si lo rechazas, y añade reachability y auditoría de licencias para enterprise. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)