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
4 changes: 3 additions & 1 deletion sentinel-capabilities/src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
23 changes: 16 additions & 7 deletions sentinel-exec/src/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
Expand All @@ -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");
Expand Down
Loading