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 πŸ‘‡

test(lisdex): B15 - the executable-only refusal had shipped with no control

CarterPerez-dev0d13cce6f5c2
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-build/src/ladder.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-build/src/ladder.rs
index d4edeeff..48daae30 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-build/src/ladder.rs
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-build/src/ladder.rs
@@ -705,6 +705,7 @@ pub fn build(
#[cfg(test)]
mod tests {
use super::*;
+ use crate::artifact::ArtifactKind;
use lisdex_ingest::detect::{Evidence, Marker};
fn detection(candidates: Vec<BuildSystem>, markers: &[(Marker, &str)]) -> Detection {
@@ -728,6 +729,61 @@ mod tests {
dir
}
+ fn elf_file(dir: &Path, name: &str) -> PathBuf {
+ use std::os::unix::fs::PermissionsExt;
+ let path = dir.join(name);
+ let mut body = vec![0x7f, b'E', b'L', b'F'];
+ body.resize(64, 0);
+ std::fs::write(&path, body).unwrap();
+ let mut perms = std::fs::metadata(&path).unwrap().permissions();
+ perms.set_mode(0o755);
+ std::fs::set_permissions(&path, perms).unwrap();
+ path
+ }
+
+ #[test]
+ fn a_build_producing_only_executables_is_short_of_what_can_be_verified() {
+ let dir = scratch("executable-only");
+ elf_file(&dir, "tool");
+
+ let (found, _, _, shortfalls) =
+ inspect_artifacts(std::slice::from_ref(&dir), &Requirements::library()).unwrap();
+
+ assert_eq!(
+ found.len(),
+ 1,
+ "the fixture must produce exactly one artifact"
+ );
+ assert_eq!(
+ found[0].kind,
+ ArtifactKind::Executable,
+ "the fixture must isolate the signal: an executable and no library at all"
+ );
+ assert!(
+ shortfalls
+ .iter()
+ .any(|s| s.contains("no library artifacts were produced")),
+ "the AFL++ runtime defines the sanitizer and coverage symbols itself, so an executable-only build looks instrumented whether or not the TARGET's code was instrumented; reporting it verified is how a campaign fuzzes an uninstrumented library at full speed and finds nothing"
+ );
+ }
+
+ #[test]
+ fn a_build_producing_a_library_is_not_refused_by_that_rule() {
+ let dir = scratch("has-library");
+ elf_file(&dir, "tool");
+ std::fs::write(dir.join("libfoo.so"), [0x7f, b'E', b'L', b'F', 0, 0, 0, 0]).unwrap();
+
+ let (_, _, _, shortfalls) =
+ inspect_artifacts(std::slice::from_ref(&dir), &Requirements::library()).unwrap();
+
+ assert!(
+ !shortfalls
+ .iter()
+ .any(|s| s.contains("no library artifacts were produced")),
+ "a rule that refuses every build regardless of what it produced would satisfy the test above while being useless"
+ );
+ }
+
#[test]
fn tiers_are_ordered_cheapest_first() {
assert_eq!(TIERS[0], Tier::FlagInjection);