diff --git a/sentinel-capabilities/src/filesystem.rs b/sentinel-capabilities/src/filesystem.rs index c4b9e7d..aae7da2 100644 --- a/sentinel-capabilities/src/filesystem.rs +++ b/sentinel-capabilities/src/filesystem.rs @@ -262,7 +262,7 @@ impl Capability for LogVacuum { // Landlock allowlist must all see the same collapsed path, or a // caller-supplied `app//`/`app/./` variant splits the boundary (gate r1) let Some(log_dir_norm) = normalise_components(log_dir) else { - return CapabilityResult::failure("'log_dir' must not contain '..'".into(), false); + return CapabilityResult::failure("'log_dir' must not contain '..'", false); }; let log_dir: &str = &log_dir_norm; let days = args["older_than_days"].as_f64().unwrap() as i64; @@ -562,7 +562,9 @@ mod tests { let prefix = format!("{}/", norm); assert!("/var/log/app/a.log".starts_with(&prefix)); assert!(!"/var/log/application/x.log".starts_with(&prefix)); - assert!(!normalise_components("/var/log/app/../../etc/x.log").unwrap_or_default().starts_with(&prefix)); + assert!(!normalise_components("/var/log/app/../../etc/x.log") + .unwrap_or_default() + .starts_with(&prefix)); } #[test] diff --git a/sentinel-exec/src/sandbox.rs b/sentinel-exec/src/sandbox.rs index d75fe1f..53e7b66 100644 --- a/sentinel-exec/src/sandbox.rs +++ b/sentinel-exec/src/sandbox.rs @@ -816,10 +816,8 @@ mod tests { // BPF class mask 0x07: 0x05 = BPF_JMP (conditional, carries jt/jf) if f.code & 0x07 == 0x05 { jumps += 1; - for (name, target) in [ - ("jt", i + 1 + f.jt as usize), - ("jf", i + 1 + f.jf as usize), - ] { + for (name, target) in [("jt", i + 1 + f.jt as usize), ("jf", i + 1 + f.jf as usize)] + { assert!( target < len, "instruction {i} {name} target {target} out of bounds (len {len})" @@ -829,14 +827,25 @@ mod tests { } // the filter is jumps + loads + returns; with no jumps this test // verified nothing - assert!(jumps >= 5, "expected the documented jump chain, walked {jumps}"); + assert!( + jumps >= 5, + "expected the documented jump chain, walked {jumps}" + ); // as-built targets (indices match the /* n */ comments in the filter): // 4 x32-bit → 13 ENOSYS · 5 io_uring_setup → 13 · 6 socket else → 11 // ALLOW · 8/9/10 AF_INET/6/PACKET → 12 EACCES let t = |i: usize, jt: u8| i + 1 + jt as usize; assert_eq!(t(4, insns[4].jt), 13, "x32-bit jump must reach ENOSYS"); - assert_eq!(t(5, insns[5].jt), 13, "io_uring_setup jump must reach ENOSYS"); - assert_eq!(t(6, insns[6].jf), 11, "non-socket fall-through must reach ALLOW"); + assert_eq!( + t(5, insns[5].jt), + 13, + "io_uring_setup jump must reach ENOSYS" + ); + assert_eq!( + t(6, insns[6].jf), + 11, + "non-socket fall-through must reach ALLOW" + ); assert_eq!(t(8, insns[8].jt), 12, "AF_INET must reach EACCES"); assert_eq!(t(9, insns[9].jt), 12, "AF_INET6 must reach EACCES"); assert_eq!(t(10, insns[10].jt), 12, "AF_PACKET must reach EACCES");