fix(domain): V1-2.2 second review round, linear walks, bounds, CSS loaders
Verifier ECARTS(3) and security PASS on 8294d54: one indexed walk per
view chain in sheet.edit, a set for referenced drawings, released
preview parses, xml:base and CSS loaders refused, fail-closed PI scan,
PI drawings rejected by the preview, the builder naming its cap.
This commit is contained in:
1 parent
8294d5471c
commit
ca31b787b6
13 files changed
+201
-36
No files matched your search
@@ -850,3 +850,26 @@ fn is_below(key: &ElementKey, ancestor: &ElementKey) -> bool {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_edit_on_a_long_chain_of_views_stays_linear() {
|
||||
let mut doc = serde_json::to_value(small()).unwrap();
|
||||
let views = doc["views"].as_array_mut().unwrap();
|
||||
for i in 0..2000 {
|
||||
let parent = if i == 0 {
|
||||
"main".to_owned()
|
||||
} else {
|
||||
format!("c{}", i - 1)
|
||||
};
|
||||
views.push(json!({ "id": format!("c{i}"), "kind": "detail", "name": name("C"), "svg_asset_id": null,
|
||||
"view_box": { "min_x": 0, "min_y": 0, "width": 1, "height": 1 }, "parent_view_id": parent }));
|
||||
}
|
||||
let doc: AnatomicalSheetDocument = serde_json::from_value(doc).unwrap();
|
||||
let started = std::time::Instant::now();
|
||||
edit(&doc, json!({ "op": "remove", "key": annotation("a1") }));
|
||||
assert!(
|
||||
started.elapsed().as_millis() < 1000,
|
||||
"{:?}",
|
||||
started.elapsed()
|
||||
);
|
||||
}
|
||||
@@ -391,3 +391,48 @@ fn a_preview_holds_a_bounded_number_of_bounded_drawings() {
|
||||
);
|
||||
assert_eq!(draft.drawing_reads(), 1, "the same bytes are read once");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_replaced_asset_releases_its_parse_and_a_pi_drawing_shows_rejected() {
|
||||
let mut draft = PreviewSheet::load(
|
||||
input(PreviewStatus::Draft, document_text(), None),
|
||||
vec![horse_drawing()],
|
||||
)
|
||||
.unwrap();
|
||||
for i in 0..40 {
|
||||
let svg = format!(r#"<svg xmlns="http://www.w3.org/2000/svg"><path d="M0 0h{i}"/></svg>"#)
|
||||
.into_bytes();
|
||||
let sha = faunosteo_core::domain::sheet::verdict::sha256_hex(&svg);
|
||||
draft
|
||||
.add_drawing(PreviewDrawing {
|
||||
asset_id: "same-asset".into(),
|
||||
sha256: sha,
|
||||
bytes: svg,
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
assert_eq!(
|
||||
draft.held_parses(),
|
||||
2,
|
||||
"the horse and the last bytes of the re-added asset"
|
||||
);
|
||||
let pi = br#"<?xml-stylesheet href="https://e/x.xsl"?><svg xmlns="http://www.w3.org/2000/svg"><path d="M0 0h1"/></svg>"#.to_vec();
|
||||
let sha = faunosteo_core::domain::sheet::verdict::sha256_hex(&pi);
|
||||
let mut doc = parse_json(&document_text()).unwrap();
|
||||
doc["views"][0]["svg_asset_id"] = json!("33333333-0000-4000-8000-000000000001");
|
||||
let preview = PreviewSheet::load(
|
||||
input(PreviewStatus::Draft, doc.to_string(), None),
|
||||
vec![PreviewDrawing {
|
||||
asset_id: "33333333-0000-4000-8000-000000000001".into(),
|
||||
sha256: sha,
|
||||
bytes: pi,
|
||||
}],
|
||||
)
|
||||
.unwrap();
|
||||
let state = state(&preview);
|
||||
assert_eq!(state.drawings[0].state, PreviewDrawingStatus::Rejected);
|
||||
assert_eq!(
|
||||
state.drawings[0].detail.as_deref(),
|
||||
Some("processing_instruction")
|
||||
);
|
||||
}
|
||||
@@ -161,6 +161,9 @@ fn hidden_or_html_content_is_refused_not_cleaned() {
|
||||
svg("<h:form action=\"https://e\"/>"),
|
||||
svg("<h:div>x</h:div>"),
|
||||
svg("<g><x:thing xmlns:x=\"urn:x\" src=\"https://e\"/></g>"),
|
||||
svg("<g xml:base=\"https://e/\"><path d=\"M0 0h1\"/></g>"),
|
||||
svg("<path d=\"M0 0h1\" style=\"fill:src('https://e/x')\"/>"),
|
||||
svg("<style>p{fill:image('https://e/x.png')}</style>"),
|
||||
];
|
||||
for case in cases {
|
||||
let cleaning = clean_svg(case.as_bytes());
|
||||
|
||||
Reference in new issue
Block a user