fix(anatomy): V1-2.2 review findings, PIs and HTML refused, bounds

Security audit (PASS, 2 MEDIUM, 2 LOW) and verifier (ECARTS 6) on
741c25c: processing instructions and HTML fetchers refused, active
content under a long title classified, linear review groups, full
fixpoint check, bounded preview drawings, missing cap fixtures and
property checks, record wordings.
This commit is contained in:
bchanot committed 2026-10-29 13:38:33 +01:00
1 parent 741c25c464
commit 8294d5471c
15 files changed
+448 -72

No files matched your search

+57 -2
View File
@@ -590,7 +590,42 @@ fn random_command(doc: &AnatomicalSheetDocument, rng: &mut Rng, counter: &mut us
.iter()
.filter(|k| matches!(k, ElementKey::Finding { path, .. } if path.len() < 8))
.collect();
match rng.below(9) {
match rng.below(12) {
9 => {
let view = rng.pick(&doc.views).cloned();
match view {
Some(view) => {
let mut value = serde_json::to_value(&view).unwrap();
if value["view_box"].is_object() {
value["view_box"]["width"] = json!(1 + rng.below(5));
} else {
value["svg_asset_id"] =
json!(format!("11111111-2222-4333-8444-{:012}", rng.below(3)));
}
json!({ "op": "update", "key": { "kind": "view", "id": view.id() }, "element": { "kind": "view", "value": value } })
}
None => json!({ "op": "remove", "key": { "kind": "sheet" } }),
}
}
10 => match rng.below(3) {
0 => {
json!({ "op": "insert", "element": { "kind": "reference", "value": { "id": id, "type": "web", "citation": id } } })
}
1 => {
json!({ "op": "remove", "key": { "kind": "reference", "id": rng.pick(&doc.references).map(|r| r.id.clone()).unwrap_or_default() } })
}
_ => {
json!({ "op": "move", "key": { "kind": "zone", "id": rng.pick(&doc.finding_zones).map(|z| z.id.clone()).unwrap_or_default() }, "position": rng.below(3) })
}
},
11 => {
let zone = rng
.pick(&doc.finding_zones)
.map(|z| z.id.clone())
.unwrap_or_default();
json!({ "op": "update", "key": { "kind": "zone", "id": zone },
"element": { "kind": "zone", "value": { "id": zone, "name": name("Zone renommée"), "categories": [] } } })
}
0 => {
json!({ "op": "insert", "position": rng.below(2), "element": { "kind": "annotation", "value": {
"id": id, "kind": "point", "view_id": view, "category_id": "c", "laterality": "left",
@@ -738,7 +773,7 @@ fn check_command(
"{raw}"
);
}
"update" => {
"update" if before.contains_key(&key()) => {
let key = key();
let expected = if changes == Some(&json!(true)) {
ReviewStatus::ToConfirm
@@ -775,8 +810,28 @@ fn check_command(
"{raw}"
);
}
"mark_reviewed" => {
let ElementKey::Zone { id } = key() else {
unreachable!()
};
for (k, status) in after {
let inside = matches!(k, ElementKey::Finding { zone_id, .. } if *zone_id == id);
let expected = if inside {
ReviewStatus::Reviewed
} else {
before[k]
};
assert_eq!(*status, expected, "{raw}");
}
}
_ => {}
}
if op != "remove" {
assert!(
before.keys().all(|k| after.contains_key(k)),
"keys kept: {raw}"
);
}
}
fn is_below(key: &ElementKey, ancestor: &ElementKey) -> bool {