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 @@ -3079,7 +3079,7 @@ The VEX document is JSON-LD, which collides with the standard `--json` envelope

`--output -` means stdout (the first row). With `--dry-run`, a document bound for `--output` is built and verified but not written, a previous document at that path is left alone, the one-line summary reads `[dry-run] Would write OpenVEX document with N statements to <path>`, and the envelope's `dryRun` is `true`. In every one-line summary the count reads `N statements (K affected)` when K of the statements say `affected`. A written file ends with a newline, like the stdout form.

When verification is enabled (the default) and a patch is omitted, the failed PURLs are surfaced on stderr in plain mode or as `skipped` events on the envelope in JSON mode (one per patch, sorted by PURL; `errorCode` is the tag). Plain mode prints one line per reason, largest first: `Warning: omitting 82 packages from VEX: the patched files still hold the original content (not_applied): @sigstore/core@1.1.0, @sigstore/core@2.0.0, @simple-git/argv-parser@1.1.1 and 79 more (--verbose lists them all)`; a reason with a single patch keeps the per-patch line `Warning: omitting <purl> from VEX: <reason> (<tag>)`, and `--verbose` prints that line for every patch. The run's advisories print before them, folded the same way: the first of each kind in full, then ` ... and 9 more like these: glob@10.4.5, glob@11.0.3, minimatch@3.1.2 and 6 more (--verbose lists them all)` (the packages are named where each advisory opens with one). When nothing could be attested, the `Error: No applied patches with vulnerability metadata to attest.` line is followed by the remedy for the patches that only need installing (`The patched packages are not installed yet: ... Reinstall from the lockfile (hosted or vendored patches) or run \`socket-patch apply\` (agent-mode patches), then run \`socket-patch vex\` again.`, or `N of the patched packages ...` when other reasons are among them). `--json` is unchanged: every advisory is its own `warnings[]` entry and every omission its own `skipped` event. Status becomes `partialFailure` when at least one patch was omitted but at least one was emitted. It is `partialFailure` too, with exit `0`, when a statement of the document says `affected`, also when every one does: `summary.verified` counts the packages attested as patched and no other.
When verification is enabled (the default) and a patch is omitted, the failed PURLs are surfaced on stderr in plain mode or as `skipped` events on the envelope in JSON mode (one per patch, sorted by PURL; `errorCode` is the tag). Plain mode prints one line per reason, largest first: `Warning: omitting 82 packages from VEX: the patched files still hold the original content (not_applied): @sigstore/core@1.1.0, @sigstore/core@2.0.0, @simple-git/argv-parser@1.1.1 and 79 more (--verbose lists them all)`; a reason with a single patch keeps the per-patch line `Warning: omitting <purl> from VEX: <reason> (<tag>)`, and `--verbose` prints that line for every patch. The run's advisories print before them, folded the same way: the first of each kind in full, then ` ... and 9 more like these: glob@10.4.5, glob@11.0.3, minimatch@3.1.2 and 6 more (--verbose lists them all)` (the packages are named where each advisory opens with one). When nothing could be attested, the `Error: No applied patches with vulnerability metadata to attest.` line is followed by the remedy for the patches that only need installing (`The patched packages are not installed yet: ... Reinstall from the lockfile (hosted or vendored patches) or run \`socket-patch apply\` (agent-mode patches), then run \`socket-patch vex\` again.`, or `N of the patched packages ...` when other reasons are among them). A hosted gem among them is not told to reinstall, since Bundler keeps a gem it has already installed and `bundle pristine` on Bundler 2.6+ removes the gems and then fails on the lock's checksum; its remedy is the scan that replaces the installed copy: `The patched packages are hosted gems whose installed copies are still the upstream builds. ... Run \`socket-patch scan\` to replace the installed copies (for a gem home outside the project, run \`bundle config set --local path vendor/bundle && bundle install\` instead, or add \`--gem-refresh-shared\` to the scan), then run \`socket-patch vex\` again.` (see "Gem stale-install guard"). Where a scan with no `--mode` is not a hosted one (the project also holds agent-mode or vendored patches), that sentence names the files to remove instead: `Remove each gem's \`specifications/<name>-<version>.gemspec\` and \`cache/<name>-<version>.gem\` from its gem home (and its archive in \`vendor/cache\`, if the project keeps one) and run \`bundle install\`. Other projects may load a gem home outside the project, so for one run \`bundle config set --local path vendor/bundle && bundle install\` instead, then run \`socket-patch vex\` again.` A gem the manifest records under the same patch as the hosted pin keeps the general remedy, since `apply` patches it in place; a record of another patch, which the pin superseded, does not. `--json` is unchanged: every advisory is its own `warnings[]` entry and every omission its own `skipped` event. Status becomes `partialFailure` when at least one patch was omitted but at least one was emitted. It is `partialFailure` too, with exit `0`, when a statement of the document says `affected`, also when every one does: `summary.verified` counts the packages attested as patched and no other.

## Semver policy

Expand Down
3 changes: 2 additions & 1 deletion crates/socket-patch-cli/src/commands/gem_refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ fn home_spec(gem_dir: &Path) -> Option<PathBuf> {

/// The local-path remedy: Bundler then installs every gem of the project
/// into the project, from the source the lock names.
const LOCAL_PATH_REMEDY: &str = "bundle config set --local path vendor/bundle && bundle install";
pub(crate) const LOCAL_PATH_REMEDY: &str =
"bundle config set --local path vendor/bundle && bundle install";

/// The files whose removal makes `bundle install` fetch the gem again: the
/// installed copy's `specifications` entry and cached archive (Bundler
Expand Down
10 changes: 10 additions & 0 deletions crates/socket-patch-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ pub(crate) async fn bare_scan_looks_below(common: &crate::args::GlobalArgs) -> b
)
}

/// Whether a bare `scan` at `--cwd` runs in hosted mode: the project's own
/// state records no other mode ([`mode_from_project_state`]). Only a
/// hosted scan replaces the stale installed copy of a hosted gem.
pub(crate) async fn bare_scan_is_hosted(common: &crate::args::GlobalArgs) -> bool {
matches!(
mode_from_project_state(common).await,
Ok(scan::ScanMode::Hosted)
)
}

/// The mode a `scan`/`get` run with no `--mode` uses for the project
/// (CLI_CONTRACT.md, Mode resolution): the mode the project's own patch
/// state already records, so a bare run never converts the project to
Expand Down
Loading
Loading