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): B51(a) - keep every survivor, so global novelty finally has something to be novel against
CarterPerez-devfbebd6318951
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex/src/main.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex/src/main.rsindex 777eb716..c2c9de3d 100644--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex/src/main.rs+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex/src/main.rs@@ -381,6 +381,7 @@ fn harness(args: &HarnessArgs) -> Result<(), Box<dyn Error>> {std::fs::create_dir_all(&candidates)?;let mut rejected = Vec::new();let mut accepted = EdgeSet::new();+ let mut survivors: Vec<Survivor> = Vec::new();let sequence = authored_sequence(&analysis);@@ -407,7 +408,14 @@ fn harness(args: &HarnessArgs) -> Result<(), Box<dyn Error>> {for ((label, source), plan) in emitted.iter().zip(&plans) {let Some(bench) = &bench else {- return promote(plan, candidate.name.as_str(), &args.out, plans.len(), None);+ return promote(+ plan,+ candidate.name.as_str(),+ &args.out,+ plans.len(),+ None,+ 0,+ );};// No parent: D4's linearity oracle measures a candidate against the shorter@@ -415,6 +423,7 @@ fn harness(args: &HarnessArgs) -> Result<(), Box<dyn Error>> {// later variant extends an earlier one. Feeding it a sibling would reject the// fallback for a constant gain of zero, which is true and meaningless.// One candidate's toolchain failure must not kill the other nineteen.+ let against = accepted.len();let verdict = match bench.verify(source, label, None, &accepted) {Ok(verdict) => verdict,Err(err) => {@@ -424,26 +433,69 @@ fn harness(args: &HarnessArgs) -> Result<(), Box<dyn Error>> {};match &verdict.outcome {Ok(reached) => {+ let novel = reached.novel_against(&accepted);accepted.absorb(reached);- report_rejections(&rejected);- return promote(+ promote(plan,candidate.name.as_str(),&args.out,plans.len(),Some(&verdict),- );+ against,+ )?;+ survivors.push(Survivor {+ name: candidate.name.clone(),+ edges: reached.len(),+ novel,+ judged_against: against,+ });+ // Variants of ONE candidate are alternatives, not distinct harnesses:+ // they call the same entry point with more or less of its context+ // populated. Taking the first that survives and moving on is what+ // makes the accumulated set a set of ENTRY POINTS.+ break;}Err(rejection) => rejected.push(format!(" {label} - {rejection}")),}}}- println!("no candidate in the top {} survived the oracles:", args.top);- for line in &rejected {- println!("{line}");+ report_rejections(&rejected);+ if survivors.is_empty() {+ println!("no candidate in the top {} survived the oracles:", args.top);+ return Err("no harness synthesized".into());+ }+ report_survivors(&survivors, accepted.len());+ Ok(())+}++// What the global-novelty oracle actually decided, per survivor. `judged_against` is the+// size of the accepted set at the moment this candidate was judged: 0 means it was first+// and the oracle could only reject a harness reaching nothing, which is the weak form B51+// described. Anything above 0 is the oracle discriminating for real.+struct Survivor {+ name: String,+ edges: usize,+ novel: usize,+ judged_against: usize,+}++fn report_survivors(survivors: &[Survivor], total: usize) {+ println!(+ "\n{} harness(es) survived the oracles, covering {total} edges in total:",+ survivors.len()+ );+ for survivor in survivors {+ let novelty = if survivor.judged_against == 0 {+ "first accepted, nothing to be novel against".to_owned()+ } else {+ format!(+ "{} edge(s) novel against the {} already accepted",+ survivor.novel, survivor.judged_against+ )+ };+ println!(" {} - {} edges, {novelty}", survivor.name, survivor.edges);}- Err("no harness synthesized".into())}// The ladder RESCORES nothing. It reorders, and inside each group the surface's own rank@@ -549,10 +601,7 @@ fn report_rejections(rejected: &[String]) {if rejected.is_empty() {return;}- println!(- "{} higher-ranked candidate(s) did not survive:",- rejected.len()- );+ println!("{} candidate(s) did not survive:", rejected.len());for line in rejected {println!("{line}");}@@ -564,6 +613,7 @@ fn promote(out: &std::path::Path,variants: usize,verdict: Option<&Verdict>,+ judged_against: usize,) -> Result<(), Box<dyn Error>> {// Rendered again rather than copied so the file header names the file it is in.let filename = format!("{name}.c");@@ -584,27 +634,41 @@ fn promote(observation.map_or(0, |o| o.valid.len()),verdict.binary.display());- // Naming the oracles that actually ran, because two of D4's four cannot- // discriminate in a single-harness run and saying "all four" was a lie.- println!("oracles run: {}", oracles_run(invalid > 0));+ // Naming the oracles that actually ran, because saying "all four" was a lie+ // while two of D4's four could not discriminate. Oracle 4 discriminates from+ // the SECOND acceptance onward, so what it did is a property of THIS verdict+ // rather than of the build, and it is reported per harness.+ println!(+ "oracles run: {}",+ oracles_run(invalid > 0, judged_against > 0)+ );}None => println!("{UNVERIFIED_BANNER}"),}Ok(())}-fn oracles_run(differential: bool) -> String {+fn oracles_run(differential: bool, novelty_discriminated: bool) -> String {let mut ran = vec!["1 compilation", "2 execution", "3a inter-seed divergence"];if differential {ran.push("3c valid-vs-invalid differential");}+ if novelty_discriminated {+ ran.push("4 global novelty");+ }let mut line = ran.join(", ");if !differential {line.push_str("; 3c SKIPPED, no --invalid-seeds given");}+ if !novelty_discriminated {+ line.push_str(+ "; 4 global novelty could only reject a harness reaching nothing - this is the \+ first acceptance, so there was no accepted set to be novel against",+ );+ }line.push_str(- "; 3b non-linear delta needs a call-sequence parent and 4 global novelty needs an \- already-accepted harness, neither of which exists in a single-harness run",+ "; 3b non-linear delta needs a call-sequence parent, which a single-call harness \+ does not have",);line}diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m4-gate.sh b/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m4-gate.shindex 7dc9b41a..dc174e1d 100755--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m4-gate.sh+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m4-gate.sh@@ -103,8 +103,12 @@ rm -rf "$SYNTH"mapfile -d '' HARNESS_FLAGS < <(oracle_flags)"$LISDEX_BIN" harness "$REPO" --out "$SYNTH" --top "$TOP" "${HARNESS_FLAGS[@]}" \| tee "$GATE/synth.log"-ENTRY="$(find "$SYNTH" -maxdepth 1 -name '*.c' | head -1)"-[ -n "$ENTRY" ] || die "no harness was synthesized"+# lisdex emits the SET of survivors now, so `find | head -1` would pick whichever name the+# filesystem happened to return first. The log lists promotions in RANK order, so the first+# `synthesized` line is the top-ranked harness and that is the one this gate fuzzes.+ENTRY_FILE="$(grep -m1 '^synthesized ' "$GATE/synth.log" | awk '{print $2}')"+ENTRY="$SYNTH/$ENTRY_FILE"+[ -n "$ENTRY_FILE" ] && [ -f "$ENTRY" ] || die "no harness was synthesized"ENTRY_NAME="$(basename "$ENTRY" .c)"if grep -q '^oracles run:' "$GATE/synth.log"; thenpass "lisdex accepted $ENTRY_NAME through its own oracle layer"@@ -118,6 +122,27 @@ elsefail "oracle 3c did not run - the gate must exercise the differential"fi+# B51(a). The run keeps every survivor instead of returning at the first acceptance, which+# is the only way oracle 4 ever has an accepted set to be novel AGAINST. Ties the summary to+# the artifacts on disk, so a run that reports a set it did not write fails here. libpng+# yields exactly one survivor (its other planning candidates are 4-byte header readers that+# oracle 3a rejects), so the REJECTING direction of oracle 4 is measured on libwebp - see+# doc 02 D31 - and asserted by the judge_global_novelty unit tests in stage 1.+SUMMARY="$(grep -m1 -oE '^[0-9]+ harness\(es\) survived' "$GATE/synth.log" | grep -oE '^[0-9]+')"+WRITTEN="$(find "$SYNTH" -maxdepth 1 -name '*.c' | wc -l)"+if [ -n "$SUMMARY" ] && [ "$SUMMARY" -eq "$WRITTEN" ] && [ "$WRITTEN" -ge 1 ]; then+ pass "the survivor set is reported and matches the $WRITTEN harness(es) written"+else+ fail "survivor summary '$SUMMARY' does not match $WRITTEN harness(es) on disk"+fi+# The honesty line: with one survivor, oracle 4 could NOT discriminate and must say so+# rather than claim it ran.+if grep -q '4 global novelty could only reject a harness reaching nothing' "$GATE/synth.log"; then+ pass "a single-survivor run says oracle 4 could not discriminate rather than claiming it ran"+else+ fail "the oracle report overclaims global novelty on a first acceptance"+fi+if grep -q 'LLVMFuzzerTestOneInput' "$ENTRY"; thenpass "harness defines LLVMFuzzerTestOneInput"else