Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/socket-patch-cli/CLI_CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ Human (non-`--json`) output is not a stable interface, but these rules hold:
* Warning lines carry no machine code: `Warning: <detail>` (and `GC: skipped: <message>.`); error lines keep theirs (`Error (<code>): …`) so a `--silent` run stays grep-able. The stable codes stay in the JSON envelope (`warnings[].code`, `error.code`, `errorCode`).
* Hosted mode is called "hosted" in human text (`Switched N packages to hosted patches; rewrote M files.`); JSON keys and codes keep their `redirect*` names. `N` counts the packages this run switched: one whose hosted patch was in place before the run is not counted again, and a run that finds some gets a second sentence (`Switched 1 package to hosted patches; rewrote 1 file. 2 packages were already on hosted patches.`); a run that rewrites nothing says `N packages are already on hosted patches; nothing to rewrite.` `--json` is unchanged: every confirmed pin, new or already in place, is an `applied` event (`verified` on a dry run), and `rollout.counts.already` / `redirect.rewrittenFiles` tell a re-run from a first run.
* npm's `allow-remote` notice prints as one line (`Note: set \`allow-remote=all\` in .npmrc …` or `Warning: npm >=12 refuses the hosted patches until …`); the full `redirect_npm_allow_remote` detail is in `--json` and under `--verbose`.
* Hosted and vendored runs that change the project end with one shared `Next steps:` block (commit, reinstall + `socket-patch vex`, then any extra step: `2. Reinstall from the updated lockfile (e.g. \`npm ci\`), then run \`socket-patch vex\` to verify the installed patches.`). A hosted run that rewrote Bundler's files alone words the second step by what it did about the gems Bundler already held (see "Gem stale-install guard"): once it replaced them it is `Run \`socket-patch vex\` to verify the installed patches (the installed gems already hold the patched builds, so there is nothing to reinstall).`, and while a shared gem home still holds unpatched copies it points at the command in that run's warning instead of a reinstall, since a plain `bundle install` keeps the gems it already has.
* Hosted and vendored runs that change the project end with one shared `Next steps:` block (commit, reinstall + `socket-patch vex`, then any extra step: `2. Reinstall from the updated lockfile (e.g. \`npm ci\`), then run \`socket-patch vex\` to verify the installed patches.`). A hosted run that rewrote Bundler's files alone words the second step by what it did about the gems Bundler already held (see "Gem stale-install guard"): once it replaced them it is `Run \`socket-patch vex\` to verify the installed patches (the installed gems already hold the patched builds, so there is nothing to reinstall).`, and while a shared gem home still holds unpatched copies it points at the command in that run's warning instead of a reinstall, since a plain `bundle install` keeps the gems it already has. A vendored run that vendored a gem for Bundler adds a step when a `Dockerfile` or `Containerfile` in the project root runs `bundle install` in a stage that has copied the `Gemfile` or its lock but neither the project (`COPY . .`) nor `.socket` (or its `vendor` or `vendor/gem` directory): ``3. Dockerfile runs `bundle install` with only the Gemfile and its lock in the image, and the vendored gems are `path:` gems under .socket/vendor/: add `COPY .socket/vendor ./.socket/vendor` before that step, or the image build fails there with "The path … does not exist".`` The `COPY` it names puts the directory beside the copied Gemfile (`COPY .socket/vendor /app/.socket/vendor` after `COPY Gemfile Gemfile.lock /app/`). The step is advice in the human output only: no event, no warning code, no change to the exit code. See docs/ecosystems.md "Ruby gems: vendored gems in a Docker build".
* An agent-mode run that recorded a patch (`scan --mode agent`, agent-mode `get`) ends with its own `Next steps:` block, on stdout: `1. Commit .socket/ to keep the patches.` and `2. Run \`socket-patch apply\` after every \`bundle install\`, locally and in CI. A fresh install removes the patches.` The second step names the install command of each ecosystem the run patched, read from the project's lockfile where several package managers share one (`pnpm install`, `yarn install`, `bun install`, `vlt install`, else `npm install`; `uv sync`, `poetry install`, `pipenv install`, `pdm install`, else `pip install`; `bundle install`; `composer install`; `cargo fetch`; `dotnet restore`), and says `every dependency install` where there is no single command (Maven, Gradle, sbt). After `get --save-only` it reads `Run \`socket-patch apply\` now, and after every …`. A Go patch is a committed copy plus a `replace`, so the first step also names `go.mod (or go.work)` and a run that patched only Go modules has no second step. The block is not printed by a run that recorded nothing new, a dry run, a failed run, a global (`-g` / `--global-prefix`) run, `--silent` or `--json`. With a `--max-new-patches` cap, the lines about deferred patches follow in the same block.
* `scan` lists each package it patched once, under the mode's result line (`Switched …`, `Vendored …`, the agent apply's `Applied N patches.`, the `--dry-run` line): ` <SEVERITY> <name>@<version> <ids> <measurements> <N unpatched>`, worst severity first, then by purl. The name is the package's `name@version` when every row of the project is one ecosystem and its purl otherwise. `<ids>` are the first two advisories the patch fixes (a CVE, or the advisory's own id when it has none) and `(+N)` for the rest; `<N unpatched>` counts the advisories only the package's other patches fix (paid ones included), since one patch is applied per package version. `--verbose` names every id and lists the unpatched ones under the row by reason, leaving out a line with no ids: `waiting on a merged patch: <ids>` (another patch the account can download fixes them, and the merged patch is not published yet; see [Free and paid patches, and merged patches that are not ready](#free-and-paid-patches-and-merged-patches-that-are-not-ready)), `needs a paid Socket plan: <ids>` (only the paid tier fixes them), and `still unpatched: <ids>` for the rest. On a terminal narrower than a row, the row names fewer ids and then drops the measurements rather than wrap. Only a patch the run applied (or found applied, or on a dry run would apply) gets a row. `--json` carries the same facts on `packages[]` (see [`scan` and `get` JSON](#scan-and-get-json-v50-major)). The other per-package listings a scan used to print (the results table, the `Patches to apply:` blocks, `[add]` / `[fetch]` lines, `Patched packages:`) are gone from the default output; `--verbose` keeps the per-patch blocks. `get` keeps its numbered listing and, like `scan`, no longer names the patches again while it downloads and applies them: its nested apply says `Applied N patches.` (the other buckets only when a patch landed in one: `Applied 4 of 6 patches: 1 already patched, 1 failed.`), and `get --save-only` says `Saved N patches to <manifest>.` (`(1 updated, 1 skipped)` when so); a recorded patch a `get` replaces still gets its `[update] <purl> (replacing <uuid>)` line. `apply` itself prints as before.
* `scan` closes with the totals of the whole invocation, once, under a blank line: `Patched 22 packages in 3 projects, fixing 39 vulnerabilities (5 critical, 15 high).` (`Would patch …` on a dry run; `in N projects` only past one), then, under the `Verified:` line when there is one, `Saved about 44 hours of engineering time (22 package upgrades at ~2 hours each).` (`Would save …` on a dry run), then `18 vulnerabilities left to patch (32%): 6 await a merged patch, 8 need a package upgrade, 3 need a paid Socket plan, 1 is in packages this run did not patch.` or `Nothing left to patch.` (`No free patches left to apply.` when a lookup of the run went through the public proxy, which answers for free patches only). The reasons, for an advisory left on a patched package: it awaits a merged patch (another patch the account can download fixes it, and no downloadable patch fixes everything those patches fix between them); it needs a paid Socket plan (only a paid patch fixes it, or, for an account without paid access, only a free patch that is not critical; so does every advisory of a package whose every patch is paid); else it needs a package upgrade (a downloadable patch fixes it and the run selected another one, as a selection filter can make it). When any advisory is waiting on a merged patch the next two lines say so: `1 merged patch is not ready yet: Socket is still processing it.` and `Run \`socket-patch scan\` again later to apply it.` (`4 merged patches are not ready yet: Socket is still processing them.` / `… to apply them.`), counting the patched packages that have one, per project directory like the other totals. They are two short lines so that neither wraps an 80-column terminal; where color is on, the count is bold yellow like the count of what is left, and the second line is dim. The counts are occurrences: a package patched in three project directories counts three times, and so does each advisory its patch fixes there; an advisory is one id as the rows show it. "Left to patch" counts the advisories of every package a patch was offered for that this run did not fix, as a share of those it could have. A package a hosted or vendored run finds installed on the machine but absent from a lockfile that lists the whole dependency graph (npm, Cargo, Go, Bundler, Composer) is not the project's and is not counted; a PyPI package always counts, since a requirements file may pin only direct dependencies. A run given a selection filter with reachability findings adds `Reachable: 9 fixed, 2 left to patch (18%).`, the same two counts for the advisories a finding marks `reachable`. The hours are an estimate, and the line says so: each patched package, in every project directory it is patched in, stands for one upgrade that did not have to be made, taken at two hours (finding a release with the fix, moving to it, getting the build and tests through everything else that release changed, and the review). The figure is an assumption, not a measurement of the project. A run that leaves advisories to a paid plan ends with the upsell line below (once per invocation: a project directory whose every patch is paid prints it under its `No downloadable patches` line instead). Nothing is printed when no patch was offered at all.
Expand Down
Loading
Loading