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
1 change: 1 addition & 0 deletions changelog.d/6914-install-sfw-firewall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**`perry install` rides Socket Firewall:** the secure install wrapper (#738) now runs the wrapped `bun`/`npm` install *through* an `sfw` binary when one is available, adding network-time malware scanning to the existing offline scan + lifecycle-script allowlist: wire → tree → execution. Resolution is `PERRY_SFW` (an explicit path) → `sfw` found by an explicit `PATH` walk that drops empty and relative entries (both resolve against the not-yet-scanned project directory; Windows `PATHEXT` is honored). The `$HOME` dev-tools rack is deliberately **not** probed — nothing in a shipped perry binary can verify that file, so preferring it would let anything that writes under `$HOME` pick the binary perry executes; the not-found message names the rack path so contributors know what to point `PERRY_SFW` at. Fail-open when sfw is absent, but never silent-open: the stderr notice prints on every run including `--json`, and the install report records the outcome under `firewall.state` (`active`/`opted-out`/`unavailable`, defaulting to `unavailable` so a forgetful path under-claims protection). `--no-firewall` opts out. The child env sets the `SFW_SHIM_ACTIVE_*` sentinels (built by iterating `Installer::ALL`, so a new installer can't ship without one) so a shimmed package manager execs the real binary instead of nesting a second proxy, and `SFW_UNKNOWN_HOST_ACTION=ignore` keeps enterprise sfw from blocking non-registry hosts. Companion to the supply-chain soak PR (#6912); notably closes the gap where the bun path bypassed the sfw shims entirely (bun is not a shimmed ecosystem).
17 changes: 17 additions & 0 deletions crates/perry/src/commands/install/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,30 @@ pub enum Installer {
}

impl Installer {
/// Every variant perry can pick. Anything that must stay in step with the
/// set of installers — notably the Socket Firewall shim sentinels in
/// `firewall::firewall_env` — iterates this instead of restating the list,
/// so adding a variant here is enough (and the compiler flags the
/// `match`es that also need updating).
pub const ALL: [Installer; 2] = [Installer::Bun, Installer::Npm];

pub fn binary(&self) -> &'static str {
match self {
Installer::Bun => "bun",
Installer::Npm => "npm",
}
}

/// The `SFW_SHIM_ACTIVE_*` variable that tells an sfw shim for this
/// package manager to exec the real binary instead of starting a second,
/// nested proxy inside the one perry already started.
pub fn shim_sentinel_env(&self) -> &'static str {
match self {
Installer::Bun => "SFW_SHIM_ACTIVE_BUN",
Installer::Npm => "SFW_SHIM_ACTIVE_NPM",
}
}

pub fn print_banner(&self, use_color: bool) {
let label = match self {
Installer::Bun => "bun",
Expand Down
Loading
Loading