Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can — learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company đŸ‘‡

feat(lisdex): M8.0 - an advisory that refuses three fields, and never files a planted bug

CarterPerez-dev0707a3d2c9b2
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/Cargo.lock b/PROJECTS/advanced/zero-day-vulnerability-scanner/Cargo.lock
index 38fb95cb..d0afc165 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/Cargo.lock
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/Cargo.lock
@@ -751,6 +751,15 @@ dependencies = [
"ureq",
]
+[[package]]
+name = "lisdex-report"
+version = "0.0.0"
+dependencies = [
+ "lisdex-core",
+ "lisdex-triage",
+ "serde_json",
+]
+
[[package]]
name = "lisdex-surface"
version = "0.1.0"
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/Cargo.toml b/PROJECTS/advanced/zero-day-vulnerability-scanner/Cargo.toml
index 3de418bf..32e45711 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/Cargo.toml
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/Cargo.toml
@@ -29,6 +29,7 @@ lisdex-surface = { path = "crates/lisdex-surface" }
lisdex-harness = { path = "crates/lisdex-harness" }
lisdex-llm = { path = "crates/lisdex-llm" }
lisdex-triage = { path = "crates/lisdex-triage" }
+lisdex-report = { path = "crates/lisdex-report" }
[workspace.lints.rust]
unsafe_code = "deny"
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/Cargo.toml b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/Cargo.toml
new file mode 100644
index 00000000..9eb3adce
--- /dev/null
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/Cargo.toml
@@ -0,0 +1,18 @@
+# ©AngelaMos | 2026
+# Cargo.toml
+
+[package]
+name = "lisdex-report"
+version = "0.0.0"
+edition.workspace = true
+rust-version.workspace = true
+license.workspace = true
+authors.workspace = true
+
+[dependencies]
+lisdex-core = { workspace = true }
+lisdex-triage = { workspace = true }
+serde_json = { workspace = true }
+
+[lints]
+workspace = true
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/advisory.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/advisory.rs
new file mode 100644
index 00000000..48573623
--- /dev/null
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/advisory.rs
@@ -0,0 +1,347 @@
+// ©AngelaMos | 2026
+// advisory.rs
+
+use lisdex_core::crash::Crash;
+use lisdex_core::report::SanitizerReport;
+use lisdex_triage::classify::classify;
+use lisdex_triage::severity::Severity;
+
+use crate::weakness::{Weakness, weakness_for};
+
+const BENCHMARK_CANARY_FRAME: &str = "magma_log";
+const BENCHMARK_FUNCTION_PREFIX: &str = "MAGMA_";
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Provenance {
+ Field,
+ SyntheticBenchmark,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum OperatorInput {
+ AffectedVersionRange,
+ CvssVector,
+ AttackerReachability,
+}
+
+impl OperatorInput {
+ #[must_use]
+ pub fn field(self) -> &'static str {
+ match self {
+ Self::AffectedVersionRange => "Affected version range",
+ Self::CvssVector => "CVSS vector and score",
+ Self::AttackerReachability => "Attacker-reachability of this entry point",
+ }
+ }
+
+ #[must_use]
+ pub fn why(self) -> &'static str {
+ match self {
+ Self::AffectedVersionRange => {
+ "lisdex fuzzed one build and persists no version identifier for it. Establishing \
+ the earliest affected release means building and re-testing released versions, \
+ which this campaign did not do."
+ }
+ Self::CvssVector => {
+ "A CVSS vector encodes attack complexity, privileges required, user interaction \
+ and scope. None of those are observable from a crash, and a score derived from \
+ the crash class alone would be a guess wearing a number."
+ }
+ Self::AttackerReachability => {
+ "lisdex drove a harness it synthesized against a ranked entry point. That the \
+ entry point is public API is measured; that a real deployment feeds it \
+ attacker-controlled bytes is a judgement about the consumer, not the library."
+ }
+ }
+ }
+}
+
+pub const OPERATOR_INPUTS: [OperatorInput; 3] = [
+ OperatorInput::AffectedVersionRange,
+ OperatorInput::CvssVector,
+ OperatorInput::AttackerReachability,
+];
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Advisory {
+ target: String,
+ key: String,
+ class: String,
+ severity: Severity,
+ weakness: Option<Weakness>,
+ security_relevant: bool,
+ crash_site: Option<String>,
+ frames: Vec<String>,
+ crash_count: usize,
+ reproducer_bytes: usize,
+ provenance: Provenance,
+ sanitizer_report: String,
+}
+
+impl Advisory {
+ #[must_use]
+ pub fn draft(target: &str, representative: &Crash, crash_count: usize) -> Option<Advisory> {
+ let text = representative.sanitizer_report();
+ let parsed = SanitizerReport::parse(text)?;
+ let classification = classify(text)?;
+ let key = representative.stack_hash()?.to_owned();
+ Some(Advisory {
+ target: target.to_owned(),
+ key,
+ class: classification.class().to_owned(),
+ severity: classification.severity(),
+ weakness: weakness_for(classification.class()),
+ security_relevant: classification.is_security_relevant(),
+ crash_site: parsed.crash_site().map(str::to_owned),
+ frames: parsed.frames().to_vec(),
+ crash_count,
+ reproducer_bytes: representative.input().len(),
+ provenance: provenance_of(&parsed),
+ sanitizer_report: text.to_owned(),
+ })
+ }
+
+ #[must_use]
+ pub fn target(&self) -> &str {
+ &self.target
+ }
+
+ #[must_use]
+ pub fn key(&self) -> &str {
+ &self.key
+ }
+
+ #[must_use]
+ pub fn class(&self) -> &str {
+ &self.class
+ }
+
+ #[must_use]
+ pub fn severity(&self) -> Severity {
+ self.severity
+ }
+
+ #[must_use]
+ pub fn weakness(&self) -> Option<Weakness> {
+ self.weakness
+ }
+
+ #[must_use]
+ pub fn is_security_relevant(&self) -> bool {
+ self.security_relevant
+ }
+
+ #[must_use]
+ pub fn crash_site(&self) -> Option<&str> {
+ self.crash_site.as_deref()
+ }
+
+ #[must_use]
+ pub fn frames(&self) -> &[String] {
+ &self.frames
+ }
+
+ #[must_use]
+ pub fn crash_count(&self) -> usize {
+ self.crash_count
+ }
+
+ #[must_use]
+ pub fn reproducer_bytes(&self) -> usize {
+ self.reproducer_bytes
+ }
+
+ #[must_use]
+ pub fn provenance(&self) -> Provenance {
+ self.provenance
+ }
+
+ #[must_use]
+ pub fn sanitizer_report(&self) -> &str {
+ &self.sanitizer_report
+ }
+
+ #[must_use]
+ pub fn is_disclosable(&self) -> bool {
+ self.provenance == Provenance::Field
+ }
+
+ #[must_use]
+ pub fn severity_is_assessed(&self) -> bool {
+ self.severity != Severity::Undefined
+ }
+}
+
+#[must_use]
+pub fn provenance_of(report: &SanitizerReport) -> Provenance {
+ let planted = report.frames().iter().any(|frame| {
+ frame == BENCHMARK_CANARY_FRAME || frame.starts_with(BENCHMARK_FUNCTION_PREFIX)
+ });
+ if planted {
+ Provenance::SyntheticBenchmark
+ } else {
+ Provenance::Field
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use lisdex_core::campaign::CampaignId;
+
+ use super::*;
+
+ const CAMPAIGN: CampaignId = CampaignId(1);
+
+ const REAL_HEAP_WRITE: &str = "\
+=================================================================
+==53767==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7bd6bfde0020 at pc 0x558474e40fd9
+WRITE of size 32 at 0x7bd6bfde0020 thread T0
+ #0 0x558474e40fd8 in png_handle_iCCP /src/libpng/pngrutil.c:1447:5
+ #1 0x558474e41111 in png_read_info /src/libpng/pngread.c:160:10
+SUMMARY: AddressSanitizer: heap-buffer-overflow (/out/harness+0xcdfd8) in png_handle_iCCP
+";
+
+ const CANARY_CRASH: &str = "\
+=================================================================
+==29092==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000071a4 (pc 0x7fa6518a053b bp 0x1 sp 0x2 T0)
+==29092==The signal is caused by a READ memory access.
+ #0 0x7fa6518a053b in kill (/lib/x86_64-linux-gnu/libc.so.6+0x4553b)
+ #1 0x55a5aee02220 in magma_log /opt/magma/magma/src/canary.c:92:5
+ #2 0x55a5aee68dae in MAGMA_png_handle_PLTE /opt/magma-work/libpng/repo/pngrutil.c:992:4
+SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x4553b) in kill
+";
+
+ const CANARY_RUNTIME_ONLY: &str = "\
+=================================================================
+==29093==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000071a4 (pc 0x1 bp 0x1 sp 0x2 T0)
+==29093==The signal is caused by a READ memory access.
+ #0 0x1 in kill (/lib/x86_64-linux-gnu/libc.so.6+0x4553b)
+ #1 0x2 in magma_log /opt/magma/magma/src/canary.c:92:5
+ #2 0x3 in some_unrenamed_parser /repo/parse.c:10:4
+SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x4553b) in kill
+";
+
+ const CANARY_RENAME_ONLY: &str = "\
+=================================================================
+==29094==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000018 at pc 0x4a1
+WRITE of size 1 at 0x602000000018 thread T0
+ #0 0x4a1 in MAGMA_png_handle_PLTE /opt/magma-work/libpng/repo/pngrutil.c:992:4
+SUMMARY: AddressSanitizer: heap-buffer-overflow (/out/harness+0x4a1) in MAGMA_png_handle_PLTE
+";
+
+ fn crash(report: &str) -> Crash {
+ Crash::from_report(CAMPAIGN, b"reproducer-bytes".to_vec(), report)
+ }
+
+ #[test]
+ fn a_draft_carries_the_measured_facts_of_its_group() {
+ let advisory = Advisory::draft("libpng", &crash(REAL_HEAP_WRITE), 44).unwrap();
+ assert_eq!(advisory.target(), "libpng");
+ assert_eq!(advisory.class(), "heap-buffer-overflow(write)");
+ assert_eq!(advisory.severity(), Severity::Exploitable);
+ assert_eq!(advisory.weakness().unwrap().id, "CWE-122");
+ assert_eq!(advisory.crash_site(), Some("png_handle_iCCP"));
+ assert_eq!(advisory.crash_count(), 44);
+ assert_eq!(advisory.reproducer_bytes(), b"reproducer-bytes".len());
+ assert!(advisory.is_security_relevant());
+ }
+
+ #[test]
+ fn a_crash_with_no_dedup_key_drafts_no_advisory() {
+ let unkeyed = Crash::from_report(
+ CAMPAIGN,
+ b"x".to_vec(),
+ "==12==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x1 at pc 0x2\n #0 0x3 (/out/lib.so+0x4)\n",
+ );
+ assert_eq!(unkeyed.stack_hash(), None);
+ assert!(
+ Advisory::draft("libpng", &unkeyed, 1).is_none(),
+ "an advisory names one bug, and a crash the triage layer refused to key is not known to be one bug"
+ );
+ }
+
+ #[test]
+ fn a_planted_benchmark_crash_is_never_disclosable() {
+ let advisory = Advisory::draft("libpng", &crash(CANARY_CRASH), 44).unwrap();
+ assert_eq!(advisory.provenance(), Provenance::SyntheticBenchmark);
+ assert!(
+ !advisory.is_disclosable(),
+ "this is an injected benchmark canary in a research build of libpng; an advisory that looked genuine could be filed against a real, widely deployed library for a bug that was deliberately planted"
+ );
+ }
+
+ #[test]
+ fn the_canary_runtime_alone_is_enough_to_mark_it() {
+ let report = SanitizerReport::parse(CANARY_RUNTIME_ONLY).unwrap();
+ assert!(
+ !report
+ .frames()
+ .iter()
+ .any(|f| f.starts_with(BENCHMARK_FUNCTION_PREFIX)),
+ "the fixture must isolate the signal: no renamed function here, only the canary runtime"
+ );
+ assert_eq!(provenance_of(&report), Provenance::SyntheticBenchmark);
+ }
+
+ #[test]
+ fn a_renamed_benchmark_function_alone_is_enough_to_mark_it() {
+ let report = SanitizerReport::parse(CANARY_RENAME_ONLY).unwrap();
+ assert!(
+ !report.frames().iter().any(|f| f == BENCHMARK_CANARY_FRAME),
+ "the fixture must isolate the signal: no canary runtime frame here, only a renamed function"
+ );
+ assert_eq!(provenance_of(&report), Provenance::SyntheticBenchmark);
+ }
+
+ #[test]
+ fn a_real_crash_is_not_mistaken_for_a_benchmark() {
+ let advisory = Advisory::draft("libpng", &crash(REAL_HEAP_WRITE), 1).unwrap();
+ assert_eq!(
+ advisory.provenance(),
+ Provenance::Field,
+ "marking every finding synthetic would make the mark meaningless"
+ );
+ assert!(advisory.is_disclosable());
+ }
+
+ #[test]
+ fn the_guard_reads_every_frame_and_not_just_the_significant_ones() {
+ let report = SanitizerReport::parse(CANARY_RUNTIME_ONLY).unwrap();
+ assert!(
+ !report
+ .significant_frames()
+ .contains(&BENCHMARK_CANARY_FRAME),
+ "magma_log is filtered out of the significant frames by the dedup noise list, so a guard reading those would never see the canary runtime at all"
+ );
+ assert!(report.frames().iter().any(|f| f == BENCHMARK_CANARY_FRAME));
+ }
+
+ #[test]
+ fn every_operator_input_states_a_field_and_a_reason() {
+ for input in OPERATOR_INPUTS {
+ assert!(!input.field().is_empty());
+ assert!(
+ input.why().len() > 40,
+ "a field lisdex declines to fill has to say why, or the reader cannot tell a gap from an oversight"
+ );
+ }
+ }
+
+ #[test]
+ fn an_undefined_severity_is_reported_as_unassessed() {
+ let ubsan = crash(
+ "pngrutil.c:1204:7: runtime error: left shift of negative value -1\n #0 0x55a in png_do_read_transform pngrtran.c:1204:7\n",
+ );
+ let advisory = Advisory::draft("libpng", &ubsan, 1).unwrap();
+ assert_eq!(advisory.severity(), Severity::Undefined);
+ assert!(
+ !advisory.severity_is_assessed(),
+ "lisdex has no ground-truth corpus for UBSan severity (B91), so an advisory must not present the placeholder tier as an assessment"
+ );
+ assert_eq!(
+ advisory.weakness(),
+ None,
+ "and the same gap applies to naming a CWE for it"
+ );
+ }
+}
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/lib.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/lib.rs
new file mode 100644
index 00000000..64ffa815
--- /dev/null
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/lib.rs
@@ -0,0 +1,5 @@
+// ©AngelaMos | 2026
+// lib.rs
+
+pub mod advisory;
+pub mod weakness;
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/weakness.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/weakness.rs
new file mode 100644
index 00000000..41c90883
--- /dev/null
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/weakness.rs
@@ -0,0 +1,233 @@
+// ©AngelaMos | 2026
+// weakness.rs
+
+const QUALIFIER_OPEN: char = '(';
+const QUALIFIER_CLOSE: char = ')';
+const READ: &str = "read";
+const WRITE: &str = "write";
+
+const HEAP_OVERFLOW: &str = "heap-buffer-overflow";
+const STACK_OVERFLOW: &str = "stack-buffer-overflow";
+const GLOBAL_OVERFLOW: &str = "global-buffer-overflow";
+const DYNAMIC_STACK_OVERFLOW: &str = "dynamic-stack-buffer-overflow";
+const USE_AFTER_FREE_CLASS: &str = "heap-use-after-free";
+const DOUBLE_FREE_CLASS: &str = "double-free";
+const MEMORY_LEAKS_CLASS: &str = "memory-leaks";
+const SOURCE_AV_NEAR_NULL: &str = "SourceAvNearNull";
+const DEST_AV_NEAR_NULL: &str = "DestAvNearNull";
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct Weakness {
+ pub id: &'static str,
+ pub name: &'static str,
+}
+
+pub const OUT_OF_BOUNDS_WRITE: Weakness = Weakness {
+ id: "CWE-787",
+ name: "Out-of-bounds Write",
+};
+
+pub const STACK_BASED_BUFFER_OVERFLOW: Weakness = Weakness {
+ id: "CWE-121",
+ name: "Stack-based Buffer Overflow",
+};
+
+pub const HEAP_BASED_BUFFER_OVERFLOW: Weakness = Weakness {
+ id: "CWE-122",
+ name: "Heap-based Buffer Overflow",
+};
+
+pub const OUT_OF_BOUNDS_READ: Weakness = Weakness {
+ id: "CWE-125",
+ name: "Out-of-bounds Read",
+};
+
+pub const USE_AFTER_FREE: Weakness = Weakness {
+ id: "CWE-416",
+ name: "Use After Free",
+};
+
+pub const DOUBLE_FREE: Weakness = Weakness {
+ id: "CWE-415",
+ name: "Double Free",
+};
+
+pub const NULL_POINTER_DEREFERENCE: Weakness = Weakness {
+ id: "CWE-476",
+ name: "NULL Pointer Dereference",
+};
+
+pub const MISSING_RELEASE_OF_MEMORY: Weakness = Weakness {
+ id: "CWE-401",
+ name: "Missing Release of Memory after Effective Lifetime",
+};
+
+#[must_use]
+pub fn split_qualifier(class: &str) -> (&str, Option<&str>) {
+ match class.split_once(QUALIFIER_OPEN) {
+ Some((base, rest)) => (base, rest.strip_suffix(QUALIFIER_CLOSE)),
+ None => (class, None),
+ }
+}
+
+#[must_use]
+pub fn weakness_for(class: &str) -> Option<Weakness> {
+ let (base, qualifier) = split_qualifier(class);
+ match (base, qualifier) {
+ (_, Some(READ))
+ if matches!(
+ base,
+ HEAP_OVERFLOW | STACK_OVERFLOW | GLOBAL_OVERFLOW | DYNAMIC_STACK_OVERFLOW
+ ) =>
+ {
+ Some(OUT_OF_BOUNDS_READ)
+ }
+ (HEAP_OVERFLOW, Some(WRITE)) => Some(HEAP_BASED_BUFFER_OVERFLOW),
+ (STACK_OVERFLOW | DYNAMIC_STACK_OVERFLOW, Some(WRITE)) => Some(STACK_BASED_BUFFER_OVERFLOW),
+ (GLOBAL_OVERFLOW, Some(WRITE)) => Some(OUT_OF_BOUNDS_WRITE),
+ (USE_AFTER_FREE_CLASS, _) => Some(USE_AFTER_FREE),
+ (DOUBLE_FREE_CLASS, None) => Some(DOUBLE_FREE),
+ (MEMORY_LEAKS_CLASS, None) => Some(MISSING_RELEASE_OF_MEMORY),
+ (SOURCE_AV_NEAR_NULL | DEST_AV_NEAR_NULL, None) => Some(NULL_POINTER_DEREFERENCE),
+ _ => None,
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn the_access_direction_decides_the_weakness_not_the_region() {
+ assert_eq!(
+ weakness_for("heap-buffer-overflow(write)"),
+ Some(HEAP_BASED_BUFFER_OVERFLOW)
+ );
+ assert_eq!(
+ weakness_for("heap-buffer-overflow(read)"),
+ Some(OUT_OF_BOUNDS_READ),
+ "CWE-122 sits under CWE-787 Out-of-bounds WRITE, so calling a read overflow a heap-based buffer overflow states the wrong weakness in an advisory"
+ );
+ assert_eq!(
+ weakness_for("stack-buffer-overflow(read)"),
+ Some(OUT_OF_BOUNDS_READ)
+ );
+ assert_eq!(
+ weakness_for("global-buffer-overflow(read)"),
+ Some(OUT_OF_BOUNDS_READ)
+ );
+ }
+
+ #[test]
+ fn each_overflow_region_maps_to_its_own_write_weakness() {
+ assert_eq!(
+ weakness_for("stack-buffer-overflow(write)"),
+ Some(STACK_BASED_BUFFER_OVERFLOW)
+ );
+ assert_eq!(
+ weakness_for("dynamic-stack-buffer-overflow(write)"),
+ Some(STACK_BASED_BUFFER_OVERFLOW)
+ );
+ assert_eq!(
+ weakness_for("global-buffer-overflow(write)"),
+ Some(OUT_OF_BOUNDS_WRITE),
+ "CWE has no global-buffer variant, so the honest answer is the Base weakness rather than a stack or heap variant that names the wrong region"
+ );
+ }
+
+ #[test]
+ fn a_use_after_free_maps_the_same_way_in_both_directions() {
+ assert_eq!(
+ weakness_for("heap-use-after-free(read)"),
+ Some(USE_AFTER_FREE)
+ );
+ assert_eq!(
+ weakness_for("heap-use-after-free(write)"),
+ Some(USE_AFTER_FREE)
+ );
+ }
+
+ #[test]
+ fn the_unqualified_classes_map_to_their_own_weaknesses() {
+ assert_eq!(weakness_for("double-free"), Some(DOUBLE_FREE));
+ assert_eq!(
+ weakness_for("memory-leaks"),
+ Some(MISSING_RELEASE_OF_MEMORY)
+ );
+ assert_eq!(
+ weakness_for("SourceAvNearNull"),
+ Some(NULL_POINTER_DEREFERENCE)
+ );
+ assert_eq!(
+ weakness_for("DestAvNearNull"),
+ Some(NULL_POINTER_DEREFERENCE)
+ );
+ }
+
+ #[test]
+ fn a_fault_that_is_not_near_null_is_refused_rather_than_called_a_null_dereference() {
+ assert_eq!(
+ weakness_for("SourceAv"),
+ None,
+ "a wild read at an address the boundary calls far is not a null dereference and is not demonstrably an out-of-bounds access either; naming a weakness here would be a guess in a security advisory"
+ );
+ assert_eq!(weakness_for("DestAv"), None);
+ assert_eq!(weakness_for("AccessViolation"), None);
+ }
+
+ #[test]
+ fn an_overflow_whose_access_direction_is_unknown_is_refused_rather_than_assumed_a_write() {
+ for class in [
+ "heap-buffer-overflow",
+ "stack-buffer-overflow",
+ "global-buffer-overflow",
+ "dynamic-stack-buffer-overflow",
+ ] {
+ assert_eq!(
+ weakness_for(class),
+ None,
+ "{class} carries no access direction, which is what an unanchored report produces when libcasr cannot find the READ/WRITE line; guessing WRITE here would publish CWE-787 for what may be an out-of-bounds read"
+ );
+ }
+ }
+
+ #[test]
+ fn a_class_the_table_does_not_cover_yields_no_weakness() {
+ assert_eq!(weakness_for(""), None);
+ assert_eq!(weakness_for("undefined-behavior"), None);
+ assert_eq!(weakness_for("shift exponent 35 is too large"), None);
+ assert_eq!(weakness_for("some-future-sanitizer-class(write)"), None);
+ }
+
+ #[test]
+ fn every_identifier_is_a_cwe_id_and_every_name_is_the_one_mitre_publishes() {
+ for weakness in [
+ OUT_OF_BOUNDS_WRITE,
+ STACK_BASED_BUFFER_OVERFLOW,
+ HEAP_BASED_BUFFER_OVERFLOW,
+ OUT_OF_BOUNDS_READ,
+ USE_AFTER_FREE,
+ DOUBLE_FREE,
+ NULL_POINTER_DEREFERENCE,
+ MISSING_RELEASE_OF_MEMORY,
+ ] {
+ assert!(weakness.id.starts_with("CWE-"));
+ assert!(weakness.id[4..].chars().all(|c| c.is_ascii_digit()));
+ assert!(!weakness.name.is_empty());
+ }
+ assert_eq!(
+ MISSING_RELEASE_OF_MEMORY.name, "Missing Release of Memory after Effective Lifetime",
+ "the shorthand everyone writes is 'Memory Leak', which is not what CWE-401 is called, and an advisory quoting a CWE has to quote its published name"
+ );
+ }
+
+ #[test]
+ fn a_qualifier_is_split_off_only_when_it_is_closed() {
+ assert_eq!(split_qualifier("double-free"), ("double-free", None));
+ assert_eq!(
+ split_qualifier("heap-buffer-overflow(write)"),
+ ("heap-buffer-overflow", Some("write"))
+ );
+ assert_eq!(split_qualifier("truncated(write"), ("truncated", None));
+ }
+}