Synced from monorepo
Synced from monorepo Changes: - Workspace task snapshots only list incomplete backgrounded tasks - Quiet auth, LSP, and config warnings in the shell - Fix observability attributes for warm store errors, restore setup, remote tools, and preview denials - Fail closed when soak metrics are missing - Run plan-mode exit last in mixed tool batches - Allow /loop to store prompts that can terminate the loop - Make subagent maximum nesting depth configurable - Security: apply sandbox profile to the leader process that executes tools Source-Revision: 1adcd1f477870e4a97bacbd6be78c8a3bfbac46d
This commit is contained in:
parent
b41c75a578
commit
02d9359435
96 changed files with 2346 additions and 351 deletions
|
|
@ -104,6 +104,19 @@ pub fn set_configured_profile(name: impl Into<String>) {
|
|||
pub fn configured_profile_name() -> Option<&'static str> {
|
||||
CONFIGURED_PROFILE.get().map(|s| s.as_str())
|
||||
}
|
||||
/// The non-`off` sandbox profile this process was **requested** with, if any.
|
||||
///
|
||||
/// This is the configured request, not a report that enforcement succeeded —
|
||||
/// `is_active()` can be false while the process is still confined (e.g. some
|
||||
/// Linux bwrap paths), and a requested-but-unapplied profile already warns the
|
||||
/// user. Keying on the request is the fail-closed choice.
|
||||
pub fn requested_confinement_profile() -> Option<&'static str> {
|
||||
configured_profile_name().filter(|name| profile_confines(name))
|
||||
}
|
||||
fn profile_confines(name: &str) -> bool {
|
||||
name.parse::<ProfileName>()
|
||||
.is_ok_and(|profile| profile != ProfileName::Off)
|
||||
}
|
||||
/// Whether the sandbox was successfully applied to this process.
|
||||
pub fn is_active() -> bool {
|
||||
SANDBOX.get().is_some_and(|s| s.applied)
|
||||
|
|
@ -772,6 +785,15 @@ mod tests {
|
|||
assert_eq!(configured_profile_name(), Some("read-only"));
|
||||
}
|
||||
#[test]
|
||||
fn profile_confines_only_for_non_off_profiles() {
|
||||
assert!(!super::profile_confines("off"));
|
||||
assert!(!super::profile_confines("none"));
|
||||
assert!(super::profile_confines("strict"));
|
||||
assert!(super::profile_confines("read-only"));
|
||||
assert!(super::profile_confines("readonly"));
|
||||
assert!(super::profile_confines("my-custom-profile"));
|
||||
}
|
||||
#[test]
|
||||
fn known_launch_guard_is_linux_only() {
|
||||
assert_eq!(
|
||||
restrict_network_at_known_linux_launches(true, true),
|
||||
|
|
|
|||
Loading…
Reference in a new issue