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 π
Go aicertificationcloud-engineeringcybercybersecuritycybersecurity-analystcybersecurity-certificationcybersecurity-certificationscybersecurity-educationcybersecurity-jobscybersecurity-portfoliocybersecurity-projectscybersecurity-toolsgrchackinglearningpentestingproject-repositoryprojetcspython
fix(lisdex): B70 - a trailing digit is a version, not part of the verb
CarterPerez-devb16e9f33affa
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/extract.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/extract.rsindex 759f3cd8..ea1d5193 100644--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/extract.rs+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/extract.rs@@ -373,9 +373,26 @@ pub fn identifier_words(name: &str) -> Vec<String> {words}+// A trailing digit on a word is a version or a bit depth, never part of the verb:+// `tj3Compress8`, `tj3Decompress16`, `compress2`, `uncompress2`. Stripping it is what lets+// the verb be seen at all, and it has to happen per WORD rather than per name, because+// `identifier_words` splits `tj3Compress8` into `["tj3", "Compress8"]` and the digit sits in+// the middle of the identifier, not at its end.+//+// An all-digit word trims to the empty string and that needs no guard: "" cannot equal any+// vocabulary entry, and the suffix arm requires `only.len() > entry.len()`, so it cannot+// match a non-empty one either. A guard was written, measured inert on all 629 tests, and+// deleted rather than kept as insurance.+fn without_version_digits(word: &str) -> &str {+ word.trim_end_matches(|character: char| character.is_ascii_digit())+}+#[must_use]pub fn carries_word(name: &str, vocabulary: &[&str]) -> bool {- let words = identifier_words(name);+ let words: Vec<String> = identifier_words(name)+ .iter()+ .map(|word| without_version_digits(word).to_owned())+ .collect();if words.iter().any(|word| {vocabulary.iter()@@ -874,6 +891,59 @@ void WebPFreeDecBuffer(WebPDecBuffer *buffer);assert!(is_teardown_name("archive_read_free"));}+ // B70. `identifier_words` splits `tj3Compress8` into `["tj3", "Compress8"]`, and+ // "Compress8" is not the word "compress", so libjpeg-turbo's whole compressor family+ // carried NO write signal anywhere in the tool. The digit sits in the MIDDLE of the+ // identifier, which is why the strip has to run per word rather than per name.+ #[test]+ fn a_trailing_digit_is_a_version_or_a_bit_depth_never_part_of_the_verb() {+ use crate::naming::{READ_WORDS, WRITE_WORDS};+ assert!(carries_word("tj3Compress8", &WRITE_WORDS));+ assert!(carries_word("tj3Compress16", &WRITE_WORDS));+ assert!(carries_word("tj3Decompress8", &READ_WORDS));+ assert!(carries_word("compress2", &WRITE_WORDS));+ assert!(carries_word("uncompress2", &READ_WORDS));+ }++ // The isolating control for stripping per WORD rather than per name: the ladder's old+ // local workaround trimmed the whole identifier, which cannot reach a digit that is not+ // the last character. Both must pass, and only the per-word rule satisfies the second.+ #[test]+ fn a_digit_inside_the_identifier_is_reached_too_not_only_a_trailing_one() {+ use crate::naming::READ_WORDS;+ assert!(+ carries_word("Decompress8Bit", &READ_WORDS),+ "a whole-name trim stops at the final 't' and never sees Decompress8"+ );+ }++ // The other direction: stripping must not invent a word that was not there. These are+ // the shapes the census turned up across the seven trees - hash primitives, encodings+ // and type names whose stems sit next to real vocabulary entries.+ #[test]+ fn stripping_digits_does_not_manufacture_a_verb_that_was_never_written() {+ use crate::naming::{READ_WORDS, WRITE_WORDS};+ for name in [+ "crc32",+ "adler32",+ "sha256",+ "md5",+ "blake2xb",+ "poly1305",+ "xxh64",+ "utf8",+ "base64",+ "png16",+ "uint8",+ "VP8YuvToRgb32",+ ] {+ assert!(+ !carries_word(name, &READ_WORDS) && !carries_word(name, &WRITE_WORDS),+ "{name} carries no direction word and must not gain one"+ );+ }+ }+#[test]fn an_all_lowercase_name_falls_back_to_a_suffix_match() {assert!(diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/ladder.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/ladder.rsindex fdada8cb..f849c609 100644--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/ladder.rs+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/ladder.rs@@ -100,17 +100,6 @@ fn frequencies(files: &[Harness]) -> BTreeMap<String, usize> {counted}-// `identifier_words` splits `tj3Compress8` into `["tj3", "Compress8"]`, and "Compress8" is-// not the word "compress" - so libjpeg-turbo's `fuzz/compress.cc` carried NO write signal-// at all, while `tj3LoadImage8` gave it a read one, and the compressor's own fuzz target-// won its tier as a pure decoder. A trailing digit is a version or a bit depth, never part-// of the verb. Kept local to the ladder on purpose: `polarity_of` also decides producer-// selection, and that is measured behaviour this commit is not changing.-fn without_version_digits(name: &str) -> String {- name.trim_end_matches(|character: char| character.is_ascii_digit())- .to_owned()-}-pub const DIRECTION_PURE_READ: u8 = 3;pub const DIRECTION_NEUTRAL: u8 = 2;pub const DIRECTION_ROUND_TRIP: u8 = 1;@@ -130,7 +119,11 @@ fn direction(calls: &[String], declared: &BTreeSet<String>) -> (u8, usize) {let mut reads = 0;let mut writes = 0;for call in calls.iter().filter(|call| declared.contains(call.as_str())) {- match polarity_of(&without_version_digits(call)) {+ // The trailing-digit strip used to live here as a local workaround, because+ // `polarity_of` could not see the verb in `tj3Compress8` and touching it would have+ // moved producer selection too. It is in `carries_word` now (B70), measured at 13+ // verdict gains and 0 regressions, so the local copy is deleted rather than kept.+ match polarity_of(call) {Some(Polarity::Read) => reads += 1,Some(Polarity::Write) => writes += 1,None => {}