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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! The `HARN_HANDLER_SANDBOX` read seam.
//!
//! Production reads the selector straight from the process environment; under
//! `cfg(test)` that environment is structurally invisible and the value comes
//! from a thread-local override instead, so ambient shell or CI configuration
//! can never flip a test's sandbox outcome. See [`handler_sandbox_env`].
use SandboxFallback;
use HANDLER_SANDBOX_ENV;
use crateSandboxProfile;
/// Resolve the fallback policy for the requested profile. `OsHardened`
/// always enforces — that is the entire point of the profile, so the
/// `HARN_HANDLER_SANDBOX` env var cannot weaken it. `Worktree` honors
/// the env var (default `warn`).
pub
/// Reads the `HARN_HANDLER_SANDBOX` fallback selector for
/// [`effective_fallback`] through the shared env seam.
///
/// Under `cfg(test)` the process environment is structurally invisible: the
/// value comes from a per-thread override instead, so an ambient
/// `HARN_HANDLER_SANDBOX` exported in a developer's shell or a CI wrapper can
/// never flip a test's sandbox outcome. The exec-path tests in
/// `vm::tests_runtime` that need a specific selector inject it through
/// [`HandlerSandboxTestGuard::set`]; every other test observes the built-in
/// `warn` default deterministically. The override is thread-keyed, matching
/// the same-thread `new_current_thread` runtime those tests drive, so no
/// cross-test lock is needed. In production this is a plain env read.
/// Gives a test a hermetic `HARN_HANDLER_SANDBOX` universe by wrapping the
/// shared env seam ([`crate::test_env::test_env_guard`]): creation and drop
/// both clear this thread's overrides, so neither ambient configuration nor a
/// sibling test's leftover selector can leak in or out. Inject a selector for
/// the duration of the test with [`HandlerSandboxTestGuard::set`].
pub
/// Guard returned by [`handler_sandbox_test_guard`]. Injects a
/// `HARN_HANDLER_SANDBOX` selector for this thread via
/// [`HandlerSandboxTestGuard::set`]; the inner shared guard clears it on drop.
/// This domain wrapper exists only to keep the single-variable `set(value)`
/// ergonomics — there is no extra drop behavior to layer on.
pub