From 0369b4d17bc61a36e01609994f6c4cba407f78da Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 14:18:15 +0000 Subject: [PATCH] fix(panicbot): carry unsuppressed test-code findings, as the direct lane does First shadow run (standards#1562): the direct panic-attack row read critical in a changed test script; panicbot read clean. Same binary, same tree. Of 75 weak points, 51 are production, 6 test_only (not suppressed) and 18 test_only (suppressed). The direct lane keeps the first 57; panicbot dropped the test_only ones, so it reported 51. Owner ruling 2026-11-14: carry them at full severity. translate_all now drops only what panic-attack itself suppressed; test_context is recorded in the finding metadata. Against the real tree panicbot now reports 57, equal to the direct lane. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZkEdznGjgTixZgjhB6 --- bots/panicbot/src/translator.rs | 53 +++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/bots/panicbot/src/translator.rs b/bots/panicbot/src/translator.rs index 62b08fa4..c18735a8 100644 --- a/bots/panicbot/src/translator.rs +++ b/bots/panicbot/src/translator.rs @@ -380,6 +380,7 @@ pub fn translate_weak_point(wp: &WeakPoint, config: &PanicbotConfig) -> Finding "panic_attack_category": wp.category, "panic_attack_severity": wp.severity, "recommended_attacks": wp.recommended_attack, + "test_context": wp.test_context, })); finding @@ -400,20 +401,19 @@ pub fn translate_all(weak_points: &[WeakPoint], config: &PanicbotConfig) -> Vec< // RAII, schema validation) that makes this finding likely a false positive. // // v2.5.5+ classifications (test_context field): - // * `"test_only"` / `"doc"` → typically also `suppressed: true` - // (set by `apply_v255_context_suppression` in panic-attack - // after the kanren rule pass). Defensive: even if a future - // scanner version preserves `suppressed: false` while - // classifying as TestOnly, drop the finding here so test code - // never reaches the fleet. + // * `"test_only"` / `"doc"` that panic-attack suppressed + // (`suppressed: true`) are dropped with the rest. + // * `"test_only"` / `"doc"` that it did NOT suppress are carried + // at their own severity, with `test_context` in the finding's + // metadata. The direct panic-attack lane keeps them, and + // dropping them made the shadow row read clean where the + // direct row read critical (owner ruling 2026-11-14: carry at + // full severity). Never dropped silently. // * `"production"` → forwarded normally. // * `None` → predates v2.5.5; treat as production. if wp.suppressed { return None; } - if matches!(wp.test_context.as_deref(), Some("test_only") | Some("doc")) { - return None; - } // Apply severity filter let severity_value = match wp.severity.to_lowercase().as_str() { @@ -698,31 +698,46 @@ mod tests { } #[test] - fn translate_all_drops_test_only_findings_even_if_not_suppressed() { - // Defensive: even when `suppressed: false`, a `test_context: test_only` - // finding should not reach the fleet. + fn translate_all_carries_unsuppressed_test_only_findings() { + // The direct lane keeps them; so does panicbot, at full severity, with + // the test context recorded in the metadata. let wps = vec![ make_wp("UnsafeCode", Some("test_only"), false), make_wp("UnsafeCode", Some("production"), false), ]; let config = PanicbotConfig::default(); let findings = translate_all(&wps, &config); - assert_eq!( - findings.len(), - 1, - "test_only finding must be dropped regardless of suppressed flag" - ); + assert_eq!(findings.len(), 2, "unsuppressed test_only must be carried"); + let carried = findings + .iter() + .find(|f| f.metadata["test_context"] == "test_only") + .expect("a finding records test_context test_only"); + assert_eq!(carried.severity, map_severity("Critical")); + } + + #[test] + fn translate_all_drops_suppressed_test_only_findings() { + let wps = vec![ + make_wp("UnsafeCode", Some("test_only"), true), + make_wp("UnsafeCode", Some("production"), false), + ]; + let findings = translate_all(&wps, &PanicbotConfig::default()); + assert_eq!(findings.len(), 1, "suppressed findings stay dropped"); } #[test] - fn translate_all_drops_doc_findings_even_if_not_suppressed() { + fn translate_all_carries_unsuppressed_doc_findings() { let wps = vec![ make_wp("PanicPath", Some("doc"), false), make_wp("PanicPath", Some("production"), false), ]; let config = PanicbotConfig::default(); let findings = translate_all(&wps, &config); - assert_eq!(findings.len(), 1, "doc finding must be dropped"); + assert_eq!( + findings.len(), + 2, + "unsuppressed doc finding must be carried" + ); } #[test]