From d960ba658ecd14514b8b6a604b247cec649dd822 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Tue, 6 Oct 2026 08:49:39 +0000 Subject: [PATCH] feat(malware): ClamAV stage, committed-binary inventory, unchanged rescans skipped (#465) (#488) --- compliance-agent/src/agent.rs | 7 +- compliance-agent/src/lifecycle.rs | 41 +- compliance-agent/src/llm/triage.rs | 20 +- compliance-agent/src/pipeline/binaries.rs | 438 +++++++++++++++++ compliance-agent/src/pipeline/change.rs | 117 +++++ compliance-agent/src/pipeline/clamav.rs | 462 ++++++++++++++++++ compliance-agent/src/pipeline/mod.rs | 3 + compliance-agent/src/pipeline/orchestrator.rs | 151 +++++- compliance-agent/src/pipeline/plan.rs | 1 + compliance-agent/src/pipeline/repo_view.rs | 3 + compliance-core/src/models/mod.rs | 2 +- compliance-core/src/models/onboarding.rs | 19 + compliance-core/src/models/scan.rs | 12 + .../src/components/scan_runs.rs | 4 + compliance-dashboard/src/i18n/texts.rs | 37 +- docs/guide/findings.md | 4 +- docs/guide/scanning.md | 11 +- docs/reference/tools.md | 28 ++ .../release/staging-test-plan-after-v0.4.5.md | 50 ++ .../baselines/archive-order-intake-tgz.json | 4 +- .../baselines/archive-order-intake.json | 4 +- .../baselines/firmware-zephyr-example.json | 4 +- fixtures/nightly/baselines/fw-arduino.json | 4 +- .../nightly/baselines/fw-c-sensor-node.json | 2 + .../nightly/baselines/fw-cargo-embedded.json | 1 + fixtures/nightly/baselines/fw-cmake.json | 4 +- .../nightly/baselines/fw-embedded-libs.json | 1 + fixtures/nightly/baselines/fw-espidf.json | 4 +- .../nightly/baselines/fw-freertos-cmake.json | 4 +- .../baselines/fw-freertos-lostbuild.json | 4 +- .../fw-make-onboarded-as-service.json | 4 +- fixtures/nightly/baselines/fw-make.json | 4 +- fixtures/nightly/baselines/fw-platformio.json | 4 +- .../nightly/baselines/fw-yocto-layer.json | 3 +- .../baselines/fw-zephyr-example-pinned.json | 4 +- .../nightly/baselines/fw-zephyr-pinned.json | 4 +- .../nightly/baselines/git-cra-vuln-demo.json | 4 +- fixtures/nightly/baselines/js-bun-binary.json | 1 + fixtures/nightly/baselines/js-bun.json | 4 +- .../nightly/baselines/js-no-lockfile.json | 1 + .../nightly/baselines/js-npm-lock-v3.json | 4 +- fixtures/nightly/baselines/js-pnpm.json | 4 +- fixtures/nightly/baselines/js-yarn-berry.json | 4 +- .../nightly/baselines/js-yarn-classic.json | 4 +- .../mobile-android-gradle-catalog.json | 1 + .../baselines/mobile-android-gradle-lock.json | 4 +- .../baselines/mobile-android-insecure.json | 1 + .../mobile-android-legacy-groovy.json | 1 + .../nightly/baselines/mobile-flutter.json | 1 + .../baselines/mobile-ios-app-settings.json | 4 +- .../baselines/mobile-ios-carthage-legacy.json | 3 +- .../baselines/mobile-ios-cocoapods.json | 3 +- .../baselines/mobile-ios-insecure.json | 4 +- .../baselines/mobile-ios-spm-unlocked.json | 1 + .../baselines/mobile-ios-spm-xcode.json | 4 +- .../baselines/mobile-legacy-adt-unity.json | 1 + .../mobile-public-android-nowinandroid.json | 1 + .../baselines/mobile-public-ios-swiftui.json | 1 + .../baselines/mobile-react-native.json | 1 + .../baselines/mobile-unity-mobile.json | 1 + .../c-sensor-node/Prebuilt/bootloader.hex | 129 +++++ fixtures/nightly/targets.json | 5 +- 62 files changed, 1600 insertions(+), 61 deletions(-) create mode 100644 compliance-agent/src/pipeline/binaries.rs create mode 100644 compliance-agent/src/pipeline/change.rs create mode 100644 compliance-agent/src/pipeline/clamav.rs create mode 100644 fixtures/nightly/firmware/c-sensor-node/Prebuilt/bootloader.hex diff --git a/compliance-agent/src/agent.rs b/compliance-agent/src/agent.rs index 56f51ca..450b199 100644 --- a/compliance-agent/src/agent.rs +++ b/compliance-agent/src/agent.rs @@ -202,9 +202,10 @@ impl ComplianceAgent { PipelineOrchestrator::new(self.config.clone(), tenant_id, db.clone(), self.llm.clone()) .with_nuget_license_cache(self.nuget_license_cache.clone()); let started = chrono::Utc::now(); - orchestrator.run_target(target_id, trigger.clone()).await?; - // Support's scans are ours, not the customer's usage. - if trigger != compliance_core::models::ScanTrigger::Support { + let scanned = orchestrator.run_target(target_id, trigger.clone()).await?; + // Support's scans are ours, not the customer's usage; a scheduled scan + // skipped because nothing changed scanned nothing (#465). + if scanned && trigger != compliance_core::models::ScanTrigger::Support { self.emit_usage( tenant_id, "scan.completed", diff --git a/compliance-agent/src/lifecycle.rs b/compliance-agent/src/lifecycle.rs index a76e57d..d901848 100644 --- a/compliance-agent/src/lifecycle.rs +++ b/compliance-agent/src/lifecycle.rs @@ -17,7 +17,7 @@ use chrono::{DateTime, Utc}; use mongodb::bson::{doc, DateTime as BsonDateTime}; use tokio::time::MissedTickBehavior; -use compliance_core::models::RunErrorCode; +use compliance_core::models::{RunErrorCode, ScanTrigger}; use compliance_core::shutdown::Shutdown; use crate::database::{Database, DatabasePool}; @@ -179,23 +179,17 @@ pub async fn resume_interrupted_scans( continue; } }; - for target_id in targets { + for (target_id, trigger) in targets { tracing::info!( tenant_id, target_id, + ?trigger, "starting a scan interrupted by the restart again" ); let agent = agent.clone(); let tenant = tenant_id.clone(); tokio::spawn(async move { - if let Err(e) = agent - .run_target_scan( - &tenant, - &target_id, - compliance_core::models::ScanTrigger::Scheduled, - ) - .await - { + if let Err(e) = agent.run_target_scan(&tenant, &target_id, trigger).await { tracing::warn!(tenant_id = tenant, target_id, "resumed scan failed: {e}"); } }); @@ -211,7 +205,7 @@ pub async fn resume_interrupted_scans( async fn targets_to_resume( db: &Database, closed_at: DateTime, -) -> Result, AgentError> { +) -> Result, AgentError> { let closed = BsonDateTime::from_chrono(closed_at); let window = BsonDateTime::from_chrono(closed_at - chrono::Duration::hours(RESUME_WINDOW_HOURS)); @@ -248,7 +242,14 @@ async fn targets_to_resume( .count_documents(doc! { "_id": oid, "archived_at": { "$exists": false } }) .await?; if active > 0 { - out.push(id.to_string()); + // Resumed as it was started: a scan a person started runs even when + // nothing changed since the last completed one (#465). + let trigger = db + .scan_runs() + .find_one(doc! { "repo_id": id, "status": "interrupted", "completed_at": closed }) + .await? + .map_or(ScanTrigger::Scheduled, |run| run.trigger); + out.push((id.to_string(), trigger)); } } Ok(out) @@ -329,7 +330,7 @@ mod tests { #[tokio::test] async fn only_scans_this_start_interrupted_are_resumed_once() { - use compliance_core::models::{OnboardedTarget, ScanRun, ScanTrigger, TargetType}; + use compliance_core::models::{OnboardedTarget, ScanRun, TargetType}; let uri = std::env::var("TEST_MONGODB_URI") .unwrap_or_else(|_| "mongodb://root:example@localhost:27017/?authSource=admin".into()); @@ -365,9 +366,14 @@ mod tests { let earlier_only = insert(target("earlier-only")).await; // Arrange: runs left open, plus one interrupted an hour ago. - for id in [&resumes, &looping, &archived] { + // The scan to resume was started by a person. + for (id, trigger) in [ + (&resumes, ScanTrigger::Manual), + (&looping, ScanTrigger::Scheduled), + (&archived, ScanTrigger::Scheduled), + ] { db.scan_runs() - .insert_one(ScanRun::new(id.clone(), ScanTrigger::Scheduled)) + .insert_one(ScanRun::new(id.clone(), trigger)) .await .unwrap(); } @@ -382,8 +388,9 @@ mod tests { close_open_runs(&db, now).await.unwrap(); let resumed = targets_to_resume(&db, now).await.unwrap(); - // Assert: only the target interrupted once, by this start, and active. - assert_eq!(resumed, [resumes]); + // Assert: only the target interrupted once, by this start, and active, + // resumed as a person's scan, so it runs even if nothing changed. + assert_eq!(resumed, [(resumes, ScanTrigger::Manual)]); pool.drop_tenant("resume").await.ok(); } diff --git a/compliance-agent/src/llm/triage.rs b/compliance-agent/src/llm/triage.rs index 14d8d75..93b604b 100644 --- a/compliance-agent/src/llm/triage.rs +++ b/compliance-agent/src/llm/triage.rs @@ -108,6 +108,9 @@ pub enum SkipReason { OverCap, /// The model gave no readable verdict, also when asked again. NoAnswer, + /// A malware signature in a binary file (#465): there is no code for the + /// model to read, and a person decides. + Binary, } impl SkipReason { @@ -121,6 +124,10 @@ impl SkipReason { Self::NoAnswer => { "skipped: no answer (the model gave no verdict, also when asked again)" } + Self::Binary => { + "skipped: binary (a malware signature in a file the model cannot read; a \ + person decides)" + } } } } @@ -154,6 +161,8 @@ pub struct TriageSummary { pub low_confidence: usize, pub skipped_low: usize, pub skipped_over_cap: usize, + /// Malware signatures in binary files, which a person decides. + pub skipped_binary: usize, pub skipped_no_answer: usize, /// Critical and high findings among `skipped_no_answer`. pub skipped_no_answer_severe: usize, @@ -169,7 +178,7 @@ impl TriageSummary { /// Distinct findings without a verdict. pub fn skipped(&self) -> usize { - self.skipped_low + self.skipped_over_cap + self.skipped_no_answer + self.skipped_low + self.skipped_over_cap + self.skipped_binary + self.skipped_no_answer } fn count(&mut self, outcome: Outcome) { @@ -186,6 +195,7 @@ impl TriageSummary { match reason { SkipReason::Low => self.skipped_low += 1, SkipReason::OverCap => self.skipped_over_cap += 1, + SkipReason::Binary => self.skipped_binary += 1, SkipReason::NoAnswer => { self.skipped_no_answer += 1; if *severity >= Severity::High { @@ -202,7 +212,8 @@ impl fmt::Display for TriageSummary { f, "LLM triage: {} findings ({} distinct); triaged {} (confirmed {}, downgraded {}, \ upgraded {}, dismissed {} and low confidence {} kept as needs review); skipped {} \ - (low {}, over cap {}, no answer {} of which {} critical/high); {} LLM calls", + (low {}, over cap {}, binary {}, no answer {} of which {} critical/high); {} LLM \ + calls", self.findings, self.unique, self.triaged(), @@ -214,6 +225,7 @@ impl fmt::Display for TriageSummary { self.skipped(), self.skipped_low, self.skipped_over_cap, + self.skipped_binary, self.skipped_no_answer, self.skipped_no_answer_severe, self.calls, @@ -231,7 +243,9 @@ fn triage_selection( let mut skipped = Vec::new(); let mut sent: Vec = Vec::with_capacity(distinct.len()); for &i in distinct { - if findings[i].severity <= Severity::Low { + if findings[i].scan_type == compliance_core::models::ScanType::Malware { + skipped.push((i, SkipReason::Binary)); + } else if findings[i].severity <= Severity::Low { skipped.push((i, SkipReason::Low)); } else { sent.push(i); diff --git a/compliance-agent/src/pipeline/binaries.rs b/compliance-agent/src/pipeline/binaries.rs new file mode 100644 index 0000000..35355e6 --- /dev/null +++ b/compliance-agent/src/pipeline/binaries.rs @@ -0,0 +1,438 @@ +//! The binaries committed to a tree (#465): executables, libraries and +//! firmware images that arrive as built files instead of being built from +//! the sources next to them. +//! +//! Each is an informational finding with its format, architecture, size and +//! SHA-256, and for a Windows file its version resource (product, version, +//! company, original file name): what the CRA's SBOM and supply-chain +//! requirements need to know about a component nobody builds here. A file +//! that changes is reported anew (the hash is part of its identity), so the +//! old finding closes. When a repository holds many, they become one finding +//! listing them (#464). +//! +//! Files are recognised by their first bytes, not their extension: PE +//! (`MZ` with a `PE` header), ELF, Mach-O, and firmware images (`.bin`, +//! `.hex`, `.srec`/`.s19`, `.uf2`, `.dfu`) of at least [`MIN_IMAGE_BYTES`]. +//! Java class files share Mach-O's fat magic and are told apart. + +use std::io::Read; +use std::path::Path; + +use compliance_core::models::{Finding, ScanType, Severity}; +use sha2::{Digest, Sha256}; + +use crate::pipeline::dedup; + +/// The scanner name of these findings. +pub const SCANNER: &str = "binary-inventory"; + +/// The rule of every finding. +const RULE: &str = "committed-binary"; + +/// How deep the tree is walked. +const MAX_DEPTH: usize = 16; + +/// Directories never listed: version control and dependency caches, whose +/// binaries the SBOM covers or nobody committed. +const SKIPPED_DIRS: &[&str] = &[".git", "node_modules", ".gradle", "Pods"]; + +/// A firmware image smaller than this is a test vector or a resource. +const MIN_IMAGE_BYTES: u64 = 1024; + +/// How much of a PE file is searched for its version resource. +const MAX_PE_READ: u64 = 32 * 1024 * 1024; + +/// What a committed binary is. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Binary { + /// Relative to the tree, `/`-separated. + pub path: String, + /// `PE32+ x86-64`, `PE32 i386 (.NET)`, `ELF 32-bit ARM`, `Mach-O`, + /// `firmware image (Intel HEX)`. + pub format: String, + pub size: u64, + pub sha256: String, + /// The version resource of a Windows file: `ProductName`, + /// `FileVersion`, `CompanyName`, `OriginalFilename`, as present. + pub version_info: Vec<(&'static str, String)>, +} + +/// The committed binaries under `root`. +/// +/// # Arguments +/// +/// * `root` - the checked-out or unpacked tree +pub fn committed_binaries(root: &Path) -> Vec { + let entries = walkdir::WalkDir::new(root) + .min_depth(1) + .max_depth(MAX_DEPTH) + .sort_by_file_name() + .into_iter() + .filter_entry(|e| { + !(e.file_type().is_dir() + && SKIPPED_DIRS.contains(&e.file_name().to_string_lossy().as_ref())) + }) + .filter_map(Result::ok) + .filter(|e| e.file_type().is_file()); + entries + .filter_map(|entry| describe(root, entry.path())) + .collect() +} + +/// The binary at `file`, or `None` when it is not one. +fn describe(root: &Path, file: &Path) -> Option { + let size = std::fs::metadata(file).ok()?.len(); + let mut head = [0_u8; 64]; + let read = std::fs::File::open(file).ok()?.read(&mut head).ok()?; + let head = &head[..read]; + let name = file.file_name()?.to_string_lossy().to_ascii_lowercase(); + let (format, version_info) = if head.starts_with(b"MZ") { + let bytes = read_prefix(file, MAX_PE_READ)?; + (pe_format(&bytes)?, version_strings(&bytes)) + } else if head.starts_with(b"\x7fELF") { + (elf_format(head), Vec::new()) + } else if macho(head) { + ("Mach-O".to_string(), Vec::new()) + } else { + (image_format(&name, head, size)?, Vec::new()) + }; + Some(Binary { + path: file + .strip_prefix(root) + .unwrap_or(file) + .to_string_lossy() + .replace('\\', "/"), + format, + size, + sha256: sha256_of(file)?, + version_info, + }) +} + +/// Up to `limit` bytes of `file`. +fn read_prefix(file: &Path, limit: u64) -> Option> { + let mut bytes = Vec::new(); + std::fs::File::open(file) + .ok()? + .take(limit) + .read_to_end(&mut bytes) + .ok()?; + Some(bytes) +} + +/// The SHA-256 of `file`, hex. +fn sha256_of(file: &Path) -> Option { + let mut input = std::fs::File::open(file).ok()?; + let mut hasher = Sha256::new(); + std::io::copy(&mut input, &mut hasher).ok()?; + Some(hex::encode(hasher.finalize())) +} + +/// A little-endian `u16` at `at`. +fn u16_at(bytes: &[u8], at: usize) -> Option { + Some(u16::from_le_bytes(bytes.get(at..at + 2)?.try_into().ok()?)) +} + +/// A little-endian `u32` at `at`. +fn u32_at(bytes: &[u8], at: usize) -> Option { + Some(u32::from_le_bytes(bytes.get(at..at + 4)?.try_into().ok()?)) +} + +/// The format of a PE file (`PE32+ x86-64 (.NET)`), or `None` when the `MZ` +/// header leads to no PE header (a DOS executable, a text file). +fn pe_format(bytes: &[u8]) -> Option { + let pe = usize::try_from(u32_at(bytes, 0x3c)?).ok()?; + if bytes.get(pe..pe + 4)? != b"PE\0\0" { + return None; + } + let machine = match u16_at(bytes, pe + 4)? { + 0x014c => "i386", + 0x8664 => "x86-64", + 0x01c0 | 0x01c4 => "ARM", + 0xaa64 => "ARM64", + _ => "other CPU", + }; + let optional = pe + 24; + let (kind, directories) = match u16_at(bytes, optional)? { + 0x10b => ("PE32", optional + 96), + 0x20b => ("PE32+", optional + 112), + _ => return Some(format!("PE {machine}")), + }; + // Data directory 14 is the CLR header of a .NET assembly. + let clr = u32_at(bytes, directories + 14 * 8).unwrap_or(0); + let dotnet = if clr != 0 { " (.NET)" } else { "" }; + Some(format!("{kind} {machine}{dotnet}")) +} + +/// The format of an ELF file (`ELF 32-bit ARM`). +fn elf_format(head: &[u8]) -> String { + let class = match head.get(4) { + Some(2) => "64-bit", + _ => "32-bit", + }; + let little = head.get(5) != Some(&2); + let machine = head + .get(18..20) + .and_then(|m| <[u8; 2]>::try_from(m).ok()) + .map(|m| { + if little { + u16::from_le_bytes(m) + } else { + u16::from_be_bytes(m) + } + }); + let machine = match machine { + Some(3) => "i386", + Some(8) => "MIPS", + Some(20) => "PowerPC", + Some(40) => "ARM", + Some(62) => "x86-64", + Some(94) => "Xtensa", + Some(183) => "AArch64", + Some(243) => "RISC-V", + _ => "other CPU", + }; + format!("ELF {class} {machine}") +} + +/// Whether `head` starts a Mach-O file. The fat magic `CAFEBABE` also starts +/// every Java class file; there the next word is a class file version (45 or +/// more), in a fat binary the number of architectures (a handful). +fn macho(head: &[u8]) -> bool { + match head.get(0..4) { + Some([0xfe, 0xed, 0xfa, 0xce | 0xcf]) | Some([0xce | 0xcf, 0xfa, 0xed, 0xfe]) => true, + Some([0xca, 0xfe, 0xba, 0xbe]) => { + let count = head + .get(4..8) + .and_then(|b| <[u8; 4]>::try_from(b).ok()) + .map(u32::from_be_bytes); + count.is_some_and(|n| (1..=20).contains(&n)) + } + _ => false, + } +} + +/// The format of a firmware image, by its name and first bytes. +fn image_format(name: &str, head: &[u8], size: u64) -> Option { + if size < MIN_IMAGE_BYTES { + return None; + } + let ext = name.rsplit_once('.').map(|(_, e)| e)?; + match ext { + "hex" | "ihex" if head.first() == Some(&b':') => { + Some("firmware image (Intel HEX)".to_string()) + } + "srec" | "s19" | "s28" | "s37" if head.first() == Some(&b'S') => { + Some("firmware image (Motorola S-record)".to_string()) + } + "uf2" if head.starts_with(b"UF2\n") => Some("firmware image (UF2)".to_string()), + "dfu" => Some("firmware image (DFU)".to_string()), + // A raw image: binary content, not text that happens to end in .bin. + "bin" | "img" if head.iter().any(|b| *b == 0 || *b > 0x7f) => { + Some("firmware image (raw)".to_string()) + } + _ => None, + } +} + +/// The version resource strings of a Windows file. They are stored as +/// UTF-16 key/value pairs; the key is found, and the value read after the +/// padding that aligns it to four bytes. +fn version_strings(bytes: &[u8]) -> Vec<(&'static str, String)> { + const KEYS: [&str; 4] = [ + "ProductName", + "FileVersion", + "CompanyName", + "OriginalFilename", + ]; + KEYS.iter() + .filter_map(|key| Some((*key, utf16_value(bytes, key)?))) + .collect() +} + +/// The value after the UTF-16 key `key` in a version resource. +fn utf16_value(bytes: &[u8], key: &str) -> Option { + let needle: Vec = key + .encode_utf16() + .chain(std::iter::once(0)) + .flat_map(u16::to_le_bytes) + .collect(); + let at = bytes + .windows(needle.len()) + .position(|w| w == needle.as_slice())?; + let mut i = at + needle.len(); + // Padding to the next 4-byte boundary (relative to the file, as the + // resource itself is 4-byte aligned). + while !i.is_multiple_of(4) || u16_at(bytes, i) == Some(0) { + i += 2; + if i > at + needle.len() + 8 { + return None; + } + } + let mut value = Vec::new(); + while let Some(unit) = u16_at(bytes, i) { + if unit == 0 || value.len() >= 128 { + break; + } + value.push(unit); + i += 2; + } + let text = String::from_utf16(&value).ok()?; + let text = text.trim().to_string(); + (!text.is_empty()).then_some(text) +} + +/// The finding for a committed binary. +pub fn into_finding(repo_id: &str, binary: &Binary) -> Finding { + let file = binary.path.rsplit('/').next().unwrap_or(&binary.path); + let mut description = format!( + "{} is committed as a built file: {}, {} bytes, SHA-256 {}.", + binary.path, binary.format, binary.size, binary.sha256 + ); + for (key, value) in &binary.version_info { + description.push_str(&format!("\n{key}: {value}")); + } + description.push_str( + "\n\nA component nobody builds here belongs in the SBOM with its source, version and \ + licence, and its updates must be tracked like any other dependency.", + ); + let mut finding = Finding::new( + repo_id.to_string(), + dedup::compute_fingerprint(&[repo_id, RULE, &binary.path, &binary.sha256]), + SCANNER.to_string(), + ScanType::Malware, + format!("Committed binary {file} ({})", binary.format), + description, + Severity::Info, + ); + finding.rule_id = Some(RULE.to_string()); + finding.file_path = Some(binary.path.clone()); + finding.remediation = Some( + "Record where the file comes from (vendor, version, licence) and check it against the \ + vendor's published hash; prefer fetching it through a package manager or building it \ + from source, so the SBOM lists it." + .to_string(), + ); + finding +} + +#[cfg(test)] +#[allow(clippy::expect_used, clippy::unwrap_used)] +mod tests { + use super::*; + + /// A minimal PE32+ x86-64 file with a CLR header and a version resource. + fn pe(dotnet: bool) -> Vec { + let mut bytes = vec![0_u8; 0x400]; + bytes[0..2].copy_from_slice(b"MZ"); + bytes[0x3c..0x40].copy_from_slice(&0x80_u32.to_le_bytes()); + bytes[0x80..0x84].copy_from_slice(b"PE\0\0"); + bytes[0x84..0x86].copy_from_slice(&0x8664_u16.to_le_bytes()); + let optional = 0x80 + 24; + bytes[optional..optional + 2].copy_from_slice(&0x20b_u16.to_le_bytes()); + if dotnet { + let clr = optional + 112 + 14 * 8; + bytes[clr..clr + 4].copy_from_slice(&0x2008_u32.to_le_bytes()); + } + // "ProductName\0" then padding to 4 bytes, then "Pump Tools\0". + let mut resource: Vec = Vec::new(); + for (key, value) in [("ProductName", "Pump Tools"), ("FileVersion", "2.4.1.0")] { + let mut entry: Vec = key + .encode_utf16() + .chain(std::iter::once(0)) + .flat_map(u16::to_le_bytes) + .collect(); + while !entry.len().is_multiple_of(4) { + entry.push(0); + } + entry.extend( + value + .encode_utf16() + .chain(std::iter::once(0)) + .flat_map(u16::to_le_bytes), + ); + while !entry.len().is_multiple_of(4) { + entry.push(0); + } + resource.extend(entry); + } + bytes.extend(resource); + bytes + } + + fn tree(files: &[(&str, Vec)]) -> std::path::PathBuf { + let dir = std::env::temp_dir().join(format!("cs-binaries-{}", uuid::Uuid::new_v4())); + for (path, content) in files { + let full = dir.join(path); + std::fs::create_dir_all(full.parent().unwrap()).unwrap(); + std::fs::write(full, content).unwrap(); + } + dir + } + + #[test] + fn committed_binaries_are_found_by_their_bytes() { + let mut elf = vec![0x7f, b'E', b'L', b'F', 1, 1, 1, 0]; + elf.resize(64, 0); + elf[18] = 40; + let mut hex = b":10000000".to_vec(); + hex.resize(2048, b'0'); + let mut class = vec![0xca, 0xfe, 0xba, 0xbe, 0, 0, 0, 52]; + class.resize(64, 0); + let dir = tree(&[ + ("lib/Pump.Tools.dll", pe(true)), + ("lib/native.dll", pe(false)), + ("firmware/pump.elf", elf), + ("firmware/pump.hex", hex), + ("app/Main.class", class), + ("docs/notes.bin", b"plain text".repeat(200)), + ("README.md", b"MZ is a header".to_vec()), + (".git/objects/x", pe(false)), + ]); + let found: Vec<(String, String)> = committed_binaries(&dir) + .into_iter() + .map(|b| (b.path, b.format)) + .collect(); + let info = committed_binaries(&dir) + .into_iter() + .find(|b| b.path == "lib/Pump.Tools.dll") + .unwrap() + .version_info; + let _ = std::fs::remove_dir_all(&dir); + assert_eq!( + found, + [ + ("firmware/pump.elf".into(), "ELF 32-bit ARM".into()), + ( + "firmware/pump.hex".into(), + "firmware image (Intel HEX)".into() + ), + ("lib/Pump.Tools.dll".into(), "PE32+ x86-64 (.NET)".into()), + ("lib/native.dll".into(), "PE32+ x86-64".into()), + ] + ); + assert_eq!( + info, + [ + ("ProductName", "Pump Tools".to_string()), + ("FileVersion", "2.4.1.0".to_string()) + ] + ); + } + + #[test] + fn a_changed_binary_is_a_new_finding() { + let binary = |hash: &str| Binary { + path: "lib/x.dll".into(), + format: "PE32 i386".into(), + size: 10, + sha256: hash.into(), + version_info: Vec::new(), + }; + let a = into_finding("t", &binary("aa")); + let b = into_finding("t", &binary("bb")); + assert_ne!(a.fingerprint, b.fingerprint); + assert_eq!(a.severity, Severity::Info); + assert!(a.description.contains("SHA-256 aa")); + } +} diff --git a/compliance-agent/src/pipeline/change.rs b/compliance-agent/src/pipeline/change.rs new file mode 100644 index 0000000..75be80f --- /dev/null +++ b/compliance-agent/src/pipeline/change.rs @@ -0,0 +1,117 @@ +//! Whether a scheduled scan has anything new to scan (#465). +//! +//! A scheduled or webhook scan is skipped when the target is the same as at +//! its last completed scan and the same Prüfwerk build would run it: the +//! same commit (a git target), or the same uploaded files (their content +//! hashes). A new Prüfwerk release scans every target once, since new rules +//! can find more in unchanged code. A scan a person starts always runs, and +//! a target with a live URL always runs (the service it points at changes on +//! its own). The CVE monitor matches the stored SBOM against new advisories +//! independently of these scans. + +use compliance_core::models::{ArtifactKind, OnboardedTarget}; +use sha2::{Digest, Sha256}; + +use crate::api::handlers::platform::{BUILD_COMMIT, BUILD_VERSION}; + +/// The agent build that runs a scan, as stored in +/// [`compliance_core::models::LastScan::build`]. +pub fn build_id() -> String { + format!("{BUILD_VERSION}+{BUILD_COMMIT}") +} + +/// A digest of the files uploaded to `target` (every artifact but a git +/// repository or a live URL), from their ids and content hashes. `None` when +/// the target has none, or one without a content hash: then nothing tells an +/// unchanged upload from a changed one, and it is scanned. +pub fn upload_inputs(target: &OnboardedTarget) -> Option { + let mut parts: Vec<(&str, &str)> = Vec::new(); + for artifact in &target.artifacts { + if matches!(artifact.kind, ArtifactKind::GitRepo | ArtifactKind::LiveUrl) { + continue; + } + parts.push((artifact.id.as_str(), artifact.content_hash.as_deref()?)); + } + if parts.is_empty() { + return None; + } + parts.sort_unstable(); + let mut hasher = Sha256::new(); + for (id, hash) in parts { + hasher.update(id.as_bytes()); + hasher.update([0]); + hasher.update(hash.as_bytes()); + hasher.update([0]); + } + Some(hex::encode(hasher.finalize())) +} + +/// Whether a scheduled scan of `target`, which has no git repository, would +/// read the same uploaded files with the same build as its last completed +/// scan. +pub fn upload_unchanged(target: &OnboardedTarget) -> bool { + if target.live_url().is_some() { + return false; + } + let Some(last) = &target.last_scan else { + return false; + }; + last.build == build_id() && last.inputs.is_some() && last.inputs == upload_inputs(target) +} + +#[cfg(test)] +#[allow(clippy::expect_used)] +mod tests { + use super::*; + use compliance_core::models::{Artifact, LastScan, TargetType}; + + fn upload(id: &str, hash: Option<&str>) -> Artifact { + let mut a = Artifact::firmware_image(format!("{id}.zip")); + a.id = id.to_string(); + a.content_hash = hash.map(str::to_string); + a + } + + fn target(artifacts: Vec) -> OnboardedTarget { + let mut t = OnboardedTarget::new("t".into(), TargetType::FirmwareRtos); + t.artifacts = artifacts; + t + } + + #[test] + fn the_same_uploads_with_the_same_build_are_unchanged() { + let mut t = target(vec![upload("a", Some("h1")), upload("b", Some("h2"))]); + assert!(!upload_unchanged(&t), "never scanned"); + t.last_scan = Some(LastScan { + build: build_id(), + inputs: upload_inputs(&t), + }); + assert!(upload_unchanged(&t)); + // Order does not matter, the content does. + t.artifacts.reverse(); + assert!(upload_unchanged(&t)); + t.artifacts[0].content_hash = Some("h3".into()); + assert!(!upload_unchanged(&t)); + } + + #[test] + fn a_new_build_a_live_url_or_an_unhashed_upload_scans_again() { + let mut t = target(vec![upload("a", Some("h1"))]); + t.last_scan = Some(LastScan { + build: "0.0.1+old".into(), + inputs: upload_inputs(&t), + }); + assert!(!upload_unchanged(&t), "a new build scans once"); + + t.last_scan = Some(LastScan { + build: build_id(), + inputs: upload_inputs(&t), + }); + t.artifacts + .push(Artifact::live_url("https://pump.example.com")); + assert!(!upload_unchanged(&t), "a live service changes on its own"); + + let unhashed = target(vec![upload("a", None)]); + assert_eq!(upload_inputs(&unhashed), None); + } +} diff --git a/compliance-agent/src/pipeline/clamav.rs b/compliance-agent/src/pipeline/clamav.rs new file mode 100644 index 0000000..3122dd3 --- /dev/null +++ b/compliance-agent/src/pipeline/clamav.rs @@ -0,0 +1,462 @@ +//! Malware signatures over the scanned tree, with ClamAV (#465). +//! +//! The agent does not carry signatures itself: a clamd service beside it +//! (the official ClamAV image, its signatures updated daily by freshclam +//! inside it) is reached at `CLAMD_ADDRESS` (`host:port`), and each file is +//! streamed to it (`INSTREAM`), so the tree never has to be shared with it. +//! Without `CLAMD_ADDRESS` the stage is not run; when clamd cannot be +//! reached it is recorded as not completed, never as clean. +//! +//! A file found clean is remembered per tenant by its SHA-256 and the +//! signature version, so a rescan only streams files that changed or met new +//! signatures. A hit becomes a finding of high severity; heuristic signatures +//! (`Heuristics.*`, `*.Heuristic.*`, the ML-based `*.Malware.*` families) say +//! so, as they flag packers and obfuscators as often as malware and need a +//! person's review. + +use std::collections::HashSet; +use std::path::{Path, PathBuf}; +use std::time::Duration; + +use compliance_core::models::{Finding, ScanType, Severity}; +use futures_util::{StreamExt, TryStreamExt}; +use mongodb::bson::{doc, Document}; +use sha2::{Digest, Sha256}; +use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use tokio::net::TcpStream; + +use crate::database::Database; +use crate::pipeline::dedup; + +/// The scanner name of malware findings. +pub const SCANNER: &str = "clamav"; + +/// Where clamd listens (`clamav:3310`). +const ADDRESS_ENV: &str = "CLAMD_ADDRESS"; + +/// Files larger than this are not streamed: clamd refuses a stream above its +/// `StreamMaxLength`, which the stage sidecar sets to the same. +pub const MAX_FILE_BYTES: u64 = 64 * 1024 * 1024; + +/// How many files are streamed at once. +const CONCURRENCY: usize = 4; + +/// The size of one `INSTREAM` chunk. +const CHUNK: usize = 64 * 1024; + +/// How long connecting to clamd may take. +const CONNECT_TIMEOUT: Duration = Duration::from_secs(5); + +/// How long one file's scan may take (clamd's own limit is 120 s). +const SCAN_TIMEOUT: Duration = Duration::from_secs(150); + +/// The per-tenant collection of files found clean. +const CLEAN_CACHE: &str = "malware_clean_files"; + +/// Directories never scanned. +const SKIPPED_DIRS: &[&str] = &[".git"]; + +/// Why the stage did not complete. +#[derive(Debug, thiserror::Error)] +pub enum ClamavError { + #[error("clamd at {0} cannot be reached: {1}")] + Unreachable(String, std::io::Error), + #[error("clamd did not answer in time")] + Timeout, + #[error("clamd answered: {0}")] + Refused(String), + #[error("reading the tree failed: {0}")] + Io(#[from] std::io::Error), +} + +/// A clamd service. +#[derive(Debug, Clone)] +pub struct Clamd { + address: String, +} + +/// What a scan of a tree found. +#[derive(Debug, Default)] +pub struct MalwareScan { + /// One per signature hit. + pub findings: Vec, + /// The signature version the tree was scanned with. + pub signatures: String, + /// Files above [`MAX_FILE_BYTES`], relative to the tree, not scanned. + pub too_large: Vec, + /// How many files were streamed (the others were known clean). + pub streamed: usize, +} + +impl Clamd { + /// The clamd at `CLAMD_ADDRESS`, or `None` when it is not set. + pub fn from_env() -> Option { + std::env::var(ADDRESS_ENV) + .ok() + .map(|a| a.trim().to_string()) + .filter(|a| !a.is_empty()) + .map(|address| Self { address }) + } + + /// One command, its whole answer (clamd closes after a `z` command). + async fn ask(&self, command: &[u8]) -> Result { + let mut stream = self.connect().await?; + stream.write_all(command).await?; + read_answer(&mut stream).await + } + + async fn connect(&self) -> Result { + match tokio::time::timeout(CONNECT_TIMEOUT, TcpStream::connect(&self.address)).await { + Ok(Ok(stream)) => Ok(stream), + Ok(Err(e)) => Err(ClamavError::Unreachable(self.address.clone(), e)), + Err(_) => Err(ClamavError::Unreachable( + self.address.clone(), + std::io::Error::from(std::io::ErrorKind::TimedOut), + )), + } + } + + /// The engine and signature version (`1.5.4/28145`). + /// + /// # Errors + /// + /// clamd cannot be reached or does not answer. + pub async fn signatures(&self) -> Result { + let answer = self.ask(b"zVERSION\0").await?; + Ok(signature_version(&answer)) + } + + /// Stream `file` to clamd: the signature it matches, if any. + /// + /// # Errors + /// + /// The file cannot be read, or clamd cannot be reached or refuses it. + pub async fn scan_file(&self, file: &Path) -> Result, ClamavError> { + let scan = async { + let mut stream = self.connect().await?; + stream.write_all(b"zINSTREAM\0").await?; + let mut input = tokio::fs::File::open(file).await?; + let mut buffer = vec![0_u8; CHUNK]; + loop { + let read = input.read(&mut buffer).await?; + if read == 0 { + break; + } + let len = u32::try_from(read).unwrap_or(u32::MAX); + stream.write_all(&len.to_be_bytes()).await?; + stream.write_all(&buffer[..read]).await?; + } + stream.write_all(&0_u32.to_be_bytes()).await?; + let answer = read_answer(&mut stream).await?; + parse_scan_answer(&answer) + }; + tokio::time::timeout(SCAN_TIMEOUT, scan) + .await + .map_err(|_| ClamavError::Timeout)? + } + + /// Scan every file of the tree under `root` that is not known clean with + /// the current signatures. + /// + /// # Arguments + /// + /// * `db` - the tenant database, which keeps the files found clean + /// * `root` - the checked-out or unpacked tree + /// * `repo_id` - the target the findings belong to + /// + /// # Errors + /// + /// clamd cannot be reached, or fails on a file: the stage then counts as + /// not completed. + pub async fn scan_tree( + &self, + db: &Database, + root: &Path, + repo_id: &str, + ) -> Result { + let signatures = self.signatures().await?; + let tree = root.to_path_buf(); + let (files, too_large) = tokio::task::spawn_blocking(move || list_files(&tree)) + .await + .map_err(|e| ClamavError::Io(std::io::Error::other(e)))?; + let hashes: Vec<(PathBuf, String)> = futures_util::stream::iter(files) + .map(|file| async move { + let hash = hash_file(&file).await?; + Ok::<_, ClamavError>((file, hash)) + }) + .buffer_unordered(CONCURRENCY) + .try_collect() + .await?; + let known = known_clean(db, &signatures, &hashes).await; + let to_scan: Vec<(PathBuf, String)> = hashes + .into_iter() + .filter(|(_, hash)| !known.contains(hash)) + .collect(); + let streamed = to_scan.len(); + // Owned values in the futures: borrowed ones make the scan future + // not `Send` for every lifetime, which the spawned scan needs. + let results: Vec<(PathBuf, String, Option)> = futures_util::stream::iter(to_scan) + .map(|(file, hash)| { + let clamd = self.clone(); + async move { + let hit = clamd.scan_file(&file).await?; + Ok::<_, ClamavError>((file, hash, hit)) + } + }) + .buffer_unordered(CONCURRENCY) + .try_collect() + .await?; + let clean: Vec = results + .iter() + .filter(|(_, _, hit)| hit.is_none()) + .map(|(_, hash, _)| doc! { "_id": cache_key(hash, &signatures) }) + .collect(); + if !clean.is_empty() { + // Already-known keys fail one by one; the rest is stored. + let _ = db + .raw_collection(CLEAN_CACHE) + .insert_many(clean) + .ordered(false) + .await; + } + let mut findings: Vec = results + .iter() + .filter_map(|(file, hash, hit)| { + let signature = hit.as_deref()?; + Some(finding(root, repo_id, file, hash, signature)) + }) + .collect(); + findings.sort_by(|a, b| a.file_path.cmp(&b.file_path)); + Ok(MalwareScan { + findings, + signatures, + too_large, + streamed, + }) + } +} + +/// Read clamd's answer up to its terminating NUL. +async fn read_answer(stream: &mut TcpStream) -> Result { + let mut answer = Vec::new(); + stream.read_to_end(&mut answer).await?; + let text = String::from_utf8_lossy(&answer); + Ok(text.trim_end_matches(['\0', '\n']).to_string()) +} + +/// The signature version in a `VERSION` answer +/// (`ClamAV 1.5.4/28145/Tue Oct 6 06:26:12 2026` → `1.5.4/28145`). +fn signature_version(answer: &str) -> String { + let version = answer.trim().trim_start_matches("ClamAV ").trim(); + let mut parts = version.split('/'); + match (parts.next(), parts.next()) { + (Some(engine), Some(daily)) => format!("{engine}/{daily}"), + _ => version.to_string(), + } +} + +/// The answer to `INSTREAM`: `stream: OK`, `stream: FOUND`, or an +/// error. +fn parse_scan_answer(answer: &str) -> Result, ClamavError> { + let result = answer.strip_prefix("stream:").unwrap_or(answer).trim(); + if result == "OK" { + return Ok(None); + } + if let Some(signature) = result.strip_suffix(" FOUND") { + return Ok(Some(signature.trim().to_string())); + } + Err(ClamavError::Refused(result.to_string())) +} + +/// Whether a signature is a heuristic that needs a person's review. +fn heuristic(signature: &str) -> bool { + let lower = signature.to_ascii_lowercase(); + lower.starts_with("heuristics.") + || lower.contains(".heuristic.") + || lower.starts_with("pua.") + || lower.contains(".malware.") +} + +/// The files under `root` to scan, and those too large to (relative). +fn list_files(root: &Path) -> (Vec, Vec) { + let mut files = Vec::new(); + let mut too_large = Vec::new(); + let entries = walkdir::WalkDir::new(root) + .min_depth(1) + .sort_by_file_name() + .into_iter() + .filter_entry(|e| { + !(e.file_type().is_dir() + && SKIPPED_DIRS.contains(&e.file_name().to_string_lossy().as_ref())) + }) + .filter_map(Result::ok) + .filter(|e| e.file_type().is_file()); + for entry in entries { + let size = entry.metadata().map(|m| m.len()).unwrap_or(0); + if size > MAX_FILE_BYTES { + too_large.push(relative(root, entry.path())); + } else if size > 0 { + files.push(entry.into_path()); + } + } + (files, too_large) +} + +/// `path` relative to `root`, `/`-separated. +fn relative(root: &Path, path: &Path) -> String { + path.strip_prefix(root) + .unwrap_or(path) + .to_string_lossy() + .replace('\\', "/") +} + +/// The SHA-256 of a file, hex. +async fn hash_file(file: &Path) -> Result { + let mut input = tokio::fs::File::open(file).await?; + let mut hasher = Sha256::new(); + let mut buffer = vec![0_u8; CHUNK]; + loop { + let read = input.read(&mut buffer).await?; + if read == 0 { + break; + } + hasher.update(&buffer[..read]); + } + Ok(hex::encode(hasher.finalize())) +} + +/// The cache key of a file found clean with `signatures`. +fn cache_key(hash: &str, signatures: &str) -> String { + format!("{hash}|{signatures}") +} + +/// The hashes among `files` known clean with `signatures`. +async fn known_clean( + db: &Database, + signatures: &str, + files: &[(PathBuf, String)], +) -> HashSet { + let keys: Vec = files + .iter() + .map(|(_, h)| cache_key(h, signatures)) + .collect(); + let mut known = HashSet::new(); + for chunk in keys.chunks(1000) { + let Ok(cursor) = db + .raw_collection(CLEAN_CACHE) + .find(doc! { "_id": { "$in": chunk.to_vec() } }) + .await + else { + continue; + }; + let rows: Vec = cursor.try_collect().await.unwrap_or_default(); + known.extend( + rows.iter() + .filter_map(|d| d.get_str("_id").ok()) + .filter_map(|key| key.split('|').next().map(str::to_string)), + ); + } + known +} + +/// The finding for a file matching `signature`. +fn finding(root: &Path, repo_id: &str, file: &Path, hash: &str, signature: &str) -> Finding { + let path = relative(root, file); + let review = if heuristic(signature) { + " This is a heuristic signature: it also matches packers, obfuscators and \ + protection tools, so a person must review whether the file is malicious." + } else { + "" + }; + let mut finding = Finding::new( + repo_id.to_string(), + dedup::compute_fingerprint(&[repo_id, SCANNER, signature, &path]), + SCANNER.to_string(), + ScanType::Malware, + format!("Malware signature {signature} matches {path}"), + format!( + "ClamAV reports the signature {signature} in {path} (SHA-256 {hash}).{review} A file \ + the product ships or the build runs must not carry malicious code." + ), + Severity::High, + ); + finding.rule_id = Some(signature.to_string()); + finding.cwe = Some("CWE-506".to_string()); + finding.file_path = Some(path); + finding.remediation = Some( + "Find out where the file comes from. Remove it, or replace it with the vendor's \ + original, checked against its published hash; if it is a deliberate tool (an \ + obfuscator, a test sample), record why and mark the finding." + .to_string(), + ); + finding +} + +#[cfg(test)] +#[allow(clippy::expect_used, clippy::unwrap_used)] +mod tests { + use super::*; + + #[test] + fn clamd_answers_are_read() { + assert_eq!( + signature_version("ClamAV 1.5.4/28145/Tue Oct 6 06:26:12 2026"), + "1.5.4/28145" + ); + assert_eq!(parse_scan_answer("stream: OK").unwrap(), None); + assert_eq!( + parse_scan_answer("stream: Win.Malware.Mardom-9971 FOUND").unwrap(), + Some("Win.Malware.Mardom-9971".to_string()) + ); + assert!(parse_scan_answer("INSTREAM size limit exceeded. ERROR").is_err()); + } + + #[test] + fn heuristic_signatures_ask_for_review() { + assert!(heuristic("Win.Malware.Mardom-9971")); + assert!(heuristic("Heuristics.Encrypted.Zip")); + assert!(heuristic("PUA.Win.Packer.Confuser-1")); + assert!(!heuristic("Eicar-Test-Signature")); + assert!(!heuristic("Win.Trojan.Emotet-123")); + } + + #[test] + fn large_and_empty_files_and_git_are_not_streamed() { + let dir = std::env::temp_dir().join(format!("cs-clamav-{}", uuid::Uuid::new_v4())); + std::fs::create_dir_all(dir.join(".git/objects")).unwrap(); + std::fs::write(dir.join(".git/objects/x"), "blob").unwrap(); + std::fs::write(dir.join("empty"), "").unwrap(); + std::fs::write(dir.join("tool.dll"), "MZ").unwrap(); + let (files, too_large) = list_files(&dir); + let _ = std::fs::remove_dir_all(&dir); + assert_eq!(files.len(), 1); + assert!(files[0].ends_with("tool.dll")); + assert!(too_large.is_empty()); + } + + /// Against a real clamd at `CLAMD_ADDRESS` (the official image); skipped + /// without one. + #[tokio::test] + async fn the_eicar_test_file_is_found_by_a_real_clamd() { + let Some(clamd) = Clamd::from_env() else { + eprintln!("SKIP clamav: CLAMD_ADDRESS not set"); + return; + }; + let dir = std::env::temp_dir().join(format!("cs-clamav-{}", uuid::Uuid::new_v4())); + std::fs::create_dir_all(&dir).unwrap(); + let eicar = dir.join("eicar.com"); + std::fs::write( + &eicar, + "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*", + ) + .unwrap(); + let clean = dir.join("readme.txt"); + std::fs::write(&clean, "a pump controller").unwrap(); + let hit = clamd.scan_file(&eicar).await.unwrap(); + let none = clamd.scan_file(&clean).await.unwrap(); + let _ = std::fs::remove_dir_all(&dir); + assert_eq!(hit.as_deref(), Some("Eicar-Test-Signature")); + assert_eq!(none, None); + assert!(clamd.signatures().await.unwrap().contains('/')); + } +} diff --git a/compliance-agent/src/pipeline/mod.rs b/compliance-agent/src/pipeline/mod.rs index 729b684..50d31a2 100644 --- a/compliance-agent/src/pipeline/mod.rs +++ b/compliance-agent/src/pipeline/mod.rs @@ -1,4 +1,7 @@ +pub mod binaries; pub mod build_lifecycle; +pub mod change; +pub mod clamav; pub mod code_review; pub mod cppcheck; pub mod cve; diff --git a/compliance-agent/src/pipeline/orchestrator.rs b/compliance-agent/src/pipeline/orchestrator.rs index fc44bcd..9f47add 100644 --- a/compliance-agent/src/pipeline/orchestrator.rs +++ b/compliance-agent/src/pipeline/orchestrator.rs @@ -108,9 +108,12 @@ impl PipelineOrchestrator { } // A scheduled or webhook scan of an unchanged repository has nothing - // new to find; one a person started always runs (after an update of - // Prüfwerk itself, or a changed setting, it can find something else). + // new to find; one a person started always runs (after a changed + // setting it can find something else), and a new Prüfwerk build scans + // once (#465). if !trigger.started_by_person() + && repo.last_scanned_build.as_deref() + == Some(crate::pipeline::change::build_id().as_str()) && !GitOps::has_new_commits(&repo_path, repo.last_scanned_commit.as_deref())? { tracing::info!("[{repo_id}] No new commits, skipping scan"); @@ -595,6 +598,19 @@ impl PipelineOrchestrator { group_repetitive(&mut all_findings, &grouping); run_findings.save_new(&self.db, &mut all_findings).await?; + // Stage 4a': malware signatures and committed binaries (#465). Vendor + // code is scanned too: a vendored DLL is exactly where it hides. + self.update_phase(scan_run_id, ScanPhase::MalwareScanning) + .await; + let malware = self + .scan_malware(&repo_path, &repo_id, scan_run_id, &mut run_findings) + .instrument(tracing::info_span!("stage_malware")) + .await; + all_findings.extend(malware); + run_findings.label(&mut all_findings); + group_repetitive(&mut all_findings, &grouping); + run_findings.save_new(&self.db, &mut all_findings).await?; + // Stage 4b: Lint Scanning tracing::info!("[{repo_id}] Stage 4b: Lint Scanning"); self.update_phase(scan_run_id, ScanPhase::LintScanning) @@ -803,11 +819,21 @@ impl PipelineOrchestrator { /// `OnboardedTarget`. Mirrors [`Self::run`] but sources the target from /// `onboarded_targets` and dispatches by the scan plan. #[tracing::instrument(skip_all, fields(target_id = %target_id, trigger = ?trigger))] + /// Run one scan of the target `target_id`. + /// + /// # Returns + /// + /// Whether it scanned: `false` when it was skipped because nothing changed + /// since the last completed scan (a scheduled or webhook scan, #465). + /// + /// # Errors + /// + /// The target is unknown, or the scan failed (recorded on its run). pub async fn run_target( &self, target_id: &str, trigger: ScanTrigger, - ) -> Result<(), AgentError> { + ) -> Result { let oid = mongodb::bson::oid::ObjectId::parse_str(target_id) .map_err(|e| AgentError::Other(e.to_string()))?; let target = self @@ -851,12 +877,19 @@ impl PipelineOrchestrator { .count_documents(doc! { "repo_id": target_id }) .await .unwrap_or(*count as u64); + // What this completed scan read, for the next scheduled one. + let last_scan = compliance_core::models::LastScan { + build: crate::pipeline::change::build_id(), + inputs: crate::pipeline::change::upload_inputs(&target), + }; self.db .onboarded_targets() .update_one( doc! { "_id": oid }, doc! { "$set": { "findings_count": total as i64, + "last_scan": mongodb::bson::to_bson(&last_scan) + .map_err(|e| AgentError::Other(e.to_string()))?, "updated_at": mongodb::bson::DateTime::now(), } }, ) @@ -879,7 +912,16 @@ impl PipelineOrchestrator { .await?; } } - result.map(|_| ()) + result?; + let skipped = self + .db + .scan_runs() + .count_documents(doc! { + "_id": &insert.inserted_id, + "skipped_stages.stage": "change_detection", + }) + .await?; + Ok(skipped == 0) } /// Run the applicable scans for a target. For a code target this reuses the @@ -893,6 +935,29 @@ impl PipelineOrchestrator { trigger: &ScanTrigger, ) -> Result { let target_id = target.id.map(|id| id.to_hex()).unwrap_or_default(); + // Uploaded files the last completed scan already read, with the same + // Prüfwerk build: a scheduled scan has nothing new to find (#465). + let has_git = target + .artifacts + .iter() + .any(|a| a.kind == ArtifactKind::GitRepo); + if !trigger.started_by_person() + && !has_git + && crate::pipeline::change::upload_unchanged(target) + { + tracing::info!(target_id = %target_id, "Uploaded files unchanged, skipping scan"); + self.skip_stage( + scan_run_id, + SkippedStage::new( + "change_detection", + SkipCode::UploadUnchanged, + "the uploaded files and the Prüfwerk version are the same as at the last \ + completed scan", + ), + ) + .await; + return Ok(0); + } let plan = build_scan_plan(target); // An attached artifact nothing analyses is recorded, never passed over: // a completed run must not read as "we looked and found nothing". @@ -1750,6 +1815,84 @@ impl PipelineOrchestrator { self.config.features.source_only() } + /// The committed binaries of the tree under `repo_path` and, when a clamd + /// is configured, the malware signatures in it (#465). A clamd that is + /// not configured or cannot be reached is recorded as a skipped stage; + /// the scan goes on. + async fn scan_malware( + &self, + repo_path: &std::path::Path, + repo_id: &str, + scan_run_id: &str, + run_findings: &mut crate::pipeline::finding_store::RunFindings, + ) -> Vec { + use crate::pipeline::{binaries, clamav}; + let tree = repo_path.to_path_buf(); + let listed = tokio::task::spawn_blocking(move || binaries::committed_binaries(&tree)) + .await + .unwrap_or_default(); + run_findings.completed(binaries::SCANNER); + let mut findings: Vec = listed + .iter() + .map(|b| binaries::into_finding(repo_id, b)) + .collect(); + let Some(clamd) = clamav::Clamd::from_env() else { + self.skip_stage( + scan_run_id, + SkippedStage::new( + "malware", + SkipCode::FeatureDisabled, + "no ClamAV service is configured (CLAMD_ADDRESS)", + ), + ) + .await; + return findings; + }; + match clamd.scan_tree(&self.db, repo_path, repo_id).await { + Ok(scan) => { + tracing::info!( + "[{repo_id}] ClamAV {}: {} files streamed, {} hits, {} binaries listed", + scan.signatures, + scan.streamed, + scan.findings.len(), + listed.len() + ); + run_findings.completed(clamav::SCANNER); + if !scan.too_large.is_empty() { + let list = scan.too_large.join(", "); + self.skip_stage( + scan_run_id, + SkippedStage::new( + "malware", + SkipCode::TooLargeToScan, + format!( + "files above {} MiB were not scanned for malware: {list}", + clamav::MAX_FILE_BYTES / (1024 * 1024) + ), + ) + .about(list), + ) + .await; + } + findings.extend(scan.findings); + } + Err(e) => { + tracing::warn!("[{repo_id}] ClamAV did not complete: {e}"); + self.skip_stage( + scan_run_id, + SkippedStage::new( + "malware", + SkipCode::ToolFailed, + format!("ClamAV did not complete: {e}"), + ) + .about("ClamAV"), + ) + .await; + } + } + findings + } + /// Record a stage the pipeline deliberately did not run. A skipped stage is /// not an error: the scan completes, and the dashboard shows it as skipped /// rather than failed. diff --git a/compliance-agent/src/pipeline/plan.rs b/compliance-agent/src/pipeline/plan.rs index 4cf9fae..32120f9 100644 --- a/compliance-agent/src/pipeline/plan.rs +++ b/compliance-agent/src/pipeline/plan.rs @@ -140,6 +140,7 @@ fn phase_for(scan: ScanType) -> ScanPhase { ScanType::MobileStatic => ScanPhase::MobileStatic, ScanType::ContainerScan => ScanPhase::ContainerScan, ScanType::IcsProbe => ScanPhase::IcsProbe, + ScanType::Malware => ScanPhase::MalwareScanning, } } diff --git a/compliance-agent/src/pipeline/repo_view.rs b/compliance-agent/src/pipeline/repo_view.rs index f2ecbeb..c0a9afc 100644 --- a/compliance-agent/src/pipeline/repo_view.rs +++ b/compliance-agent/src/pipeline/repo_view.rs @@ -36,6 +36,8 @@ pub struct RepoView { pub auth_token: Option, pub auth_username: Option, pub last_scanned_commit: Option, + /// The Prüfwerk build of the target's last completed scan (#465). + pub last_scanned_build: Option, pub findings_count: u32, /// Created by a managed git source (#439): its Gitea issues get the /// Prüfwerk/CRA labels and a link into Prüfwerk. @@ -65,6 +67,7 @@ impl RepoView { auth_token: None, auth_username: None, last_scanned_commit: None, + last_scanned_build: target.last_scan.as_ref().map(|l| l.build.clone()), findings_count: target.findings_count, managed: target.source_repo.is_some(), }; diff --git a/compliance-core/src/models/mod.rs b/compliance-core/src/models/mod.rs index f301174..36a34f2 100644 --- a/compliance-core/src/models/mod.rs +++ b/compliance-core/src/models/mod.rs @@ -45,7 +45,7 @@ pub use notification::{CveNotification, NotificationSeverity, NotificationStatus pub use onboarding::{ default_compliance_profile, Artifact, ArtifactAuth, ArtifactKind, Classification, ComplianceFramework, ComplianceProfile, DetectedFact, ExternalRef, ExternalSystem, - GitArtifactConfig, IssueTrackerConfig, OnboardedTarget, PlcArtifactConfig, PlcFormat, + GitArtifactConfig, IssueTrackerConfig, LastScan, OnboardedTarget, PlcArtifactConfig, PlcFormat, TargetScanConfig, TargetType, TargetTypeCandidate, WebArtifactConfig, }; pub use oscal::OscalDocument; diff --git a/compliance-core/src/models/onboarding.rs b/compliance-core/src/models/onboarding.rs index e720972..08ec072 100644 --- a/compliance-core/src/models/onboarding.rs +++ b/compliance-core/src/models/onboarding.rs @@ -529,6 +529,20 @@ pub struct ComplianceProfile { /// The sensible default compliance scope for a target type. Firmware / PLC / /// embedded default to CRA + IEC 62443; software defaults to GDPR + SOC 2. +/// What a completed scan of a target read: the Prüfwerk build that ran it +/// and, for uploaded files, a digest of them. A git target's commit is kept +/// on its artifact (`last_scanned_commit`). +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)] +pub struct LastScan { + /// The agent build (`+`): a new release can find more in + /// the same code, so it scans again. + pub build: String, + /// The uploaded artifacts' ids and content hashes, digested; `None` for a + /// git target. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub inputs: Option, +} + impl OnboardedTarget { /// The type a scan's `classification` gives a managed target, when it /// should change: the target came from a managed git source (created @@ -625,6 +639,10 @@ pub struct OnboardedTarget { with = "super::serde_helpers::opt_bson_datetime" )] pub archived_at: Option>, + /// What the last completed scan read, so a scheduled scan of an unchanged + /// target can be skipped (#465). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub last_scan: Option, /// Creation timestamp. #[serde( default = "chrono::Utc::now", @@ -663,6 +681,7 @@ impl OnboardedTarget { source_repo: None, type_chosen: false, archived_at: None, + last_scan: None, created_at: now, updated_at: now, } diff --git a/compliance-core/src/models/scan.rs b/compliance-core/src/models/scan.rs index e30de0c..2367b93 100644 --- a/compliance-core/src/models/scan.rs +++ b/compliance-core/src/models/scan.rs @@ -30,6 +30,9 @@ pub enum ScanType { /// A penetration test done by a person; its findings are entered or /// imported by hand. Pentest, + /// Malware signatures (ClamAV) and the committed binaries of a tree + /// (#465). + Malware, } impl std::fmt::Display for ScanType { @@ -51,6 +54,7 @@ impl std::fmt::Display for ScanType { Self::ContainerScan => write!(f, "container_scan"), Self::IcsProbe => write!(f, "ics_probe"), Self::Pentest => write!(f, "pentest"), + Self::Malware => write!(f, "malware"), } } } @@ -79,6 +83,8 @@ pub enum ScanPhase { CveScanning, PatternScanning, SecretDetection, + /// ClamAV over the tree, and the committed binaries listed (#465). + MalwareScanning, LintScanning, CodeReview, GraphBuilding, @@ -213,6 +219,12 @@ pub enum SkipCode { /// native code are not in the repository; `subject` names the project and /// platform. PlatformProjectGenerated, + /// A scheduled or webhook scan of uploaded files that are the same as at + /// the last completed scan, run by the same Prüfwerk version, so nothing + /// was scanned again. + UploadUnchanged, + /// Files too large for the malware scan; `subject` lists them. + TooLargeToScan, } /// Why a scan run failed, stable for the dashboard to word. diff --git a/compliance-dashboard/src/components/scan_runs.rs b/compliance-dashboard/src/components/scan_runs.rs index df3a98b..de5b74e 100644 --- a/compliance-dashboard/src/components/scan_runs.rs +++ b/compliance-dashboard/src/components/scan_runs.rs @@ -427,6 +427,10 @@ pub fn phase(phase: &ScanPhase) -> Text { ), ScanPhase::PatternScanning => ("Datenschutz-Muster", "Privacy patterns"), ScanPhase::SecretDetection => ("Zugangsdaten im Code", "Secrets in the code"), + ScanPhase::MalwareScanning => ( + "Schadsoftware und Binärdateien", + "Malware and committed binaries", + ), ScanPhase::LintScanning => ("Code-Qualität", "Code quality"), ScanPhase::CodeReview => ("Code-Review", "Code review"), ScanPhase::GraphBuilding => ("Code-Graph", "Code graph"), diff --git a/compliance-dashboard/src/i18n/texts.rs b/compliance-dashboard/src/i18n/texts.rs index 4c94e89..7855cd2 100644 --- a/compliance-dashboard/src/i18n/texts.rs +++ b/compliance-dashboard/src/i18n/texts.rs @@ -443,6 +443,10 @@ pub mod scans { de: "Abhängigkeiten (SBOM)", en: "Dependencies (SBOM)", }, + "malware" => Text { + de: "Schadsoftware (ClamAV)", + en: "Malware (ClamAV)", + }, "platform_project" => Text { de: "Von Unity erzeugtes App-Projekt", en: "App project generated by Unity", @@ -590,6 +594,23 @@ pub mod scans { \"Run scan\" always scans in full." .into() } + (SkipCode::UploadUnchanged, Lang::De) => { + "Die hochgeladenen Dateien und die Prüfwerk-Version sind seit der letzten Prüfung \ + unverändert, daher nicht erneut geprüft. „Prüfung starten“ prüft trotzdem \ + vollständig." + .into() + } + (SkipCode::UploadUnchanged, Lang::En) => { + "The uploaded files and the Prüfwerk version are unchanged since the last scan, \ + so it was not scanned again. \"Run scan\" always scans in full." + .into() + } + (SkipCode::TooLargeToScan, Lang::De) => { + format!("Zu groß für die Suche nach Schadsoftware, nicht geprüft: {subject}") + } + (SkipCode::TooLargeToScan, Lang::En) => { + format!("Too large for the malware scan, not checked: {subject}") + } (SkipCode::PlatformProjectGenerated, Lang::De) => format!( "Für {subject} erzeugt Unity das App-Projekt erst beim Build; es liegt nicht \ im Repository. Info.plist bzw. Manifest, Berechtigungen und nativer Code sind \ @@ -1647,14 +1668,16 @@ pub mod findings { ScanType::ContainerScan => ("Container", "Container"), ScanType::IcsProbe => ("Industrieprotokolle (ICS)", "Industrial protocols (ICS)"), ScanType::Pentest => ("Penetrationstest", "Penetration test"), + ScanType::Malware => ("Schadsoftware und Binärdateien", "Malware and binaries"), }; Text { de, en } } /// Every scan type a finding can carry, in the filter's order. - pub const SCAN_TYPES: [ScanType; 16] = [ + pub const SCAN_TYPES: [ScanType; 17] = [ ScanType::Sast, ScanType::SecretDetection, + ScanType::Malware, ScanType::Cve, ScanType::Sbom, ScanType::FirmwareStatic, @@ -1767,6 +1790,14 @@ pub mod findings { de: "Build-System und Plattform", en: "Build system and platform", }, + "clamav" => Text { + de: "Schadsoftware (ClamAV)", + en: "Malware (ClamAV)", + }, + "binary-inventory" => Text { + de: "Eingecheckte Binärdateien", + en: "Committed binaries", + }, "ios-config" => Text { de: "iOS-App-Einstellungen", en: "iOS app settings", @@ -2800,6 +2831,10 @@ pub mod coverage { ScanType::ContainerScan => ("Prüft das Container-Image", "Checks the container image"), ScanType::MobileStatic => ("Analysiert die mobile App", "Analyses the mobile app"), ScanType::Pentest => ("Penetrationstest", "Penetration test"), + ScanType::Malware => ( + "Sucht mit ClamAV nach Schadsoftware und listet eingecheckte Binärdateien", + "Searches for malware with ClamAV and lists committed binaries", + ), ScanType::Graph => ("Baut den Code-Graphen", "Builds the code graph"), ScanType::Gdpr => ("Prüft Datenschutz-Muster", "Checks privacy patterns"), ScanType::OAuth => ("Prüft die OAuth-Konfiguration", "Checks the OAuth setup"), diff --git a/docs/guide/findings.md b/docs/guide/findings.md index 1762dc8..2343f36 100644 --- a/docs/guide/findings.md +++ b/docs/guide/findings.md @@ -180,8 +180,8 @@ What the scan never changes: **Nicht ausgeführt**): a failed analysis says nothing about the code. - Findings of the linters and of the AI checks, and of SPS/PLC projects (not yet). -- A scheduled scan that finds no new commits does not scan, so it closes - nothing. +- A scheduled scan that finds no new commits (or unchanged uploaded files) does + not scan, so it closes nothing. Findings are tied to a file and line. When code moves (lines added above it), the same issue is reported at its new line as a new finding, and the old one diff --git a/docs/guide/scanning.md b/docs/guide/scanning.md index 38618b9..e71ce53 100644 --- a/docs/guide/scanning.md +++ b/docs/guide/scanning.md @@ -75,8 +75,13 @@ A manual scan always scans in full, even if nothing changed. Targets are scanned automatically on a recurring schedule: by default every 6 hours, with an hourly check of known components for newly published CVEs. Your administrator controls these schedules. A scheduled scan of a git repository -with no new commits since the last scan does not scan again; the run says so -under **Nicht ausgeführt**. +with no new commits since the last scan, or of uploaded files that are the +same as at the last scan, does not scan again; the run says so under +**Nicht ausgeführt** and counts as no scan. After an update of Prüfwerk every +target is scanned once more, since new rules can find more in the same code. +**Prüfung starten** always scans in full, also when a restart of Prüfwerk +interrupted it and it is started again. The hourly CVE check of the known +components runs either way. ### Webhook-Triggered Scans @@ -150,6 +155,8 @@ as a clean result: the CRA requirements it checks show as **Nicht bewertet**. | **Firmware-SBOM** | *(build system)*-Build erkannt, aber ohne Build lassen sich keine Komponenten auflösen. | The components could not be read from the sources without building. Importing a Firmwerk bundle, which the message mentions, is not available yet. | | **CVE-Abgleich unvollständig** | Nicht abgeglichen: *(lookup and components)* | Start the scan again later; the lookup service may have been unavailable. | | **Änderungserkennung** | Keine neuen Commits seit der letzten Prüfung, daher nicht erneut geprüft. „Prüfung starten“ prüft trotzdem vollständig. | Nothing; click **Prüfung starten** for a full scan. | +| **Änderungserkennung** | Die hochgeladenen Dateien und die Prüfwerk-Version sind seit der letzten Prüfung unverändert, daher nicht erneut geprüft. | Nothing; click **Prüfung starten** for a full scan. | +| **Schadsoftware (ClamAV)** | In dieser Umgebung nicht aktiviert. / … wurde nicht fertig. / Zu groß für die Suche nach Schadsoftware, nicht geprüft: … | Without the ClamAV service nothing was searched; files above 64 MiB are listed. | ## Where a scan may connect diff --git a/docs/reference/tools.md b/docs/reference/tools.md index eebaf57..7dc60b4 100644 --- a/docs/reference/tools.md +++ b/docs/reference/tools.md @@ -138,6 +138,33 @@ Only package URLs (purl), CVE ids and CPE product prefixes are sent. Both source Licenses of NuGet packages that no `.nuspec` in the tree gives are read from the [nuget.org registration API](https://learn.microsoft.com/nuget/api/registration-base-url-resource) (`api.nuget.org`). Only the package id and version are sent, never for an id a `nuget.config` routes to another feed (see [.NET projects](/guide/dotnet-en)). The lookup is bounded per scan (8 requests at once, 10 s per request, 60 s and 300 uncached packages in total); answers are cached for all tenants. Set `NUGET_LICENSE_LOOKUP=false` to keep the agent from contacting nuget.org. +## ClamAV -- Malware + +[ClamAV](https://www.clamav.net/) (GPL-2.0, the official image unchanged) runs +as its own service beside the agent, its signatures updated daily by freshclam +inside it. The agent streams each file of the tree to it (`INSTREAM`, at most +64 MiB per file; larger files are listed under **Nicht ausgeführt**), vendor +code included: a vendored DLL is exactly where malware hides. A file found +clean is remembered by its SHA-256 and the signature version, so a rescan only +streams what changed or met new signatures. Each hit is a finding of high +severity with the signature, the file and its SHA-256 (type **Schadsoftware und +Binärdateien**, tool **Schadsoftware (ClamAV)**). Heuristic signatures +(`Heuristics.*`, `*.Malware.*`, `PUA.*`) also match packers, obfuscators and +protection tools; such a finding says so and needs a person's review. The LLM +triage does not judge these findings (there is no code to read). Without the +service (`CLAMD_ADDRESS` unset) the stage is listed as not enabled; when the +service cannot be reached, as not completed, never as clean. + +## Committed binaries + +Executables, libraries and firmware images committed as built files (PE, ELF, +Mach-O, and `.hex`/`.srec`/`.uf2`/`.dfu`/raw `.bin` images, recognised by their +first bytes) are listed as informational findings (tool **Eingecheckte +Binärdateien**) with format, architecture (and `.NET` for an assembly), size, +SHA-256 and, for a Windows file, its version resource (product, version, +company, original file name). A changed file is a new finding. Many of them in +one repository become one finding listing them. + ## Custom OAuth Scanner A purpose-built scanner that detects OAuth and OIDC misconfigurations in your code, including: @@ -241,6 +268,7 @@ These are set by the operator in the agent's environment, not by a tenant, and o | Identity providers for pentest test-user cleanup (Keycloak, Auth0, Okta) | `pentest/cleanup.rs` | `KEYCLOAK_URL`, `AUTH0_DOMAIN`, `OKTA_DOMAIN` | | Headless Chrome for PDF reports | `pentest/report/pdf.rs` | `CHROME_WS_URL` | | MongoDB | `database.rs` | `MONGODB_URI` | +| ClamAV service (clamd, plain TCP; the tree's files are streamed to it) | `pipeline/clamav.rs` | `CLAMD_ADDRESS` | ## Planned integrations (decided 2026-08-31, not yet in the code) diff --git a/docs/release/staging-test-plan-after-v0.4.5.md b/docs/release/staging-test-plan-after-v0.4.5.md index 18f8a85..8a3da91 100644 --- a/docs/release/staging-test-plan-after-v0.4.5.md +++ b/docs/release/staging-test-plan-after-v0.4.5.md @@ -15,6 +15,7 @@ together on stage in one pass before the next prod promotion. | #478–#482 | iOS readiness 1–5: Carthage and lifecycle, iOS rules, Unity targets, app variants, public samples (with the mobsfscan and Firebase fixes) | | #484 | Groups take over their places' decisions (#483) | | #486 | The clone cache heals itself after an interrupted clone or fetch | +| #465 | Malware stage (ClamAV), committed binaries, unchanged scheduled rescans skipped | **Customer-visible on the next prod rescan** is marked **[visible]**: these change what a customer sees on their existing targets, without them doing @@ -217,6 +218,55 @@ places) and rescan. - **[visible]** customers whose scans failed on a broken cache entry get scans again; nothing else changes. +### 15. #465 Malware, committed binaries, unchanged rescans + +Needs orca-platform #66 deployed (the `pruefwerk-clamav-stage` service); +`docker logs` of it shows `clamd started` once its signatures are in. + +Malware: + +- **Do:** upload an archive holding the EICAR test file (create it locally, + `printf 'X5O!P%%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > eicar.com`, + never commit it) next to a few source files. +- **Expect:** a **Hoch** finding **Malware signature Eicar-Test-Signature + matches eicar.com**, type **Schadsoftware und Binärdateien**, tool + **Schadsoftware (ClamAV)**, with its SHA-256; no LLM verdict (triage + rationale "skipped: binary"). Rescan the same target: no new finding, and + the log shows `0 files streamed` (the clean files are remembered). +- **Log:** `ClamAV 1.5.4/: N files streamed, 1 hits, M binaries listed`. +- **Without the service:** stop `pruefwerk-clamav-stage` and scan: the scan + completes, **Nicht ausgeführt** lists **Schadsoftware (ClamAV)** as not + completed (`ClamAV did not complete: clamd at clamav:3310 cannot be reached`). + +Committed binaries: + +- **Do:** scan `fixtures/nightly/firmware/c-sensor-node` (it holds + `Prebuilt/bootloader.hex`) and any repository with committed DLLs. +- **Expect:** an **Info** finding **Committed binary bootloader.hex + (firmware image (Intel HEX))** with size and SHA-256; for a DLL its format + (`PE32 i386 (.NET)` …) and version resource (ProductName, FileVersion, + CompanyName, OriginalFilename). More than five in one repository become one + finding listing them. +- **[visible]** repositories with committed DLLs, executables or firmware + images get these Info findings on the next rescan; a malware hit is High. + +Unchanged rescans: + +- **Do:** upload an archive target and let a scheduled scan run after a + completed one (or wait for the 6-hourly schedule). +- **Expect:** the scheduled run lists **Änderungserkennung** under **Nicht + ausgeführt** ("Die hochgeladenen Dateien und die Prüfwerk-Version sind … + unverändert") and sends no `scan.completed` usage; **Prüfung starten** still + scans in full. After this deploy every target scans once (new build), then + skips while unchanged. The hourly CVE monitor keeps running. +- **Restart:** restart the agent during a **Prüfung starten** scan of an + unchanged target: the resumed scan runs in full (`starting a scan + interrupted by the restart again` with `trigger=Manual`). +- **Log:** `Uploaded files unchanged, skipping scan` / `No new commits, + skipping scan`. +- **[visible]** scheduled scans of unchanged targets no longer count as scans + (usage), and a new Prüfwerk release rescans every target once. + ## After the pass - The nightly job on `main` is green with the new mobile targets. diff --git a/fixtures/nightly/baselines/archive-order-intake-tgz.json b/fixtures/nightly/baselines/archive-order-intake-tgz.json index bc0652b..b847c75 100644 --- a/fixtures/nightly/baselines/archive-order-intake-tgz.json +++ b/fixtures/nightly/baselines/archive-order-intake-tgz.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "npm:lodash@4.17.15", "npm:minimist@1.2.0", diff --git a/fixtures/nightly/baselines/archive-order-intake.json b/fixtures/nightly/baselines/archive-order-intake.json index bc0652b..b847c75 100644 --- a/fixtures/nightly/baselines/archive-order-intake.json +++ b/fixtures/nightly/baselines/archive-order-intake.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "npm:lodash@4.17.15", "npm:minimist@1.2.0", diff --git a/fixtures/nightly/baselines/firmware-zephyr-example.json b/fixtures/nightly/baselines/firmware-zephyr-example.json index fe6b0bb..e7ef691 100644 --- a/fixtures/nightly/baselines/firmware-zephyr-example.json +++ b/fixtures/nightly/baselines/firmware-zephyr-example.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "github:actions/checkout@v7.0.1", "github:actions/configure-pages@v6.0.0", diff --git a/fixtures/nightly/baselines/fw-arduino.json b/fixtures/nightly/baselines/fw-arduino.json index 285ffc5..7c3d3e0 100644 --- a/fixtures/nightly/baselines/fw-arduino.json +++ b/fixtures/nightly/baselines/fw-arduino.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "toolchain:arduino-cli@" ], diff --git a/fixtures/nightly/baselines/fw-c-sensor-node.json b/fixtures/nightly/baselines/fw-c-sensor-node.json index b2eb69d..ebb34a8 100644 --- a/fixtures/nightly/baselines/fw-c-sensor-node.json +++ b/fixtures/nightly/baselines/fw-c-sensor-node.json @@ -1,12 +1,14 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sast_vendor_code" ], "sbom": [ "toolchain:arm-none-eabi-gcc@" ], "findings": [ + "binary-inventory:committed-binary bootloader.hex:0", "cppcheck:arrayIndexOutOfBounds sensors.c:15", "cppcheck:memleak sensors.c:32", "cppcheck:uninitvar sensors.c:19", diff --git a/fixtures/nightly/baselines/fw-cargo-embedded.json b/fixtures/nightly/baselines/fw-cargo-embedded.json index 566c2f7..1acd29e 100644 --- a/fixtures/nightly/baselines/fw-cargo-embedded.json +++ b/fixtures/nightly/baselines/fw-cargo-embedded.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [ diff --git a/fixtures/nightly/baselines/fw-cmake.json b/fixtures/nightly/baselines/fw-cmake.json index d24f193..700ca1d 100644 --- a/fixtures/nightly/baselines/fw-cmake.json +++ b/fixtures/nightly/baselines/fw-cmake.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "toolchain:arm-none-eabi-gcc@" ], diff --git a/fixtures/nightly/baselines/fw-embedded-libs.json b/fixtures/nightly/baselines/fw-embedded-libs.json index 220ca63..726055b 100644 --- a/fixtures/nightly/baselines/fw-embedded-libs.json +++ b/fixtures/nightly/baselines/fw-embedded-libs.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sast_vendor_code" ], "sbom": [ diff --git a/fixtures/nightly/baselines/fw-espidf.json b/fixtures/nightly/baselines/fw-espidf.json index 27f3e55..d80aa7e 100644 --- a/fixtures/nightly/baselines/fw-espidf.json +++ b/fixtures/nightly/baselines/fw-espidf.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "library:esp-idf@", "library:espressif/led_strip@2.5.3", diff --git a/fixtures/nightly/baselines/fw-freertos-cmake.json b/fixtures/nightly/baselines/fw-freertos-cmake.json index 11a26f5..b6a6b0b 100644 --- a/fixtures/nightly/baselines/fw-freertos-cmake.json +++ b/fixtures/nightly/baselines/fw-freertos-cmake.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "library:freertos_kernel@V11.1.0", "toolchain:arm-none-eabi-gcc@" diff --git a/fixtures/nightly/baselines/fw-freertos-lostbuild.json b/fixtures/nightly/baselines/fw-freertos-lostbuild.json index 77ad58b..22030ad 100644 --- a/fixtures/nightly/baselines/fw-freertos-lostbuild.json +++ b/fixtures/nightly/baselines/fw-freertos-lostbuild.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "library:ARM CMSIS Core@", "library:FreeRTOS@", diff --git a/fixtures/nightly/baselines/fw-make-onboarded-as-service.json b/fixtures/nightly/baselines/fw-make-onboarded-as-service.json index d24f193..700ca1d 100644 --- a/fixtures/nightly/baselines/fw-make-onboarded-as-service.json +++ b/fixtures/nightly/baselines/fw-make-onboarded-as-service.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "toolchain:arm-none-eabi-gcc@" ], diff --git a/fixtures/nightly/baselines/fw-make.json b/fixtures/nightly/baselines/fw-make.json index d24f193..700ca1d 100644 --- a/fixtures/nightly/baselines/fw-make.json +++ b/fixtures/nightly/baselines/fw-make.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "toolchain:arm-none-eabi-gcc@" ], diff --git a/fixtures/nightly/baselines/fw-platformio.json b/fixtures/nightly/baselines/fw-platformio.json index 5ac539c..7bd37c0 100644 --- a/fixtures/nightly/baselines/fw-platformio.json +++ b/fixtures/nightly/baselines/fw-platformio.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "library:bblanchon/ArduinoJson@7.0.4", "library:espressif32@6.5.0", diff --git a/fixtures/nightly/baselines/fw-yocto-layer.json b/fixtures/nightly/baselines/fw-yocto-layer.json index 795f5ee..a5b70ce 100644 --- a/fixtures/nightly/baselines/fw-yocto-layer.json +++ b/fixtures/nightly/baselines/fw-yocto-layer.json @@ -1,7 +1,8 @@ { "scan_status": "completed", "skipped_stages": [ - "firmware_sbom" + "firmware_sbom", + "malware" ], "sbom": [], "findings": [], diff --git a/fixtures/nightly/baselines/fw-zephyr-example-pinned.json b/fixtures/nightly/baselines/fw-zephyr-example-pinned.json index fe6b0bb..e7ef691 100644 --- a/fixtures/nightly/baselines/fw-zephyr-example-pinned.json +++ b/fixtures/nightly/baselines/fw-zephyr-example-pinned.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "github:actions/checkout@v7.0.1", "github:actions/configure-pages@v6.0.0", diff --git a/fixtures/nightly/baselines/fw-zephyr-pinned.json b/fixtures/nightly/baselines/fw-zephyr-pinned.json index 18e8a93..3e900c3 100644 --- a/fixtures/nightly/baselines/fw-zephyr-pinned.json +++ b/fixtures/nightly/baselines/fw-zephyr-pinned.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "library:cmsis@", "library:hal_nordic@", diff --git a/fixtures/nightly/baselines/git-cra-vuln-demo.json b/fixtures/nightly/baselines/git-cra-vuln-demo.json index 6ec41c0..515f8b0 100644 --- a/fixtures/nightly/baselines/git-cra-vuln-demo.json +++ b/fixtures/nightly/baselines/git-cra-vuln-demo.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [], "findings": [ "gitleaks:stripe-access-token auth.py:2", diff --git a/fixtures/nightly/baselines/js-bun-binary.json b/fixtures/nightly/baselines/js-bun-binary.json index 6a04c99..7c848fb 100644 --- a/fixtures/nightly/baselines/js-bun-binary.json +++ b/fixtures/nightly/baselines/js-bun-binary.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [], diff --git a/fixtures/nightly/baselines/js-bun.json b/fixtures/nightly/baselines/js-bun.json index a38b21b..efa140d 100644 --- a/fixtures/nightly/baselines/js-bun.json +++ b/fixtures/nightly/baselines/js-bun.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "npm:axios@0.21.1", "npm:express@4.17.1", diff --git a/fixtures/nightly/baselines/js-no-lockfile.json b/fixtures/nightly/baselines/js-no-lockfile.json index 6a04c99..7c848fb 100644 --- a/fixtures/nightly/baselines/js-no-lockfile.json +++ b/fixtures/nightly/baselines/js-no-lockfile.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [], diff --git a/fixtures/nightly/baselines/js-npm-lock-v3.json b/fixtures/nightly/baselines/js-npm-lock-v3.json index b55fac5..2496242 100644 --- a/fixtures/nightly/baselines/js-npm-lock-v3.json +++ b/fixtures/nightly/baselines/js-npm-lock-v3.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "npm:axios@0.21.1", "npm:checkout-npm-lock-v3@2.1.0", diff --git a/fixtures/nightly/baselines/js-pnpm.json b/fixtures/nightly/baselines/js-pnpm.json index a38b21b..efa140d 100644 --- a/fixtures/nightly/baselines/js-pnpm.json +++ b/fixtures/nightly/baselines/js-pnpm.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "npm:axios@0.21.1", "npm:express@4.17.1", diff --git a/fixtures/nightly/baselines/js-yarn-berry.json b/fixtures/nightly/baselines/js-yarn-berry.json index a38b21b..efa140d 100644 --- a/fixtures/nightly/baselines/js-yarn-berry.json +++ b/fixtures/nightly/baselines/js-yarn-berry.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "npm:axios@0.21.1", "npm:express@4.17.1", diff --git a/fixtures/nightly/baselines/js-yarn-classic.json b/fixtures/nightly/baselines/js-yarn-classic.json index a38b21b..efa140d 100644 --- a/fixtures/nightly/baselines/js-yarn-classic.json +++ b/fixtures/nightly/baselines/js-yarn-classic.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "npm:axios@0.21.1", "npm:express@4.17.1", diff --git a/fixtures/nightly/baselines/mobile-android-gradle-catalog.json b/fixtures/nightly/baselines/mobile-android-gradle-catalog.json index 288466d..e84bfd3 100644 --- a/fixtures/nightly/baselines/mobile-android-gradle-catalog.json +++ b/fixtures/nightly/baselines/mobile-android-gradle-catalog.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [ diff --git a/fixtures/nightly/baselines/mobile-android-gradle-lock.json b/fixtures/nightly/baselines/mobile-android-gradle-lock.json index a7ce391..62e5d4c 100644 --- a/fixtures/nightly/baselines/mobile-android-gradle-lock.json +++ b/fixtures/nightly/baselines/mobile-android-gradle-lock.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "maven:gson@2.8.8", "maven:okhttp@3.12.0", diff --git a/fixtures/nightly/baselines/mobile-android-insecure.json b/fixtures/nightly/baselines/mobile-android-insecure.json index 956bb1b..24086d3 100644 --- a/fixtures/nightly/baselines/mobile-android-insecure.json +++ b/fixtures/nightly/baselines/mobile-android-insecure.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [], diff --git a/fixtures/nightly/baselines/mobile-android-legacy-groovy.json b/fixtures/nightly/baselines/mobile-android-legacy-groovy.json index 2f64920..7102b6a 100644 --- a/fixtures/nightly/baselines/mobile-android-legacy-groovy.json +++ b/fixtures/nightly/baselines/mobile-android-legacy-groovy.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [ diff --git a/fixtures/nightly/baselines/mobile-flutter.json b/fixtures/nightly/baselines/mobile-flutter.json index d7d0237..49d2131 100644 --- a/fixtures/nightly/baselines/mobile-flutter.json +++ b/fixtures/nightly/baselines/mobile-flutter.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [ diff --git a/fixtures/nightly/baselines/mobile-ios-app-settings.json b/fixtures/nightly/baselines/mobile-ios-app-settings.json index 5016671..02fadeb 100644 --- a/fixtures/nightly/baselines/mobile-ios-app-settings.json +++ b/fixtures/nightly/baselines/mobile-ios-app-settings.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [], "findings": [ "ios-config:ios-custom-url-scheme Info.plist:7", diff --git a/fixtures/nightly/baselines/mobile-ios-carthage-legacy.json b/fixtures/nightly/baselines/mobile-ios-carthage-legacy.json index 00b580d..bdc7c1b 100644 --- a/fixtures/nightly/baselines/mobile-ios-carthage-legacy.json +++ b/fixtures/nightly/baselines/mobile-ios-carthage-legacy.json @@ -1,7 +1,8 @@ { "scan_status": "completed", "skipped_stages": [ - "cve_lookup" + "cve_lookup", + "malware" ], "sbom": [ "carthage:Alamofire/Alamofire@4.8.2", diff --git a/fixtures/nightly/baselines/mobile-ios-cocoapods.json b/fixtures/nightly/baselines/mobile-ios-cocoapods.json index 3b24239..90e56c7 100644 --- a/fixtures/nightly/baselines/mobile-ios-cocoapods.json +++ b/fixtures/nightly/baselines/mobile-ios-cocoapods.json @@ -1,7 +1,8 @@ { "scan_status": "completed", "skipped_stages": [ - "cve_lookup" + "cve_lookup", + "malware" ], "sbom": [ "cocoapods:AFNetworking/NSURLConnection@2.5.1", diff --git a/fixtures/nightly/baselines/mobile-ios-insecure.json b/fixtures/nightly/baselines/mobile-ios-insecure.json index 3220b27..2525ea9 100644 --- a/fixtures/nightly/baselines/mobile-ios-insecure.json +++ b/fixtures/nightly/baselines/mobile-ios-insecure.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [], "findings": [ "mobsfscan:ios_app_logging PumpLink.m:8", diff --git a/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json b/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json index c18f738..9cf5a41 100644 --- a/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json +++ b/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [], diff --git a/fixtures/nightly/baselines/mobile-ios-spm-xcode.json b/fixtures/nightly/baselines/mobile-ios-spm-xcode.json index 9e1cecf..0217257 100644 --- a/fixtures/nightly/baselines/mobile-ios-spm-xcode.json +++ b/fixtures/nightly/baselines/mobile-ios-spm-xcode.json @@ -1,6 +1,8 @@ { "scan_status": "completed", - "skipped_stages": [], + "skipped_stages": [ + "malware" + ], "sbom": [ "swift:swift-nio-http2@1.19.0" ], diff --git a/fixtures/nightly/baselines/mobile-legacy-adt-unity.json b/fixtures/nightly/baselines/mobile-legacy-adt-unity.json index d637997..08042d8 100644 --- a/fixtures/nightly/baselines/mobile-legacy-adt-unity.json +++ b/fixtures/nightly/baselines/mobile-legacy-adt-unity.json @@ -2,6 +2,7 @@ "scan_status": "completed", "skipped_stages": [ "cve_lookup", + "malware", "sbom_dependencies" ], "sbom": [ diff --git a/fixtures/nightly/baselines/mobile-public-android-nowinandroid.json b/fixtures/nightly/baselines/mobile-public-android-nowinandroid.json index f75f2d3..b29c42b 100644 --- a/fixtures/nightly/baselines/mobile-public-android-nowinandroid.json +++ b/fixtures/nightly/baselines/mobile-public-android-nowinandroid.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [ diff --git a/fixtures/nightly/baselines/mobile-public-ios-swiftui.json b/fixtures/nightly/baselines/mobile-public-ios-swiftui.json index c18f738..9cf5a41 100644 --- a/fixtures/nightly/baselines/mobile-public-ios-swiftui.json +++ b/fixtures/nightly/baselines/mobile-public-ios-swiftui.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [], diff --git a/fixtures/nightly/baselines/mobile-react-native.json b/fixtures/nightly/baselines/mobile-react-native.json index a9e9280..1d867ae 100644 --- a/fixtures/nightly/baselines/mobile-react-native.json +++ b/fixtures/nightly/baselines/mobile-react-native.json @@ -1,6 +1,7 @@ { "scan_status": "completed", "skipped_stages": [ + "malware", "sbom_dependencies" ], "sbom": [ diff --git a/fixtures/nightly/baselines/mobile-unity-mobile.json b/fixtures/nightly/baselines/mobile-unity-mobile.json index 605abed..ce7c270 100644 --- a/fixtures/nightly/baselines/mobile-unity-mobile.json +++ b/fixtures/nightly/baselines/mobile-unity-mobile.json @@ -2,6 +2,7 @@ "scan_status": "completed", "skipped_stages": [ "cve_lookup", + "malware", "platform_project", "sast_vendor_code" ], diff --git a/fixtures/nightly/firmware/c-sensor-node/Prebuilt/bootloader.hex b/fixtures/nightly/firmware/c-sensor-node/Prebuilt/bootloader.hex new file mode 100644 index 0000000..a7ab2c8 --- /dev/null +++ b/fixtures/nightly/firmware/c-sensor-node/Prebuilt/bootloader.hex @@ -0,0 +1,129 @@ +:10000000030A11181F262D343B424950575E656C78 +:10001000737A81888F969DA4ABB2B9C0C7CED5DC68 +:10002000E3EAF1F8FF060D141B222930373E454C58 +:10003000535A61686F767D848B9299A0A7AEB5BC48 +:10004000C3CAD1D8DFE6EDF4FB020910171E252C38 +:10005000333A41484F565D646B727980878E959C28 +:10006000A3AAB1B8BFC6CDD4DBE2E9F0F7FE050C18 +:10007000131A21282F363D444B525960676E757C08 +:10008000838A91989FA6ADB4BBC2C9D0D7DEE5ECF8 +:10009000F3FA01080F161D242B323940474E555CE8 +:1000A000636A71787F868D949BA2A9B0B7BEC5CCD8 +:1000B000D3DAE1E8EFF6FD040B121920272E353CC8 +:1000C000434A51585F666D747B828990979EA5ACB8 +:1000D000B3BAC1C8CFD6DDE4EBF2F900070E151CA8 +:1000E000232A31383F464D545B626970777E858C98 +:1000F000939AA1A8AFB6BDC4CBD2D9E0E7EEF5FC88 +:10010000030A11181F262D343B424950575E656C77 +:10011000737A81888F969DA4ABB2B9C0C7CED5DC67 +:10012000E3EAF1F8FF060D141B222930373E454C57 +:10013000535A61686F767D848B9299A0A7AEB5BC47 +:10014000C3CAD1D8DFE6EDF4FB020910171E252C37 +:10015000333A41484F565D646B727980878E959C27 +:10016000A3AAB1B8BFC6CDD4DBE2E9F0F7FE050C17 +:10017000131A21282F363D444B525960676E757C07 +:10018000838A91989FA6ADB4BBC2C9D0D7DEE5ECF7 +:10019000F3FA01080F161D242B323940474E555CE7 +:1001A000636A71787F868D949BA2A9B0B7BEC5CCD7 +:1001B000D3DAE1E8EFF6FD040B121920272E353CC7 +:1001C000434A51585F666D747B828990979EA5ACB7 +:1001D000B3BAC1C8CFD6DDE4EBF2F900070E151CA7 +:1001E000232A31383F464D545B626970777E858C97 +:1001F000939AA1A8AFB6BDC4CBD2D9E0E7EEF5FC87 +:10020000030A11181F262D343B424950575E656C76 +:10021000737A81888F969DA4ABB2B9C0C7CED5DC66 +:10022000E3EAF1F8FF060D141B222930373E454C56 +:10023000535A61686F767D848B9299A0A7AEB5BC46 +:10024000C3CAD1D8DFE6EDF4FB020910171E252C36 +:10025000333A41484F565D646B727980878E959C26 +:10026000A3AAB1B8BFC6CDD4DBE2E9F0F7FE050C16 +:10027000131A21282F363D444B525960676E757C06 +:10028000838A91989FA6ADB4BBC2C9D0D7DEE5ECF6 +:10029000F3FA01080F161D242B323940474E555CE6 +:1002A000636A71787F868D949BA2A9B0B7BEC5CCD6 +:1002B000D3DAE1E8EFF6FD040B121920272E353CC6 +:1002C000434A51585F666D747B828990979EA5ACB6 +:1002D000B3BAC1C8CFD6DDE4EBF2F900070E151CA6 +:1002E000232A31383F464D545B626970777E858C96 +:1002F000939AA1A8AFB6BDC4CBD2D9E0E7EEF5FC86 +:10030000030A11181F262D343B424950575E656C75 +:10031000737A81888F969DA4ABB2B9C0C7CED5DC65 +:10032000E3EAF1F8FF060D141B222930373E454C55 +:10033000535A61686F767D848B9299A0A7AEB5BC45 +:10034000C3CAD1D8DFE6EDF4FB020910171E252C35 +:10035000333A41484F565D646B727980878E959C25 +:10036000A3AAB1B8BFC6CDD4DBE2E9F0F7FE050C15 +:10037000131A21282F363D444B525960676E757C05 +:10038000838A91989FA6ADB4BBC2C9D0D7DEE5ECF5 +:10039000F3FA01080F161D242B323940474E555CE5 +:1003A000636A71787F868D949BA2A9B0B7BEC5CCD5 +:1003B000D3DAE1E8EFF6FD040B121920272E353CC5 +:1003C000434A51585F666D747B828990979EA5ACB5 +:1003D000B3BAC1C8CFD6DDE4EBF2F900070E151CA5 +:1003E000232A31383F464D545B626970777E858C95 +:1003F000939AA1A8AFB6BDC4CBD2D9E0E7EEF5FC85 +:10040000030A11181F262D343B424950575E656C74 +:10041000737A81888F969DA4ABB2B9C0C7CED5DC64 +:10042000E3EAF1F8FF060D141B222930373E454C54 +:10043000535A61686F767D848B9299A0A7AEB5BC44 +:10044000C3CAD1D8DFE6EDF4FB020910171E252C34 +:10045000333A41484F565D646B727980878E959C24 +:10046000A3AAB1B8BFC6CDD4DBE2E9F0F7FE050C14 +:10047000131A21282F363D444B525960676E757C04 +:10048000838A91989FA6ADB4BBC2C9D0D7DEE5ECF4 +:10049000F3FA01080F161D242B323940474E555CE4 +:1004A000636A71787F868D949BA2A9B0B7BEC5CCD4 +:1004B000D3DAE1E8EFF6FD040B121920272E353CC4 +:1004C000434A51585F666D747B828990979EA5ACB4 +:1004D000B3BAC1C8CFD6DDE4EBF2F900070E151CA4 +:1004E000232A31383F464D545B626970777E858C94 +:1004F000939AA1A8AFB6BDC4CBD2D9E0E7EEF5FC84 +:10050000030A11181F262D343B424950575E656C73 +:10051000737A81888F969DA4ABB2B9C0C7CED5DC63 +:10052000E3EAF1F8FF060D141B222930373E454C53 +:10053000535A61686F767D848B9299A0A7AEB5BC43 +:10054000C3CAD1D8DFE6EDF4FB020910171E252C33 +:10055000333A41484F565D646B727980878E959C23 +:10056000A3AAB1B8BFC6CDD4DBE2E9F0F7FE050C13 +:10057000131A21282F363D444B525960676E757C03 +:10058000838A91989FA6ADB4BBC2C9D0D7DEE5ECF3 +:10059000F3FA01080F161D242B323940474E555CE3 +:1005A000636A71787F868D949BA2A9B0B7BEC5CCD3 +:1005B000D3DAE1E8EFF6FD040B121920272E353CC3 +:1005C000434A51585F666D747B828990979EA5ACB3 +:1005D000B3BAC1C8CFD6DDE4EBF2F900070E151CA3 +:1005E000232A31383F464D545B626970777E858C93 +:1005F000939AA1A8AFB6BDC4CBD2D9E0E7EEF5FC83 +:10060000030A11181F262D343B424950575E656C72 +:10061000737A81888F969DA4ABB2B9C0C7CED5DC62 +:10062000E3EAF1F8FF060D141B222930373E454C52 +:10063000535A61686F767D848B9299A0A7AEB5BC42 +:10064000C3CAD1D8DFE6EDF4FB020910171E252C32 +:10065000333A41484F565D646B727980878E959C22 +:10066000A3AAB1B8BFC6CDD4DBE2E9F0F7FE050C12 +:10067000131A21282F363D444B525960676E757C02 +:10068000838A91989FA6ADB4BBC2C9D0D7DEE5ECF2 +:10069000F3FA01080F161D242B323940474E555CE2 +:1006A000636A71787F868D949BA2A9B0B7BEC5CCD2 +:1006B000D3DAE1E8EFF6FD040B121920272E353CC2 +:1006C000434A51585F666D747B828990979EA5ACB2 +:1006D000B3BAC1C8CFD6DDE4EBF2F900070E151CA2 +:1006E000232A31383F464D545B626970777E858C92 +:1006F000939AA1A8AFB6BDC4CBD2D9E0E7EEF5FC82 +:10070000030A11181F262D343B424950575E656C71 +:10071000737A81888F969DA4ABB2B9C0C7CED5DC61 +:10072000E3EAF1F8FF060D141B222930373E454C51 +:10073000535A61686F767D848B9299A0A7AEB5BC41 +:10074000C3CAD1D8DFE6EDF4FB020910171E252C31 +:10075000333A41484F565D646B727980878E959C21 +:10076000A3AAB1B8BFC6CDD4DBE2E9F0F7FE050C11 +:10077000131A21282F363D444B525960676E757C01 +:10078000838A91989FA6ADB4BBC2C9D0D7DEE5ECF1 +:10079000F3FA01080F161D242B323940474E555CE1 +:1007A000636A71787F868D949BA2A9B0B7BEC5CCD1 +:1007B000D3DAE1E8EFF6FD040B121920272E353CC1 +:1007C000434A51585F666D747B828990979EA5ACB1 +:1007D000B3BAC1C8CFD6DDE4EBF2F900070E151CA1 +:1007E000232A31383F464D545B626970777E858C91 +:1007F000939AA1A8AFB6BDC4CBD2D9E0E7EEF5FC81 +:00000001FF diff --git a/fixtures/nightly/targets.json b/fixtures/nightly/targets.json index 6475291..8edd303 100644 --- a/fixtures/nightly/targets.json +++ b/fixtures/nightly/targets.json @@ -221,7 +221,7 @@ "key": "fw-c-sensor-node", "name": "Firmware · C sensor node (SAST)", "target_type": "firmware_bare_metal", - "description": "STM32Cube-style C project with a C++ module and planted flaws: CRA C rules (on C and C++) and cppcheck must fire in Core/, and the vendored HAL under Drivers/ must stay out of SAST.", + "description": "STM32Cube-style C project with a C++ module and planted flaws: CRA C rules (on C and C++) and cppcheck must fire in Core/, and the vendored HAL under Drivers/ must stay out of SAST, and the prebuilt bootloader image (Prebuilt/bootloader.hex) must be listed as a committed binary.", "artifacts": [ { "kind": "source_archive", @@ -236,7 +236,8 @@ "cra-ai-13-c-broken-hash-or-cipher", "cra-ai-16-c-predictable-random", "arrayIndexOutOfBounds", - "uninitvar" + "uninitvar", + "committed-binary" ], "cwes": [ "CWE-120",