1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Packaging proof: the released `newt` binary carries the child-side network
//! guard (`newt __net-guard`), so the confined executor's `NetGrant::DenyAll`
//! egress floor works from an installed artifact — not only from `cargo run`
//! with a sibling `newt-net-guard` helper.
//!
//! This is the regression test for the deployment gap that made the seccomp
//! egress floor fail closed in every installed layout: `release.yml` /
//! `cargo install` / the nfpm packages ship only `newt` (+ `newt-mcp-server`),
//! never the `newt-net-guard` helper the old sibling-file lookup required. The
//! self-exec path (`resolve_net_guard` → `current_exe __net-guard`) removes the
//! second binary, and this test spawns the ACTUAL `newt` binary to prove the
//! subcommand is wired in and enforces the floor.
//!
//! Real-resource (installs a seccomp filter in the spawned `newt` process),
//! Linux + `#[serial]`. It grounds the mocked `resolve_net_guard` unit logic in
//! `newt-core::confined_exec` against a real released-shape invocation.
/// `newt __net-guard --probe-egress` installs `no_new_privs` + the seccomp
/// socket()-family deny on the spawned `newt` process, then self-tests that
/// off-box sockets (AF_INET/AF_INET6/AF_PACKET) are kernel-denied while AF_UNIX
/// survives — exit 0 iff the whole floor holds. That the subcommand exists AND
/// installs the floor is the packaging guarantee: the guard rides in `newt`.
/// The guard refuses a malformed invocation (no `--` / program) rather than
/// silently exec-ing something — fail-closed argument handling. Exit 2 is the
/// usage error; crucially it is NOT 0 (which would mean it ran a program).