fix(anatomy): R5.4 report guard as an allowlist (report_guard.rs), sweep of 762 probes incl. seeded random strings, NUL refused in field segments

This commit is contained in:
bchanot committed 2026-10-23 12:39:17 +02:00
1 parent 077d91bdff
commit 124d954a0d
10 files changed
+246 -195

No files matched your search

+16 -19
View File
@@ -15,7 +15,8 @@ use faunosteo_core::curation::draft::migration_map::{
use faunosteo_core::curation::draft::review_report::{ReviewReportInput, render_review_report};
use faunosteo_core::curation::draft::stats::document_stats;
use faunosteo_core::curation::draft::{apply_changeset, parse_changeset, parse_references};
use faunosteo_core::curation::markdown::format_markdown;
use faunosteo_core::curation::ids::sha256_hex;
use faunosteo_core::curation::report_guard::format_report;
use faunosteo_core::json::to_js_compact;
use serde_json::{Value, json};
@@ -69,9 +70,11 @@ const EQUINE_SAFE: &str = "[]&#{}=<>\"':;()/%?-.,«»…≠°—+";
fn equine_safe(probe: &str) -> bool {
// A leading or trailing space becomes two spaces once the probe sits in its sentence; the
// inline constructs (links, wiki links, autolinks, character references) are probed apart.
let construct = ["](", "][", "[[", "&", "<h", "<a@"]
.iter()
.any(|m| probe.contains(m));
let tag = probe
.split('<')
.skip(1)
.any(|after| after.starts_with(|c: char| c.is_ascii_alphabetic() || "/!?".contains(c)));
let construct = tag || ["](", "][", "[[ ", "&"].iter().any(|m| probe.contains(m));
!construct
&& !probe.contains(" ")
&& !probe.starts_with(' ')
@@ -88,32 +91,26 @@ fn every_probe_is_formatted_as_the_typescript_or_refused() {
for case in frozen["cases"].as_array().unwrap() {
let probe = case["probe"].as_str().unwrap();
let (changelog, review) = raw_reports(&frozen, case);
let digest = |text: &str| sha256_hex(text.as_bytes());
assert_eq!(
changelog,
case["changelog_raw"].as_str().unwrap(),
digest(&changelog),
case["changelog_raw_sha256"],
"{probe:?} raw"
);
if let Ok(review) = &review {
assert_eq!(
review,
case["review_raw"].as_str().unwrap(),
"{probe:?} raw"
);
assert_eq!(digest(review), case["review_raw_sha256"], "{probe:?} raw");
}
let outcomes = [
(format_report(&changelog), &case["changelog_sha256"]),
(
format_markdown(&changelog),
case["changelog"].as_str().unwrap(),
),
(
review.and_then(|text| format_markdown(&text)),
case["review"].as_str().unwrap(),
review.and_then(|text| format_report(&text)),
&case["review_sha256"],
),
];
let mut case_refused = false;
for (outcome, expected) in outcomes {
match outcome {
Ok(text) if text == expected => {}
Ok(text) if digest(&text) == *expected => {}
Ok(_) => silent.push(probe.to_owned()),
Err(PipelineError::UnsupportedMarkdown(_) | PipelineError::UnsupportedWidth(_)) => {
case_refused = true;
@@ -137,6 +134,6 @@ fn every_probe_is_formatted_as_the_typescript_or_refused() {
"silent differences for {} probes: {silent:?}",
silent.len()
);
assert_eq!(same + refused, 247);
assert_eq!(same + refused, 762);
println!("{same} identical, {refused} refused");
}