fix(anatomy): R5.4 guard covers links, autolinks, references, CJK underscores; ids validated at the op; prescan before the drawing comparison
This commit is contained in:
1 parent
68dec25e5e
commit
df82424107
9 files changed
+195
-12
No files matched your search
@@ -421,3 +421,55 @@ fn a_label_the_drawing_cannot_carry_is_refused() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// An id an op writes is checked at the op (security gate R5.4 round 2): a line break or a
|
||||
/// backtick in an added, nested or renamed id, or in a field segment, would otherwise reach the
|
||||
/// reports' code spans through the records (forged sections) even when a later op removes the
|
||||
/// item. The committed drawing is read by the core's reader first (its depth cap holds).
|
||||
#[test]
|
||||
fn ids_and_field_segments_that_could_forge_report_structure_are_refused() {
|
||||
let frozen = oracle("review-synthetic.json");
|
||||
let references = parse_references(
|
||||
&to_js_compact(&serde_json::json!({ "references": frozen["references"] })).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let forged = "x`\n## 11. Section forgée\n`y";
|
||||
let annotation = serde_json::json!({
|
||||
"id": forged, "kind": "point", "view_id": "main", "category_id": "bones",
|
||||
"laterality": "unpaired", "geometry": null, "name": { "fr": "a", "en": "a" },
|
||||
"finding_zone_id": "neck", "vertebral_region_code": null,
|
||||
});
|
||||
let node = serde_json::json!({ "id": "n1", "name": { "fr": "a", "en": "a" },
|
||||
"children": [{ "id": forged, "name": { "fr": "a", "en": "a" } }] });
|
||||
let cases = [
|
||||
serde_json::json!([
|
||||
{ "op": "add", "target": "document", "field": "annotations", "value": annotation },
|
||||
{ "op": "remove", "target": format!("annotation:{forged}") },
|
||||
]),
|
||||
serde_json::json!([{ "op": "rename", "target": "annotation:hip", "id": forged }]),
|
||||
serde_json::json!([{ "op": "add", "target": "finding:hip/hip-dysfunctions/mobility", "value": node }]),
|
||||
serde_json::json!([{ "op": "set", "target": "finding:hip/hip-dysfunctions/mobility",
|
||||
"field": "name.x\ny", "value": "a" }]),
|
||||
serde_json::json!([{ "op": "set", "target": "finding:hip/hip-dysfunctions/mobility",
|
||||
"field": "name.x`y", "value": "a" }]),
|
||||
];
|
||||
for ops in cases {
|
||||
let file = serde_json::json!({ "changes": [{
|
||||
"id": "CHG-001", "level": "A", "kind": "technical",
|
||||
"title": { "fr": "Essai", "en": "Test" }, "rationale": "Essai", "reference_ids": [],
|
||||
"ops": ops,
|
||||
}]});
|
||||
let changeset = parse_changeset(&to_js_compact(&file).unwrap()).unwrap();
|
||||
let error =
|
||||
apply_changeset(&frozen["baseline"], &references, &changeset.changes).unwrap_err();
|
||||
assert!(error.to_string().starts_with("CHG-001 op 0:"), "{error}");
|
||||
}
|
||||
let deep = format!(
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\">{}{}</svg>",
|
||||
"<g>".repeat(100_000),
|
||||
"</g>".repeat(100_000)
|
||||
);
|
||||
let (_, draft) = equine();
|
||||
let rule = TriggerNames::of(&typed(&draft.document));
|
||||
assert!(compare_drawing("<svg/>", &deep, Some(&rule)).is_err());
|
||||
}
|
||||
Reference in new issue
Block a user