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
feat(lisdex): mine the author's call ORDER, not an alphabetised set
CarterPerez-dev4e23a80a13a6
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/harness.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/harness.rsindex 8cd385a9..ff1cb46c 100644--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/harness.rs+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-surface/src/harness.rs@@ -65,10 +65,18 @@ fn is_source(path: &Path) -> bool {.is_some_and(|extension| SOURCE_EXTENSIONS.contains(&extension.to_lowercase().as_str()))}+// Source order IS the finding. A `BTreeSet` here alphabetised the calls, which silently+// turned every mined harness into a reachability SET - and the set is the one thing headers+// already give you. libarchive's own harness says+// `archive_read_new` -> `archive_read_support_filter_all` -> `archive_read_support_format_all`+// -> `archive_read_open_memory`, and the middle two are exactly what our synthesized version+// omits to earn `ARCHIVE_FATAL` at full exec rate. Alphabetising loses which call must come+// first. Dedup on FIRST occurrence, because that is where the author established the order.#[must_use]pub fn extract_calls(body: &str) -> Vec<String> {let chars: Vec<char> = body.chars().collect();- let mut found = BTreeSet::new();+ let mut seen = BTreeSet::new();+ let mut found = Vec::new();let mut index = 0;while index < chars.len() {@@ -89,12 +97,13 @@ pub fn extract_calls(body: &str) -> Vec<String> {&& !NOT_CALLS.contains(&identifier.as_str())&& identifier != ENTRY_POINT&& identifier != INITIALIZE_POINT+ && seen.insert(identifier.clone()){- found.insert(identifier);+ found.push(identifier);}}- found.into_iter().collect()+ found}fn walk(root: &Path, depth: usize, found: &mut Vec<Harness>) -> Result<(), HarnessError> {@@ -150,6 +159,50 @@ pub fn discover(source: &Path) -> Result<Vec<Harness>, HarnessError> {Ok(found)}+// The isolating control for the ordering above: this fixture is written so that source order+// and alphabetical order DISAGREE. A `BTreeSet` extraction returns archive_read_data first;+// the author's actual sequence starts at archive_read_new. Any assertion using only+// `contains()` passes under both and is therefore an alibi, not a control.+#[cfg(test)]+mod order_tests {+ use super::extract_calls;++ #[test]+ fn mined_calls_keep_the_authors_order_rather_than_the_alphabets() {+ let body = "+ int LLVMFuzzerTestOneInput(const uint8_t *d, size_t n) {+ struct archive *a = archive_read_new();+ archive_read_support_filter_all(a);+ archive_read_support_format_all(a);+ archive_read_open_memory(a, d, n);+ archive_read_next_header(a, &e);+ archive_read_data(a, buf, sizeof(buf));+ archive_read_free(a);+ }+ ";+ let calls = extract_calls(body);+ assert_eq!(+ calls,+ vec![+ "archive_read_new",+ "archive_read_support_filter_all",+ "archive_read_support_format_all",+ "archive_read_open_memory",+ "archive_read_next_header",+ "archive_read_data",+ "archive_read_free",+ ],+ "alphabetical order would lead with archive_read_data"+ );+ }++ #[test]+ fn a_call_repeated_later_keeps_only_its_first_position() {+ let calls = extract_calls("zulu(); alpha(); zulu();");+ assert_eq!(calls, vec!["zulu", "alpha"]);+ }+}+#[must_use]pub fn reached_functions(harnesses: &[Harness]) -> BTreeSet<String> {harnesses