Files
faunosteo/.claude/audits/2026-10-29-v1-2-2-mutations-arbitrations.py
T
bchanot a678faaa23 fix(anatomy): V1-2.2 read url() references in their strict spelling only
Security review BLOCK(1): url(#%61) passed the dangling check and the
per-view scoping and resolved in browsers. One strict reading now, other
spellings are active content; glued names are other functions; the
composer refuses an unscoped reference; owner export procedure.
2026-10-29 16:49:15 +01:00

36 lines
4.2 KiB
Python

# V1-2.2 owner arbitrations, mutation run (evidence .claude/audits/2026-10-29-v1-2-2-evidence.md §7 (A1-A12 on 5281337, A13-A17 after the security review)): each
# mutant is applied to its source file, its cargo suite runs (`lib` = the crate's unit tests), the file is
# restored. Run from the repo root.
import subprocess
muts=[
('A1 reader accepts dangling','crates/core/src/anatomy/svg/mod.rs',' refs::check_targets(&sanitized.root)?;\n','','svg_scope'),
('A2 cleaning accepts dangling','crates/core/src/anatomy/svg/clean.rs','check_targets(&read.root)','Ok::<(), super::tree::SvgRejection>(())','svg_clean'),
('A3 canvas ids not scoped','crates/core/src/anatomy/compose.rs',' scope_ids(&mut root, &id_scope(view_id));\n','','svg_scope'),
('A4 url() references not scoped','crates/core/src/anatomy/compose.rs'," _ if attr.value.contains('(') => scope_url_targets(&attr.value, scope),"," _ if false => scope_url_targets(&attr.value, scope),",'svg_scope'),
('A5 verdict ignores the stored form','crates/core/src/domain/sheet/verdict.rs',' Ok(read) if stored_form(&read.root) != text =>',' Ok(read) if false && stored_form(&read.root) != text =>','sheet_verdict'),
('A6 preview ignores the stored form','crates/core/src/domain/sheet/preview.rs',' if stored_form(&root) != text {',' if false {','sheet_preview'),
('A7 cleaning uploads the original bytes','crates/core/src/anatomy/svg/clean.rs',' accepted(outcome, stored, preview, read.removed)',' accepted(outcome, String::from_utf8_lossy(bytes).into_owned(), preview, read.removed)','svg_clean'),
('A8 removal ignores dependents','crates/core/src/domain/sheet/edit.rs',' if named_elsewhere {',' if false && named_elsewhere {','sheet_edit'),
('A9 colour bound unchecked','crates/core/src/anatomy/svg/sanitize.rs',' if value > limit || bytes.get(index) != Some(&separator) {',' if bytes.get(index) != Some(&separator) {','svg_clean'),
('A10 glued name accepted','crates/core/src/anatomy/svg/sanitize.rs',' _ if glued => return None,',' _ if false && glued => return None,','lib'),
('A11 mixed units accepted','crates/core/src/anatomy/svg/sanitize.rs',' _ if *percentages.get_or_insert(percent) != percent => return None,',' _ if *percentages.get_or_insert(percent) != percent && false => return None,','lib'),
('A12 rgba with three components','crates/core/src/anatomy/svg/sanitize.rs',' _ if rest.starts_with("rgba(") => (4, 5),',' _ if rest.starts_with("rgba(") => (3, 5),','svg_clean'),
('A13 quote left unmatched','crates/core/src/anatomy/svg/sanitize.rs',' if bytes.get(index) != Some(&quote) {\n return None;\n }\n index += 1;',' if bytes.get(index) == Some(&quote) {\n index += 1;\n }','svg_clean'),
('A14 any id after #','crates/core/src/anatomy/svg/sanitize.rs',' if !is_reference_name(&value[id_start..id_end]) {',' if false {','svg_clean'),
('A15 glued url( read as url(','crates/core/src/anatomy/svg/sanitize.rs',' if !glued {\n return Some(from);',' if true || !glued {\n return Some(from);','svg_clean'),
('A16 colour glued to what follows','crates/core/src/anatomy/svg/sanitize.rs',' ends.then_some(at + index)',' Some(at + index)','svg_clean'),
('A17 percent-escaped id read as local','crates/core/src/anatomy/svg/sanitize.rs'," .take_while(|b| b.is_ascii_alphanumeric() || matches!(b, b'_' | b'.' | b':' | b'-'))"," .take_while(|b| b.is_ascii_alphanumeric() || matches!(b, b'_' | b'.' | b':' | b'-' | b'%'))",'svg_scope'),
]
for name,path,old,new,suite in muts:
src=open(path).read()
if src.count(old)!=1:
print(name,'ANCHOR NOT FOUND x',src.count(old)); continue
open(path,'w').write(src.replace(old,new))
target='--lib' if suite=='lib' else f'--test {suite}'
try:
r=subprocess.run(['bash','-c',f'. scripts/rust-env.sh && cargo test -q -p faunosteo-core {target} 2>&1 | tail -3'],capture_output=True,text=True)
out=r.stdout
print(f"{name} ({suite}): {'KILLED' if 'FAILED' in out else ('COMPILE-ERR' if 'could not compile' in out else 'SURVIVED')}", flush=True)
finally:
open(path,'w').write(src)