feat(worker): V1-2.3 sandboxed verify child and sheet-verify job mode

This commit is contained in:
bchanot committed 2026-11-01 17:20:07 +01:00
1 parent 345dde59e6
commit 31fbb0317f
24 files changed
+2145 -87

No files matched your search

+22
View File
@@ -79,6 +79,17 @@ pub fn validate_any_key(key: &str) -> Result<(), KeyError> {
}
}
/// Object key of a sheet drawing (bucket `anatomical-sheet-assets`): `<sha256 hex>.svg`,
/// lowercase (V1-2.3, M6 `get_sheet_verification_input`).
pub fn is_drawing_key(key: &str) -> bool {
key.strip_suffix(".svg").is_some_and(|hash| {
hash.len() == 64
&& hash
.bytes()
.all(|b| b.is_ascii_digit() || (b'a'..=b'f').contains(&b))
})
}
/// True when a (valid) key's owner and asset segments are exactly these ids.
pub fn belongs_to(key: &str, owner_id: &str, asset_id: &str) -> bool {
let mut segments = key.split('/');
@@ -153,4 +164,15 @@ mod tests {
assert!(!belongs_to(&key, U1, U1));
assert!(!is_uuid("10000000-0000-0000-0000-00000000000"));
}
#[test]
fn drawing_keys_are_a_lowercase_sha256_and_svg() {
let hash = "0123456789abcdef".repeat(4);
assert!(is_drawing_key(&format!("{hash}.svg")));
assert!(!is_drawing_key(&format!("{}.svg", hash.to_uppercase())));
assert!(!is_drawing_key(&format!("{hash}.png")));
assert!(!is_drawing_key(&format!("{}.svg", &hash[1..])));
assert!(!is_drawing_key(&format!("../{}.svg", &hash[3..])));
assert!(!is_drawing_key(&format!("x/{hash}.svg")));
}
}