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
20 changes: 20 additions & 0 deletions crates/socket-patch-core/src/patch/redirect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,26 @@ fn rewrite_yarn_berry(
if !version_re.is_match(block) {
continue;
}
// Descriptor ranges carry a protocol; only an `npm:` range names
// a registry tarball this rewriter can own. A `patch:` range
// (yarn's OWN builtin compat patches — the 2026-07 strapi
// incident family), `workspace:`, `portal:`, or `link:` block
// must survive byte-identically: splicing an npm resolution
// under such a key corrupts the key/resolution protocol pairing.
// Mirrors the vendor backend's fail-closed gate
// (vendor/yarn_berry_lock.rs).
if !parsed.iter().all(|p| p.unwrap().1.starts_with("npm:")) {
result.warnings.push(RewriteWarning {
code: "redirect_yarn_berry_unsupported_protocol".into(),
detail: format!(
"lock entry `{raw_key}` resolves {fname}@{} through a protocol \
the hosted redirect cannot own (workspace:/patch:/portal:/link:); \
leaving it byte-identical",
dep.version
),
});
continue;
}
// Rewrite the resolution wholesale from name+version — handles a
// pre-existing `::__archiveUrl=` (custom-registry lock) for free.
let resolution = format!(
Expand Down
4 changes: 3 additions & 1 deletion crates/socket-patch-core/src/patch/vendor/lock_inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ impl LockfileEntry {
/// Inventory the project's npm-family lockfile. Routes by
/// [`detect_npm_lock_flavor`] (PnP markers, bun.lockb, unsupported lock
/// versions, and a missing lockfile all yield `None`).
async fn inventory_npm_lock(project_root: &Path) -> Option<(NpmLockFlavor, Vec<LockfileEntry>)> {
pub(crate) async fn inventory_npm_lock(
project_root: &Path,
) -> Option<(NpmLockFlavor, Vec<LockfileEntry>)> {
// Rush monorepos have no root package.json/lock pair; their single
// pnpm source-of-truth lives under common/config/rush/. The flavor
// probe (root-relative) can't see it, so fall back explicitly when the
Expand Down
2 changes: 2 additions & 0 deletions crates/socket-patch-core/src/patch/vendor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ mod toml_surgery;
pub(crate) mod verify;
pub(crate) mod yarn_berry_lock;
mod yarn_classic_lock;
#[cfg(test)]
mod yarn_layering_tests;

pub use path::{ecosystem_dir_for_purl, parse_vendor_path};
pub use state::{load_state, lookup_entry, save_state, VendorEntry, VendorState, VENDOR_STATE_REL};
Expand Down
Loading
Loading