From 9b85d5148ed83416412af93e43ae4895e63bd60f Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Thu, 1 Oct 2026 18:45:27 +0000 Subject: [PATCH] fix(sbom): no clean-looking result for mobile apps without readable lockfiles (#440) --- compliance-agent/src/evidence/compliance.rs | 91 ++++- compliance-agent/src/evidence/mod.rs | 24 +- compliance-agent/src/pipeline/cve.rs | 177 ++++++---- compliance-agent/src/pipeline/orchestrator.rs | 52 ++- compliance-agent/src/pipeline/sbom/mobile.rs | 327 ++++++++++++++++++ compliance-agent/src/pipeline/sbom/mod.rs | 21 +- compliance-agent/src/pipeline/sbom/syft.rs | 54 ++- compliance-agent/src/scheduler.rs | 4 +- compliance-dashboard/src/i18n/texts.rs | 23 ++ docs/guide/sbom.md | 16 +- .../mobile-android-gradle-catalog.json | 10 + .../baselines/mobile-android-gradle-lock.json | 16 + .../nightly/baselines/mobile-flutter.json | 15 + .../baselines/mobile-ios-cocoapods.json | 13 + .../baselines/mobile-ios-spm-unlocked.json | 10 + .../baselines/mobile-ios-spm-xcode.json | 18 + .../baselines/mobile-react-native.json | 47 +++ fixtures/nightly/mobile/README.md | 18 + .../app/build.gradle.kts | 5 + .../gradle/libs.versions.toml | 7 + .../settings.gradle.kts | 2 + .../android-gradle-lock/app/build.gradle.kts | 6 + .../android-gradle-lock/app/gradle.lockfile | 7 + .../main/java/com/example/pump/PumpClient.kt | 14 + .../android-gradle-lock/build.gradle.kts | 3 + .../android-gradle-lock/settings.gradle.kts | 2 + .../mobile/flutter/android/app/build.gradle | 7 + fixtures/nightly/mobile/flutter/lib/main.dart | 7 + fixtures/nightly/mobile/flutter/pubspec.lock | 10 + fixtures/nightly/mobile/flutter/pubspec.yaml | 3 + fixtures/nightly/mobile/ios-cocoapods/Podfile | 4 + .../nightly/mobile/ios-cocoapods/Podfile.lock | 18 + .../ios-cocoapods/PumpApp/PumpClient.swift | 12 + .../PumpApp.xcodeproj/project.pbxproj | 18 + .../ios-spm-unlocked/PumpApp/PumpServer.swift | 6 + .../PumpApp.xcodeproj/project.pbxproj | 18 + .../xcshareddata/swiftpm/Package.resolved | 14 + .../ios-spm-xcode/PumpApp/PumpServer.swift | 6 + .../react-native/android/app/build.gradle | 5 + .../nightly/mobile/react-native/ios/Podfile | 5 + .../mobile/react-native/package-lock.json | 32 ++ .../nightly/mobile/react-native/package.json | 10 + fixtures/nightly/targets.json | 99 ++++++ 43 files changed, 1163 insertions(+), 93 deletions(-) create mode 100644 compliance-agent/src/pipeline/sbom/mobile.rs create mode 100644 fixtures/nightly/baselines/mobile-android-gradle-catalog.json create mode 100644 fixtures/nightly/baselines/mobile-android-gradle-lock.json create mode 100644 fixtures/nightly/baselines/mobile-flutter.json create mode 100644 fixtures/nightly/baselines/mobile-ios-cocoapods.json create mode 100644 fixtures/nightly/baselines/mobile-ios-spm-unlocked.json create mode 100644 fixtures/nightly/baselines/mobile-ios-spm-xcode.json create mode 100644 fixtures/nightly/baselines/mobile-react-native.json create mode 100644 fixtures/nightly/mobile/README.md create mode 100644 fixtures/nightly/mobile/android-gradle-catalog/app/build.gradle.kts create mode 100644 fixtures/nightly/mobile/android-gradle-catalog/gradle/libs.versions.toml create mode 100644 fixtures/nightly/mobile/android-gradle-catalog/settings.gradle.kts create mode 100644 fixtures/nightly/mobile/android-gradle-lock/app/build.gradle.kts create mode 100644 fixtures/nightly/mobile/android-gradle-lock/app/gradle.lockfile create mode 100644 fixtures/nightly/mobile/android-gradle-lock/app/src/main/java/com/example/pump/PumpClient.kt create mode 100644 fixtures/nightly/mobile/android-gradle-lock/build.gradle.kts create mode 100644 fixtures/nightly/mobile/android-gradle-lock/settings.gradle.kts create mode 100644 fixtures/nightly/mobile/flutter/android/app/build.gradle create mode 100644 fixtures/nightly/mobile/flutter/lib/main.dart create mode 100644 fixtures/nightly/mobile/flutter/pubspec.lock create mode 100644 fixtures/nightly/mobile/flutter/pubspec.yaml create mode 100644 fixtures/nightly/mobile/ios-cocoapods/Podfile create mode 100644 fixtures/nightly/mobile/ios-cocoapods/Podfile.lock create mode 100644 fixtures/nightly/mobile/ios-cocoapods/PumpApp/PumpClient.swift create mode 100644 fixtures/nightly/mobile/ios-spm-unlocked/PumpApp.xcodeproj/project.pbxproj create mode 100644 fixtures/nightly/mobile/ios-spm-unlocked/PumpApp/PumpServer.swift create mode 100644 fixtures/nightly/mobile/ios-spm-xcode/PumpApp.xcodeproj/project.pbxproj create mode 100644 fixtures/nightly/mobile/ios-spm-xcode/PumpApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved create mode 100644 fixtures/nightly/mobile/ios-spm-xcode/PumpApp/PumpServer.swift create mode 100644 fixtures/nightly/mobile/react-native/android/app/build.gradle create mode 100644 fixtures/nightly/mobile/react-native/ios/Podfile create mode 100644 fixtures/nightly/mobile/react-native/package-lock.json create mode 100644 fixtures/nightly/mobile/react-native/package.json diff --git a/compliance-agent/src/evidence/compliance.rs b/compliance-agent/src/evidence/compliance.rs index 40ca37e..68b3a1d 100644 --- a/compliance-agent/src/evidence/compliance.rs +++ b/compliance-agent/src/evidence/compliance.rs @@ -44,6 +44,21 @@ pub enum NotAssessedReason { /// The control is checked on the target's components (the SBOM and its /// CVE lookup), and the scan found none: an empty SBOM proves nothing. NoComponents, + /// The control is checked on the target's components, but the dependencies + /// `manifests` declare could not be listed (no lockfile, or one no tool + /// reads), so the SBOM is incomplete. + DependenciesUnresolved { manifests: Vec }, +} + +/// How far the target's SBOM speaks for its components. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum SbomCoverage { + /// Components were listed, and every manifest in the tree was read. + Complete, + /// The last scan listed no components. + Empty, + /// The dependencies these manifests declare could not be listed. + Unresolved(Vec), } /// The tools that check a target's components rather than its code. @@ -108,13 +123,14 @@ fn counts(finding: &Finding) -> bool { /// if one of its rules covers one of those languages, and none of the tools /// that apply is in `failed_tools` (see [`tool_of_stage`]): a scan of C code /// says nothing about a control only Python rules check, and a CVE lookup -/// that failed says nothing about the components' CVEs. +/// that failed says nothing about the components' CVEs. A control checked on +/// components only is assessed only when `sbom` is [`SbomCoverage::Complete`]. pub fn control_statuses( map: &ControlMap, findings: &[Finding], scanned_languages: Option<&[String]>, failed_tools: &[&str], - has_components: bool, + sbom: &SbomCoverage, ) -> Vec { map.controls .iter() @@ -165,13 +181,22 @@ pub fn control_statuses( ControlState::NotAssessed, Some(NotAssessedReason::ToolFailed { tools: failed }), ) - } else if on_components_only && !has_components { - ( - ControlState::NotAssessed, - Some(NotAssessedReason::NoComponents), - ) - } else { + } else if !on_components_only { (ControlState::NoViolationFound, None) + } else { + match sbom { + SbomCoverage::Complete => (ControlState::NoViolationFound, None), + SbomCoverage::Empty => ( + ControlState::NotAssessed, + Some(NotAssessedReason::NoComponents), + ), + SbomCoverage::Unresolved(manifests) => ( + ControlState::NotAssessed, + Some(NotAssessedReason::DependenciesUnresolved { + manifests: manifests.clone(), + }), + ), + } } } (Coverage::Covered, Some([])) => ( @@ -245,7 +270,7 @@ mod tests { #[test] fn every_control_gets_exactly_one_state() { let map = ControlMap::cra().expect("map"); - let statuses = control_statuses(&map, &[], Some(&python()), &[], true); + let statuses = control_statuses(&map, &[], Some(&python()), &[], &SbomCoverage::Complete); assert_eq!(statuses.len(), map.controls.len()); assert_eq!( state_of(&statuses, "cra-ai-8"), @@ -267,7 +292,13 @@ mod tests { // A real code issue that does not violate this requirement. finding("cra-ai-9", FindingStatus::WrongMapping), ]; - let statuses = control_statuses(&map, &findings, Some(&c_only()), &[], true); + let statuses = control_statuses( + &map, + &findings, + Some(&c_only()), + &[], + &SbomCoverage::Complete, + ); assert_eq!(state_of(&statuses, "cra-ai-8"), ControlState::NotSatisfied); assert_eq!( state_of(&statuses, "cra-ai-13"), @@ -295,7 +326,7 @@ mod tests { #[test] fn a_c_scan_claims_nothing_for_controls_only_python_rules_check() { let map = ControlMap::cra().expect("map"); - let statuses = control_statuses(&map, &[], Some(&c_only()), &[], true); + let statuses = control_statuses(&map, &[], Some(&c_only()), &[], &SbomCoverage::Complete); // Our C rules and cppcheck checked memory safety; gitleaks, secrets. assert_eq!( @@ -321,7 +352,7 @@ mod tests { fn a_mixed_scan_counts_every_language() { let map = ControlMap::cra().expect("map"); let mixed = vec!["c".to_string(), "python".to_string()]; - let statuses = control_statuses(&map, &[], Some(&mixed), &[], true); + let statuses = control_statuses(&map, &[], Some(&mixed), &[], &SbomCoverage::Complete); assert_eq!( state_of(&statuses, "cra-ai-1"), ControlState::NoViolationFound @@ -335,7 +366,7 @@ mod tests { #[test] fn a_scan_without_recorded_languages_only_trusts_language_independent_tools() { let map = ControlMap::cra().expect("map"); - let statuses = control_statuses(&map, &[], Some(&[]), &[], true); + let statuses = control_statuses(&map, &[], Some(&[]), &[], &SbomCoverage::Complete); assert_eq!( state_of(&statuses, "cra-ai-9"), ControlState::NoViolationFound @@ -349,7 +380,7 @@ mod tests { #[test] fn an_empty_sbom_claims_nothing_about_components() { let map = ControlMap::cra().expect("map"); - let statuses = control_statuses(&map, &[], Some(&c_only()), &[], false); + let statuses = control_statuses(&map, &[], Some(&c_only()), &[], &SbomCoverage::Empty); // cra-ai-22/23/33 are checked on components only: with none found, // nothing was checked. for control in ["cra-ai-22", "cra-ai-23", "cra-ai-33"] { @@ -365,14 +396,40 @@ mod tests { ControlState::NoViolationFound ); // With components, the SBOM controls are assessed as before. - let with = control_statuses(&map, &[], Some(&c_only()), &[], true); + let with = control_statuses(&map, &[], Some(&c_only()), &[], &SbomCoverage::Complete); assert_eq!(state_of(&with, "cra-ai-23"), ControlState::NoViolationFound); } + #[test] + fn unresolved_dependencies_claim_nothing_about_components() { + let map = ControlMap::cra().expect("map"); + let unresolved = SbomCoverage::Unresolved(vec!["android/app/build.gradle".into()]); + let statuses = control_statuses(&map, &[], Some(&c_only()), &[], &unresolved); + for control in ["cra-ai-22", "cra-ai-23", "cra-ai-33"] { + assert_eq!( + status_of(&statuses, control).reason, + Some(NotAssessedReason::DependenciesUnresolved { + manifests: vec!["android/app/build.gradle".into()] + }), + "{control}" + ); + } + assert_eq!( + state_of(&statuses, "cra-ai-20"), + ControlState::NoViolationFound + ); + } + #[test] fn a_failed_cve_lookup_claims_nothing_about_component_cves() { let map = ControlMap::cra().expect("map"); - let statuses = control_statuses(&map, &[], Some(&c_only()), &["osv"], true); + let statuses = control_statuses( + &map, + &[], + Some(&c_only()), + &["osv"], + &SbomCoverage::Complete, + ); // cra-ai-22 relies on the CVE lookup (osv) and the SBOM (syft). assert_eq!( status_of(&statuses, "cra-ai-22").reason, @@ -392,7 +449,7 @@ mod tests { #[test] fn nothing_is_passed_before_a_scan() { let map = ControlMap::cra().expect("map"); - let statuses = control_statuses(&map, &[], None, &[], true); + let statuses = control_statuses(&map, &[], None, &[], &SbomCoverage::Complete); assert_eq!(state_of(&statuses, "cra-ai-8"), ControlState::NotAssessed); assert_eq!( status_of(&statuses, "cra-ai-8").reason, diff --git a/compliance-agent/src/evidence/mod.rs b/compliance-agent/src/evidence/mod.rs index 4e57252..883f977 100644 --- a/compliance-agent/src/evidence/mod.rs +++ b/compliance-agent/src/evidence/mod.rs @@ -16,7 +16,7 @@ use serde::Serialize; use sha2::{Digest, Sha256}; use compliance_core::models::oscal_assessment::assess; -use compliance_core::models::{CveAlert, Finding, OnboardedTarget, SbomEntry, ScanRun}; +use compliance_core::models::{CveAlert, Finding, OnboardedTarget, SbomEntry, ScanRun, SkipCode}; use compliance_core::sbom_docs; use crate::error::AgentError; @@ -174,6 +174,26 @@ pub fn failed_tools(inputs: &EvidenceInputs) -> Vec<&'static str> { .collect() } +/// How far the target's SBOM speaks for its components: the last scan's +/// manifests without readable lockfiles (its `sbom_dependencies` skips) make +/// it incomplete, and no components at all make it empty. +pub fn sbom_coverage(inputs: &EvidenceInputs) -> compliance::SbomCoverage { + let unresolved: Vec = inputs + .last_run + .iter() + .flat_map(|run| &run.skipped_stages) + .filter(|s| s.code == Some(SkipCode::DependenciesUnlocked)) + .filter_map(|s| s.subject.clone()) + .collect(); + if !unresolved.is_empty() { + compliance::SbomCoverage::Unresolved(unresolved) + } else if inputs.sbom.is_empty() { + compliance::SbomCoverage::Empty + } else { + compliance::SbomCoverage::Complete + } +} + /// The target's state against every CRA Annex I control. pub fn compliance_of(inputs: &EvidenceInputs) -> Vec { control_map::ControlMap::cra() @@ -183,7 +203,7 @@ pub fn compliance_of(inputs: &EvidenceInputs) -> Vec &inputs.findings, scanned_languages(inputs), &failed_tools(inputs), - !inputs.sbom.is_empty(), + &sbom_coverage(inputs), ); // The catalog's own ratings, next to our state. for status in &mut statuses { diff --git a/compliance-agent/src/pipeline/cve.rs b/compliance-agent/src/pipeline/cve.rs index 1a337e7..bb22550 100644 --- a/compliance-agent/src/pipeline/cve.rs +++ b/compliance-agent/src/pipeline/cve.rs @@ -30,72 +30,104 @@ impl CveScanner { } } + /// Match every SBOM entry with a purl against OSV, attaching the + /// advisories to the entries and returning one alert per advisory. + /// + /// # Returns + /// + /// The alerts, and in [`CveLookup::unchecked`] the components OSV could not + /// speak for: those of a package manager OSV has no advisories for + /// (CocoaPods), and those of a batch OSV refused. Either kind is unknown, + /// not free of CVEs. + /// + /// # Errors + /// + /// Returns `CoreError::Http` when OSV cannot be reached or its answer + /// cannot be read. #[tracing::instrument(skip_all)] pub async fn scan_dependencies( &self, repo_id: &str, entries: &mut [SbomEntry], - ) -> Result, CoreError> { + ) -> Result { tracing::info!("scanning {} SBOM entries for known CVEs", entries.len()); - let mut alerts = Vec::new(); + let mut lookup = CveLookup::default(); - // Batch query OSV.dev - let osv_results = self.query_osv_batch(entries).await?; - for (idx, vulns) in osv_results.into_iter().enumerate() { - if let Some(entry) = entries.get_mut(idx) { - for vuln in &vulns { - entry.known_vulnerabilities.push(VulnRef { - id: vuln.id.clone(), - source: "osv".to_string(), - severity: vuln.severity.clone(), - url: Some(format!("https://osv.dev/vulnerability/{}", vuln.id)), - }); - - let mut alert = CveAlert::new( - vuln.id.clone(), - repo_id.to_string(), - entry.name.clone(), - entry.version.clone(), - CveSource::Osv, - ); - alert.summary = vuln.summary.clone(); - alerts.push(alert); - } + let (osv_results, refused) = self.query_osv_batch(entries).await?; + for (entry, vulns) in entries.iter_mut().zip(osv_results) { + for vuln in vulns { + entry.known_vulnerabilities.push(VulnRef { + id: vuln.id.clone(), + source: "osv".to_string(), + severity: vuln.severity, + url: Some(format!("https://osv.dev/vulnerability/{}", vuln.id)), + }); + let mut alert = CveAlert::new( + vuln.id, + repo_id.to_string(), + entry.name.clone(), + entry.version.clone(), + CveSource::Osv, + ); + alert.summary = vuln.summary; + lookup.alerts.push(alert); } } + lookup.unchecked = entries + .iter() + .enumerate() + .filter(|(i, e)| refused.contains(i) || without_osv_advisories(e)) + .map(|(_, e)| format!("{} {}", e.name, e.version)) + .collect(); // Enrich with NVD CVSS scores - for alert in &mut alerts { + for alert in &mut lookup.alerts { if let Ok(Some(cvss)) = self.query_nvd(&alert.cve_id).await { alert.cvss_score = Some(cvss); } } - Ok(alerts) + Ok(lookup) } - async fn query_osv_batch(&self, entries: &[SbomEntry]) -> Result>, CoreError> { + /// Ask OSV about every entry it has advisories for. + /// + /// # Returns + /// + /// The advisories of each entry, in the order of `entries` (empty for an + /// entry that was not asked about), and the indices of the entries whose + /// batch OSV refused. + /// + /// # Errors + /// + /// Returns `CoreError::Http` when OSV cannot be reached or its answer + /// cannot be read. + async fn query_osv_batch( + &self, + entries: &[SbomEntry], + ) -> Result<(Vec>, Vec), CoreError> { const OSV_BATCH_SIZE: usize = 500; - let queries: Vec<_> = entries + let mut results: Vec> = std::iter::repeat_with(Vec::new) + .take(entries.len()) + .collect(); + let mut refused = Vec::new(); + // Each query keeps the index of its entry: an entry without a purl is + // not asked about, and must not shift the answers onto its neighbours. + let queries: Vec<(usize, &str)> = entries .iter() - .filter_map(|e| { - e.purl.as_ref().map(|purl| { - serde_json::json!({ - "package": { "purl": purl } - }) - }) - }) + .enumerate() + .filter(|(_, e)| !without_osv_advisories(e)) + .filter_map(|(i, e)| e.purl.as_deref().map(|purl| (i, purl))) .collect(); - if queries.is_empty() { - return Ok(Vec::new()); - } - - let mut all_vulns: Vec> = Vec::with_capacity(queries.len()); - for chunk in queries.chunks(OSV_BATCH_SIZE) { - let body = serde_json::json!({ "queries": chunk }); + let body = serde_json::json!({ + "queries": chunk + .iter() + .map(|(_, purl)| serde_json::json!({ "package": { "purl": purl } })) + .collect::>() + }); let resp = self .http @@ -112,8 +144,7 @@ impl CveScanner { let status = resp.status(); let body = resp.text().await.unwrap_or_default(); tracing::warn!("OSV.dev returned {status}: {body}"); - // Push empty results for this chunk so indices stay aligned - all_vulns.extend(std::iter::repeat_with(Vec::new).take(chunk.len())); + refused.extend(chunk.iter().map(|(i, _)| *i)); continue; } @@ -122,24 +153,25 @@ impl CveScanner { CoreError::Http(format!("Failed to parse OSV.dev response: {e}")) })?; - let chunk_vulns = result.results.into_iter().map(|r| { - r.vulns - .unwrap_or_default() - .into_iter() - .map(|v| OsvVuln { - id: v.id, - summary: v.summary, - severity: v.database_specific.and_then(|d| { - d.get("severity").and_then(|s| s.as_str()).map(String::from) - }), - }) - .collect() - }); - - all_vulns.extend(chunk_vulns); + for ((index, _), answer) in chunk.iter().zip(result.results) { + if let Some(slot) = results.get_mut(*index) { + *slot = answer + .vulns + .unwrap_or_default() + .into_iter() + .map(|v| OsvVuln { + id: v.id, + summary: v.summary, + severity: v.database_specific.and_then(|d| { + d.get("severity").and_then(|s| s.as_str()).map(String::from) + }), + }) + .collect(); + } + } } - Ok(all_vulns) + Ok((results, refused)) } async fn query_nvd(&self, cve_id: &str) -> Result, CoreError> { @@ -280,7 +312,7 @@ impl CveScanner { } } -/// What an NVD lookup found, and what it could not check. +/// What a CVE lookup found, and what it could not check. #[derive(Debug, Default)] pub struct CveLookup { /// The CVEs that affect the components in use. @@ -326,6 +358,18 @@ fn record_nvd( .collect() } +/// Purl types of package managers OSV publishes no advisories for. Asking +/// about them returns nothing, which must not read as "no CVEs". +const PURL_TYPES_WITHOUT_OSV: &[&str] = &["pkg:cocoapods/"]; + +/// Whether `entry` belongs to a package manager OSV has no advisories for. +fn without_osv_advisories(entry: &SbomEntry) -> bool { + entry + .purl + .as_deref() + .is_some_and(|purl| PURL_TYPES_WITHOUT_OSV.iter().any(|t| purl.starts_with(t))) +} + /// The CODESYS runtime component (name + version) from an SBOM, if present. The /// runtime carries the version CODESYS advisories key off; the internal library /// components do not. @@ -367,6 +411,17 @@ mod tests { SbomEntry::new("t".into(), name.into(), ver.into(), pm.into()) } + #[test] + fn cocoapods_components_are_not_asked_about_but_reported_unchecked() { + let mut pod = entry("AFNetworking", "2.5.1", "cocoapods"); + pod.purl = Some("pkg:cocoapods/AFNetworking@2.5.1".into()); + let mut jar = entry("okhttp", "3.12.0", "maven"); + jar.purl = Some("pkg:maven/com.squareup.okhttp3/okhttp@3.12.0".into()); + assert!(without_osv_advisories(&pod)); + assert!(!without_osv_advisories(&jar)); + assert!(!without_osv_advisories(&entry("lwIP", "2.1.2", "embedded"))); + } + #[test] fn finds_the_codesys_runtime_component() { let entries = vec![ diff --git a/compliance-agent/src/pipeline/orchestrator.rs b/compliance-agent/src/pipeline/orchestrator.rs index fecdf91..eadae10 100644 --- a/compliance-agent/src/pipeline/orchestrator.rs +++ b/compliance-agent/src/pipeline/orchestrator.rs @@ -310,7 +310,11 @@ impl PipelineOrchestrator { ) .await { - Ok(Ok(alerts)) => alerts, + Ok(Ok(lookup)) => { + self.record_osv_unchecked(scan_run_id, &lookup.unchecked) + .await; + lookup.alerts + } Ok(Err(e)) => { tracing::warn!("[{repo_id}] CVE scanning failed: {e}"); self.record_cve_gap(scan_run_id, "OSV", "the OSV lookup failed") @@ -1125,7 +1129,11 @@ impl PipelineOrchestrator { ) .await { - Ok(Ok(a)) => a, + Ok(Ok(lookup)) => { + self.record_osv_unchecked(scan_run_id, &lookup.unchecked) + .await; + lookup.alerts + } Ok(Err(e)) => { tracing::warn!(target_id, error = %e, "control-app CVE scan failed"); self.record_cve_gap(scan_run_id, "OSV", "the OSV lookup failed") @@ -1594,6 +1602,21 @@ impl PipelineOrchestrator { .await; } + /// Record the components OSV did not check (a package manager without + /// advisories, a refused batch), so the CVE count is not read as complete. + async fn record_osv_unchecked(&self, scan_run_id: &str, unchecked: &[String]) { + if unchecked.is_empty() { + return; + } + self.record_cve_gap( + scan_run_id, + &format!("OSV: {}", component_list(unchecked)), + "these components were not matched against OSV, which has no advisories \ + for their package manager (CocoaPods) or refused the request", + ) + .await; + } + /// Control mapping for the PLC path (`run_plc_scan` is separate from /// `run_pipeline`, which does its own). PLC findings carry /// file_path/line/cwe, so the semantic pass reads each region under its @@ -1761,6 +1784,24 @@ fn planned_phases( /// The skipped-stage id recorded when CVE matching is incomplete. pub const CVE_LOOKUP_STAGE: &str = "cve_lookup"; +/// How many components a skipped stage names before it only counts the rest. +const LISTED_COMPONENTS: usize = 10; + +/// `components` as a readable list, the first [`LISTED_COMPONENTS`] by name +/// and the rest counted: an iOS app can pull in a hundred pods. +fn component_list(components: &[String]) -> String { + let listed = components + .iter() + .take(LISTED_COMPONENTS) + .map(String::as_str) + .collect::>() + .join(", "); + match components.len().saturating_sub(LISTED_COMPONENTS) { + 0 => listed, + more => format!("{listed} and {more} more"), + } +} + /// Extract the scheme + host from a git URL. /// e.g. "https://gitea.example.com/owner/repo.git" -> "https://gitea.example.com" /// e.g. "ssh://git@gitea.example.com:22/owner/repo.git" -> "https://gitea.example.com" @@ -1794,6 +1835,13 @@ mod tests { Artifact, ArtifactAuth, IssueTrackerConfig, TargetType, TrackerType, }; + #[test] + fn a_long_component_list_names_ten_and_counts_the_rest() { + let pods: Vec = (1..=12).map(|i| format!("Pod{i} 1.0")).collect(); + assert_eq!(component_list(&pods[..2]), "Pod1 1.0, Pod2 1.0"); + assert!(component_list(&pods).ends_with("Pod10 1.0 and 2 more")); + } + #[test] fn a_code_target_plans_the_code_stages_in_order() { let mut target = OnboardedTarget::new("fw".to_string(), TargetType::FirmwareRtos); diff --git a/compliance-agent/src/pipeline/sbom/mobile.rs b/compliance-agent/src/pipeline/sbom/mobile.rs new file mode 100644 index 0000000..16754be --- /dev/null +++ b/compliance-agent/src/pipeline/sbom/mobile.rs @@ -0,0 +1,327 @@ +//! Mobile package managers whose dependencies the SBOM cannot list. +//! +//! An Android, iOS or Flutter app declares its dependencies in a manifest +//! (`build.gradle.kts`, `Podfile`, `Package.swift`, `pubspec.yaml`), but only +//! the lockfile beside it says which versions ship. Syft reads the lockfiles +//! and nothing else, so an app without them gets an SBOM with no packages and +//! no CVEs, which reads like a clean result. Generating the lockfiles would run +//! the project's build scripts, which a scan must not do. +//! +//! Unlike npm or Cargo, these manifests rarely sit at the repository root: a +//! React Native or Flutter app keeps them under `android/` and `ios/`, a native +//! app under `app/` or next to its Xcode project. So the tree is walked, and an +//! ecosystem counts as locked when any of its lockfiles is anywhere in it: a +//! Gradle module or a Dart package without a lockfile of its own is normal +//! when the app that uses it has one. + +use std::path::Path; + +use super::UnlockedEcosystem; + +/// How deep manifests are looked for. Deep enough for a React Native app's +/// `android/app/build.gradle` inside a monorepo package. +const MAX_DEPTH: usize = 8; + +/// Directories never searched: build output, installed dependencies and tool +/// caches, which hold other projects' manifests and lockfiles. +const SKIPPED_DIRS: &[&str] = &[ + ".git", + ".gradle", + ".dart_tool", + ".symlinks", + "build", + "DerivedData", + "node_modules", + "Pods", + "Carthage", +]; + +/// A mobile package manager: what declares its dependencies and what pins +/// them. +struct Ecosystem { + /// File names that declare dependencies. + manifests: &'static [&'static str], + /// File names that pin versions; any one of them anywhere in the tree + /// counts. + lockfiles: &'static [&'static str], + /// Why the versions are not read. + problem: &'static str, + /// What to commit so they are. + remedy: &'static str, +} + +const GRADLE: Ecosystem = Ecosystem { + manifests: &[ + "build.gradle", + "build.gradle.kts", + "settings.gradle", + "settings.gradle.kts", + ], + lockfiles: &["gradle.lockfile", "settings-gradle.lockfile"], + problem: "declares Gradle dependencies but no gradle.lockfile pins them", + remedy: "enable Gradle dependency locking (`dependencyLocking { lockAllConfigurations() }`) \ + and commit the gradle.lockfile files (`./gradlew dependencies --write-locks`)", +}; + +const COCOAPODS: Ecosystem = Ecosystem { + manifests: &["Podfile"], + lockfiles: &["Podfile.lock"], + problem: "declares CocoaPods dependencies but no Podfile.lock pins them", + remedy: "commit Podfile.lock", +}; + +const SWIFTPM: Ecosystem = Ecosystem { + manifests: &["Package.swift"], + lockfiles: &["Package.resolved"], + problem: "declares Swift packages but no Package.resolved pins them", + remedy: "commit Package.resolved (in an Xcode project it lives under \ + `*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/`)", +}; + +const PUB: Ecosystem = Ecosystem { + manifests: &["pubspec.yaml"], + lockfiles: &["pubspec.lock"], + problem: "declares Dart/Flutter dependencies but no pubspec.lock pins them", + remedy: "commit the app's pubspec.lock", +}; + +/// Carthage has a lockfile, but no SBOM tool reads it, so it is reported +/// whether or not `Cartfile.resolved` is present. +const CARTHAGE: Ecosystem = Ecosystem { + manifests: &["Cartfile"], + lockfiles: &[], + problem: "declares Carthage dependencies, which no SBOM tool reads", + remedy: "move them to Swift Package Manager or CocoaPods, or list them by hand", +}; + +const ECOSYSTEMS: [&Ecosystem; 5] = [&GRADLE, &COCOAPODS, &SWIFTPM, &PUB, &CARTHAGE]; + +/// Where [`SWIFTPM`] sits in [`ECOSYSTEMS`]. +const SWIFTPM_AT: usize = 2; + +/// Marks an Xcode project that uses Swift packages without a `Package.swift`. +const XCODE_PACKAGE_REFERENCE: &str = "XCRemoteSwiftPackageReference"; + +/// What the walk saw: the shallowest manifest of each ecosystem (its depth +/// and relative path) and whether any of its lockfiles exists. +#[derive(Default)] +struct Seen { + manifest: [Option<(usize, String)>; ECOSYSTEMS.len()], + locked: [bool; ECOSYSTEMS.len()], +} + +impl Seen { + /// Keep `path` as ecosystem `i`'s manifest unless a shallower one (or an + /// earlier one at the same depth) was already seen: the app's own + /// manifest names the gap better than a nested library's. + fn manifest(&mut self, i: usize, depth: usize, path: impl FnOnce() -> String) { + if self.manifest[i] + .as_ref() + .is_none_or(|(seen_depth, _)| depth < *seen_depth) + { + self.manifest[i] = Some((depth, path())); + } + } +} + +/// The mobile ecosystems under `root` that declare dependencies the SBOM +/// cannot list, one entry per ecosystem naming its shallowest manifest. +/// +/// # Arguments +/// +/// * `root` - the checked-out or unpacked source tree +/// +/// # Returns +/// +/// An empty list when the tree has no mobile manifests or every one is backed +/// by a lockfile the SBOM reads. +pub(crate) fn unlocked_mobile_ecosystems(root: &Path) -> Vec { + let seen = walk(root); + ECOSYSTEMS + .iter() + .zip(seen.manifest) + .zip(seen.locked) + .filter_map(|((eco, manifest), locked)| { + let (_, manifest) = manifest?; + (!locked).then_some(UnlockedEcosystem { + manifest, + problem: eco.problem, + remedy: eco.remedy, + }) + }) + .collect() +} + +/// Walk `root` once, recording manifests and lockfiles of every ecosystem. +fn walk(root: &Path) -> Seen { + let mut seen = Seen::default(); + 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()); + for entry in entries { + let name = entry.file_name().to_string_lossy(); + let relative = || { + entry + .path() + .strip_prefix(root) + .map(|p| p.to_string_lossy().replace('\\', "/")) + .unwrap_or_else(|_| name.to_string()) + }; + for (i, eco) in ECOSYSTEMS.iter().enumerate() { + if eco.lockfiles.contains(&name.as_ref()) { + seen.locked[i] = true; + } + if eco.manifests.contains(&name.as_ref()) { + seen.manifest(i, entry.depth(), relative); + } + } + // An Xcode project can depend on Swift packages with no Package.swift + // in the tree; its project file names them. + if name == "project.pbxproj" + && seen.manifest[SWIFTPM_AT].is_none() + && std::fs::read_to_string(entry.path()) + .is_ok_and(|text| text.contains(XCODE_PACKAGE_REFERENCE)) + { + seen.manifest(SWIFTPM_AT, entry.depth(), relative); + } + } + seen +} + +#[cfg(test)] +#[allow(clippy::expect_used)] +mod tests { + use super::*; + + /// A scratch tree holding `files` (relative path, content), removed on + /// drop. + struct Tree(std::path::PathBuf); + impl Tree { + fn path(&self) -> &Path { + &self.0 + } + } + impl Drop for Tree { + fn drop(&mut self) { + let _ = std::fs::remove_dir_all(&self.0); + } + } + + fn tree(files: &[(&str, &str)]) -> Tree { + let dir = std::env::temp_dir().join(format!("cs-mobile-{}", uuid::Uuid::new_v4())); + for (path, content) in files { + let full = dir.join(path); + if let Some(parent) = full.parent() { + std::fs::create_dir_all(parent).expect("mkdir"); + } + std::fs::write(full, content).expect("write"); + } + Tree(dir) + } + + fn manifests(root: &Path) -> Vec { + unlocked_mobile_ecosystems(root) + .into_iter() + .map(|e| e.manifest) + .collect() + } + + #[test] + fn swiftpm_sits_where_the_xcode_check_expects_it() { + assert!(std::ptr::eq(ECOSYSTEMS[SWIFTPM_AT], &SWIFTPM)); + } + + #[test] + fn a_gradle_app_without_a_lockfile_is_reported_by_its_nested_manifest() { + let dir = tree(&[("android/app/build.gradle.kts", "dependencies {}")]); + let found = unlocked_mobile_ecosystems(dir.path()); + assert_eq!(found.len(), 1); + assert_eq!(found[0].manifest, "android/app/build.gradle.kts"); + assert!(found[0].problem.contains("gradle.lockfile")); + } + + #[test] + fn one_lockfile_anywhere_locks_the_ecosystem() { + let dir = tree(&[ + ("settings.gradle.kts", ""), + ("core/build.gradle.kts", ""), + ("app/build.gradle.kts", ""), + ("app/gradle.lockfile", "empty="), + ("ios/Podfile", ""), + ("ios/Podfile.lock", ""), + ("pubspec.yaml", ""), + ("pubspec.lock", ""), + ("packages/widgets/pubspec.yaml", ""), + ]); + assert!(manifests(dir.path()).is_empty()); + } + + #[test] + fn each_unlocked_ecosystem_is_reported_once() { + let dir = tree(&[ + ("ios/Podfile", ""), + ("Package.swift", ""), + ("pubspec.yaml", ""), + ("lib/pubspec.yaml", ""), + ]); + assert_eq!( + manifests(dir.path()), + vec!["ios/Podfile", "Package.swift", "pubspec.yaml"] + ); + } + + #[test] + fn an_xcode_project_using_swift_packages_needs_its_package_resolved() { + let pbxproj = "/* XCRemoteSwiftPackageReference \"swift-nio\" */"; + let unlocked = tree(&[("PumpApp.xcodeproj/project.pbxproj", pbxproj)]); + assert_eq!( + manifests(unlocked.path()), + vec!["PumpApp.xcodeproj/project.pbxproj"] + ); + + let locked = tree(&[ + ("PumpApp.xcodeproj/project.pbxproj", pbxproj), + ( + "PumpApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved", + "{}", + ), + ]); + assert!(manifests(locked.path()).is_empty()); + } + + #[test] + fn an_xcode_project_without_swift_packages_is_not_reported() { + let dir = tree(&[("PumpApp.xcodeproj/project.pbxproj", "// no packages")]); + assert!(manifests(dir.path()).is_empty()); + } + + #[test] + fn carthage_is_reported_even_with_its_resolved_file() { + let dir = tree(&[("Cartfile", ""), ("Cartfile.resolved", "")]); + assert_eq!(manifests(dir.path()), vec!["Cartfile"]); + } + + #[test] + fn installed_dependencies_and_build_output_are_not_searched() { + let dir = tree(&[ + ("node_modules/react-native/android/build.gradle", ""), + ("ios/Pods/Local Podspecs/Podfile", ""), + ("android/build/intermediates/pubspec.yaml", ""), + ]); + assert!(manifests(dir.path()).is_empty()); + } + + #[test] + fn a_tree_without_mobile_manifests_reports_nothing() { + let dir = tree(&[("package.json", "{}"), ("src/main.c", "")]); + assert!(manifests(dir.path()).is_empty()); + } +} diff --git a/compliance-agent/src/pipeline/sbom/mod.rs b/compliance-agent/src/pipeline/sbom/mod.rs index 3e1318d..7c65a09 100644 --- a/compliance-agent/src/pipeline/sbom/mod.rs +++ b/compliance-agent/src/pipeline/sbom/mod.rs @@ -1,4 +1,5 @@ mod cargo_audit; +mod mobile; mod syft; use std::path::Path; @@ -62,8 +63,9 @@ impl Scanner for SbomScanner { /// not run here, or it may have failed). Syft reports nothing for it, so the /// SBOM would be silently short of those dependencies. pub(crate) struct UnlockedEcosystem { - /// What the tree declares (`package.json`, `pyproject.toml`). - pub manifest: &'static str, + /// What the tree declares, relative to its root (`package.json`, + /// `android/app/build.gradle.kts`). + pub manifest: String, /// Why its versions were not read. pub problem: &'static str, /// What to commit so they are. @@ -86,6 +88,10 @@ const NPM_LOCKFILES: &[&str] = &[ /// after [`generate_lockfiles`]: it reads the tree as Syft will see it, so a /// lockfile that was generated counts and one that could not be does not. An /// empty result means every manifest present is backed by a lockfile. +/// +/// npm, Python and Cargo are checked at the root, where their workspaces keep +/// the lockfile; the mobile package managers anywhere in the tree (see +/// [`mobile`]). pub(crate) fn unlocked_ecosystems(repo_path: &Path) -> Vec { let has = |name: &str| repo_path.join(name).exists(); let mut out = Vec::new(); @@ -98,13 +104,13 @@ pub(crate) fn unlocked_ecosystems(repo_path: &Path) -> Vec { // Bun's binary lockfile is opaque to the SBOM tooling; its text // successor (the default since Bun 1.2) is read. out.push(UnlockedEcosystem { - manifest: "package.json", + manifest: "package.json".into(), problem: "is locked only by bun.lockb, Bun's binary lockfile, which is not read", remedy: "commit the text bun.lock (`bun install --save-text-lockfile`)", }); } else if !readable { out.push(UnlockedEcosystem { - manifest: "package.json", + manifest: "package.json".into(), problem: "declares dependencies but no lockfile pins them", remedy: "commit package-lock.json, yarn.lock, pnpm-lock.yaml or bun.lock", }); @@ -116,7 +122,7 @@ pub(crate) fn unlocked_ecosystems(repo_path: &Path) -> Vec { if let Some(manifest) = python_manifest { if !PIP_LOCKFILES.iter().any(|f| has(f)) { out.push(UnlockedEcosystem { - manifest, + manifest: manifest.into(), problem: "declares dependencies but no lockfile pins them", remedy: "commit requirements.txt, poetry.lock, Pipfile.lock or uv.lock", }); @@ -124,11 +130,12 @@ pub(crate) fn unlocked_ecosystems(repo_path: &Path) -> Vec { } if has("Cargo.toml") && !has("Cargo.lock") { out.push(UnlockedEcosystem { - manifest: "Cargo.toml", + manifest: "Cargo.toml".into(), problem: "declares dependencies but no lockfile pins them", remedy: "commit Cargo.lock", }); } + out.extend(mobile::unlocked_mobile_ecosystems(repo_path)); out } @@ -347,7 +354,7 @@ mod unlocked_tests { } } - fn names(tree: &Tree) -> Vec<&'static str> { + fn names(tree: &Tree) -> Vec { unlocked_ecosystems(&tree.0) .into_iter() .map(|e| e.manifest) diff --git a/compliance-agent/src/pipeline/sbom/syft.rs b/compliance-agent/src/pipeline/sbom/syft.rs index 63d4ce5..661a036 100644 --- a/compliance-agent/src/pipeline/sbom/syft.rs +++ b/compliance-agent/src/pipeline/sbom/syft.rs @@ -55,7 +55,7 @@ pub(super) async fn run_syft(repo_path: &Path, repo_id: &str) -> Result Option { Some(parts.join(" OR ")) } +/// `purl` in the form advisory databases look it up by. +/// +/// Syft names a Swift package by its repository URL followed by the package +/// identity again, `pkg:swift/github.com/apple/swift-nio.git/swift-nio@2.40.0`. +/// The purl spec (and OSV, which keys Swift advisories by repository URL) +/// expects `pkg:swift/github.com/apple/swift-nio@2.40.0`: in Syft's form every +/// Swift package matched no advisory at all. Every other purl, and a Swift one +/// already in that form, is returned unchanged. +fn canonical_purl(purl: String) -> String { + let Some(rest) = purl.strip_prefix("pkg:swift/") else { + return purl; + }; + // The version, qualifiers and subpath follow the name unchanged. + let (path, tail) = rest.split_at(rest.find(['@', '?', '#']).unwrap_or(rest.len())); + let Some((namespace, name)) = path.rsplit_once('/') else { + return purl; + }; + let repository = namespace.strip_suffix(".git").unwrap_or(namespace); + match repository.rsplit_once('/') { + Some((_, repo_name)) if repo_name.eq_ignore_ascii_case(name) => { + format!("pkg:swift/{repository}{tail}") + } + _ => purl, + } +} + /// Extract the ecosystem/package-manager from a PURL string. /// e.g. "pkg:npm/lodash@4.17.21" -> "npm", "pkg:cargo/serde@1.0" -> "cargo" fn extract_ecosystem_from_purl(purl: &str) -> Option { @@ -143,6 +169,32 @@ fn extract_ecosystem_from_purl(purl: &str) -> Option { mod tests { use super::*; + #[test] + fn a_swift_purl_is_keyed_by_its_repository() { + assert_eq!( + canonical_purl( + "pkg:swift/github.com/apple/swift-nio-http2.git/swift-nio-http2@1.19.0".into() + ), + "pkg:swift/github.com/apple/swift-nio-http2@1.19.0" + ); + assert_eq!( + canonical_purl("pkg:swift/github.com/Alamofire/Alamofire/alamofire@5.6.0".into()), + "pkg:swift/github.com/Alamofire/Alamofire@5.6.0" + ); + } + + #[test] + fn a_canonical_or_foreign_purl_is_left_alone() { + for purl in [ + "pkg:swift/github.com/apple/swift-nio-http2@1.19.0", + "pkg:swift/swift-nio@2.0.0", + "pkg:maven/com.squareup.okhttp3/okhttp@3.12.0", + "pkg:cocoapods/AFNetworking@2.5.1", + ] { + assert_eq!(canonical_purl(purl.into()), purl); + } + } + // --- extract_ecosystem_from_purl tests --- #[test] diff --git a/compliance-agent/src/scheduler.rs b/compliance-agent/src/scheduler.rs index ac384ad..0ca7f29 100644 --- a/compliance-agent/src/scheduler.rs +++ b/compliance-agent/src/scheduler.rs @@ -253,8 +253,10 @@ async fn monitor_cves(agent: &ComplianceAgent, tenant_id: &str) { }; // Scan dependencies for CVEs + // The periodic monitor only refreshes alerts; a scan records which + // components could not be checked. let alerts = match scanner.scan_dependencies(&repo_id, &mut repo_entries).await { - Ok(a) => a, + Ok(lookup) => lookup.alerts, Err(e) => { tracing::warn!("CVE monitor: scan failed for {repo_name}: {e}"); continue; diff --git a/compliance-dashboard/src/i18n/texts.rs b/compliance-dashboard/src/i18n/texts.rs index 50ca5b2..1a440e1 100644 --- a/compliance-dashboard/src/i18n/texts.rs +++ b/compliance-dashboard/src/i18n/texts.rs @@ -2044,6 +2044,12 @@ pub mod compliance { de: "Nicht bewertet", en: "Not assessed", }; + pub const DEPENDENCIES_UNRESOLVED: Text = Text { + de: "Die Abhängigkeiten dieser Manifeste wurden nicht aufgelöst (kein Lockfile, \ + oder eines, das kein Werkzeug liest), die Stückliste ist also unvollständig:", + en: "The dependencies these manifests declare were not resolved (no lockfile, or \ + one no tool reads), so the SBOM is incomplete:", + }; pub const NO_COMPONENTS: Text = Text { de: "Die letzte Prüfung hat keine Komponenten erkannt, also wurde nichts geprüft. \ Die Stückliste entsteht aus einem Lockfile, den Firmware-Quellen oder einem \ @@ -2209,6 +2215,17 @@ pub mod compliance { ), "languages_unknown" => LANGUAGES_UNKNOWN.get(lang).to_string(), "no_components" => NO_COMPONENTS.get(lang).to_string(), + "dependencies_unresolved" => format!( + "{} {}", + DEPENDENCIES_UNRESOLVED.get(lang), + reason["manifests"] + .as_array() + .map_or(&[][..], Vec::as_slice) + .iter() + .filter_map(serde_json::Value::as_str) + .collect::>() + .join(", ") + ), "tool_failed" => format!( "{} {}", TOOL_FAILED.get(lang), @@ -2273,6 +2290,12 @@ pub mod compliance { not_assessed_reason(&serde_json::json!({ "kind": "no_components" }), Lang::De) .is_some_and(|text| text.contains("keine Komponenten")) ); + let unresolved = serde_json::json!({ + "kind": "dependencies_unresolved", + "manifests": ["android/app/build.gradle", "ios/Podfile"], + }); + assert!(not_assessed_reason(&unresolved, Lang::En) + .is_some_and(|text| text.ends_with("android/app/build.gradle, ios/Podfile"))); assert_eq!( not_assessed_reason(&serde_json::Value::Null, Lang::En), None diff --git a/docs/guide/sbom.md b/docs/guide/sbom.md index 6ccdc89..49afb9d 100644 --- a/docs/guide/sbom.md +++ b/docs/guide/sbom.md @@ -16,6 +16,17 @@ Prüfwerk builds the SBOM during each scan: `requirements.txt`, `poetry.lock`, `Pipfile.lock`, `uv.lock`). A manifest without a lockfile gives no versions; the scan lists it under **Nicht ausgeführt** (see [Prüfungen](/guide/scanning#what-the-scanner-runs-on-your-code)). +- **Mobile apps** -- the lockfiles of Android, iOS and Flutter apps, wherever + they sit in the tree (`android/`, `ios/`, an Xcode project): `gradle.lockfile`, + `Podfile.lock`, `Package.resolved` (also the one inside + `*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/`) and `pubspec.lock`. + Gradle writes `gradle.lockfile` only with dependency locking switched on + (`dependencyLocking { lockAllConfigurations() }`, then + `./gradlew dependencies --write-locks`). Without it, and for Carthage, whose + `Cartfile.resolved` no tool reads, the scan reports the manifest under + **Nicht ausgeführt** and the SBOM requirements of the CRA view are + **Nicht bewertet**: an app whose dependencies are unknown is not shown as + clean. - **Libraries copied into a firmware tree** -- microcontroller projects carry their RTOS, TCP/IP stack and TLS library as source, with no manifest. Prüfwerk recognises **FreeRTOS**, **FreeRTOS+TCP**, **lwIP**, **Mbed TLS**, **wolfSSL** @@ -36,8 +47,9 @@ Package dependencies are matched against [OSV.dev](https://osv.dev/). Libraries copied into a firmware tree and the CODESYS runtime have no package identifier OSV could look up, so they are matched against [NVD](https://nvd.nist.gov/) by CPE: all CVEs of the product are fetched and their affected version ranges are -compared with the version in use. Components that could not be matched are -listed on the scan run under **CVE-Abgleich unvollständig**. +compared with the version in use. OSV publishes no advisories for CocoaPods, so +pods are not matched. Components that could not be matched are listed on the +scan run under **CVE-Abgleich unvollständig**. Known components are re-checked hourly, so a CVE published against an unchanged component still raises an alert. diff --git a/fixtures/nightly/baselines/mobile-android-gradle-catalog.json b/fixtures/nightly/baselines/mobile-android-gradle-catalog.json new file mode 100644 index 0000000..dcaf40e --- /dev/null +++ b/fixtures/nightly/baselines/mobile-android-gradle-catalog.json @@ -0,0 +1,10 @@ +{ + "scan_status": "completed", + "skipped_stages": [ + "sbom_dependencies" + ], + "sbom": [], + "findings": [], + "cves": [], + "registry_rules": [] +} diff --git a/fixtures/nightly/baselines/mobile-android-gradle-lock.json b/fixtures/nightly/baselines/mobile-android-gradle-lock.json new file mode 100644 index 0000000..1092d79 --- /dev/null +++ b/fixtures/nightly/baselines/mobile-android-gradle-lock.json @@ -0,0 +1,16 @@ +{ + "scan_status": "completed", + "skipped_stages": [], + "sbom": [ + "maven:gson@2.8.8", + "maven:okhttp@3.12.0", + "maven:okio@1.15.0" + ], + "findings": [], + "cves": [ + "GHSA-3cqm-mf7h-prrj", + "GHSA-4jrv-ppp4-jm57", + "GHSA-w33c-445m-f8w7" + ], + "registry_rules": [] +} diff --git a/fixtures/nightly/baselines/mobile-flutter.json b/fixtures/nightly/baselines/mobile-flutter.json new file mode 100644 index 0000000..de02fd2 --- /dev/null +++ b/fixtures/nightly/baselines/mobile-flutter.json @@ -0,0 +1,15 @@ +{ + "scan_status": "completed", + "skipped_stages": [ + "sbom_dependencies" + ], + "sbom": [ + "pub:dio@3.0.10", + "pub:pump_app@UNKNOWN" + ], + "findings": [], + "cves": [ + "GHSA-9324-jv53-9cc8" + ], + "registry_rules": [] +} diff --git a/fixtures/nightly/baselines/mobile-ios-cocoapods.json b/fixtures/nightly/baselines/mobile-ios-cocoapods.json new file mode 100644 index 0000000..27c868c --- /dev/null +++ b/fixtures/nightly/baselines/mobile-ios-cocoapods.json @@ -0,0 +1,13 @@ +{ + "scan_status": "completed", + "skipped_stages": [ + "cve_lookup" + ], + "sbom": [ + "cocoapods:AFNetworking/NSURLConnection@2.5.1", + "cocoapods:AFNetworking@2.5.1" + ], + "findings": [], + "cves": [], + "registry_rules": [] +} diff --git a/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json b/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json new file mode 100644 index 0000000..dcaf40e --- /dev/null +++ b/fixtures/nightly/baselines/mobile-ios-spm-unlocked.json @@ -0,0 +1,10 @@ +{ + "scan_status": "completed", + "skipped_stages": [ + "sbom_dependencies" + ], + "sbom": [], + "findings": [], + "cves": [], + "registry_rules": [] +} diff --git a/fixtures/nightly/baselines/mobile-ios-spm-xcode.json b/fixtures/nightly/baselines/mobile-ios-spm-xcode.json new file mode 100644 index 0000000..37931e4 --- /dev/null +++ b/fixtures/nightly/baselines/mobile-ios-spm-xcode.json @@ -0,0 +1,18 @@ +{ + "scan_status": "completed", + "skipped_stages": [], + "sbom": [ + "swift:swift-nio-http2@1.19.0" + ], + "findings": [], + "cves": [ + "GHSA-4px2-pw77-vc85", + "GHSA-ccw9-q5h2-8c2w", + "GHSA-pgfx-g6rc-8cjv", + "GHSA-q36x-r5x4-h4q6", + "GHSA-qppj-fm5r-hxr3", + "GHSA-w3f6-pc54-gfw7", + "GHSA-xvr7-p2c6-j83w" + ], + "registry_rules": [] +} diff --git a/fixtures/nightly/baselines/mobile-react-native.json b/fixtures/nightly/baselines/mobile-react-native.json new file mode 100644 index 0000000..cc01e07 --- /dev/null +++ b/fixtures/nightly/baselines/mobile-react-native.json @@ -0,0 +1,47 @@ +{ + "scan_status": "completed", + "skipped_stages": [ + "sbom_dependencies" + ], + "sbom": [ + "npm:axios@0.21.1", + "npm:checkout-npm-lock-v3@2.1.0", + "npm:express@4.17.1", + "npm:lodash@4.17.20" + ], + "findings": [], + "cves": [ + "GHSA-29mw-wpgm-hmr9", + "GHSA-35jh-r3h4-6jhm", + "GHSA-3g43-6gmg-66jw", + "GHSA-3p68-rc4w-qgx5", + "GHSA-43fc-jf86-j433", + "GHSA-5c9x-8gcm-mpgx", + "GHSA-62hf-57xw-28j9", + "GHSA-6chq-wfr3-2hj9", + "GHSA-7q8q-rj6j-mhjq", + "GHSA-898c-q2cr-xwhg", + "GHSA-cph5-m8f7-6c5x", + "GHSA-f23m-r3pf-42rh", + "GHSA-fvcv-3m26-pcqx", + "GHSA-hfxv-24rg-xrqf", + "GHSA-j5f8-grm9-p9fc", + "GHSA-jr5f-v2jv-69x6", + "GHSA-m7pr-hjqh-92cm", + "GHSA-mmx7-hfxf-jppx", + "GHSA-p92q-9vqr-4j8v", + "GHSA-pf86-5x62-jrwf", + "GHSA-pjwm-pj3p-43mv", + "GHSA-pmwg-cvhr-8vh7", + "GHSA-qw6h-vgh9-j6wx", + "GHSA-r5fr-rjxr-66jc", + "GHSA-rv95-896h-c2vc", + "GHSA-vf2m-468p-8v99", + "GHSA-w9j2-pvgh-6h63", + "GHSA-wf5p-g6vw-rhxx", + "GHSA-xhjh-pmcv-23jw", + "GHSA-xx6v-rp6x-q39c", + "GHSA-xxjr-mmjv-4gpg" + ], + "registry_rules": [] +} diff --git a/fixtures/nightly/mobile/README.md b/fixtures/nightly/mobile/README.md new file mode 100644 index 0000000..ce27a4f --- /dev/null +++ b/fixtures/nightly/mobile/README.md @@ -0,0 +1,18 @@ +# Mobile app fixtures (#434) + +One directory per way an app pins (or fails to pin) its dependencies, uploaded +as a source archive. They prove that no mobile app ends with "0 packages, +0 CVEs" unless the scan also says why. + +| Directory | What it pins | Expected | +|---|---|---| +| `android-gradle-lock` | `app/gradle.lockfile` (okhttp 3.12.0, gson 2.8.8) | 3 Maven components with their advisories | +| `android-gradle-catalog` | nothing: `libs.versions.toml` plus a literal coordinate | none; a recorded `sbom_dependencies` skip | +| `ios-cocoapods` | `Podfile.lock` (AFNetworking 2.5.1) | 2 pods; a recorded `cve_lookup` skip, as OSV has no CocoaPods advisories | +| `ios-spm-xcode` | `Package.resolved` inside the Xcode project (swift-nio-http2 1.19.0) | 1 Swift component with its advisories (needs the purl in repository form) | +| `ios-spm-unlocked` | nothing: the Xcode project names a Swift package | none; a recorded `sbom_dependencies` skip naming `project.pbxproj` | +| `flutter` | `pubspec.lock` (dio 3.0.10); the Android host app is unlocked | the Dart packages; a recorded `sbom_dependencies` skip | +| `react-native` | `package-lock.json`; neither `ios/Podfile` nor the Gradle app is locked | the npm packages; a recorded `sbom_dependencies` skip | + +The code files only make each tree look like the app it stands for; they plant +no SAST findings yet (mobile rules are #437). diff --git a/fixtures/nightly/mobile/android-gradle-catalog/app/build.gradle.kts b/fixtures/nightly/mobile/android-gradle-catalog/app/build.gradle.kts new file mode 100644 index 0000000..8d12f7a --- /dev/null +++ b/fixtures/nightly/mobile/android-gradle-catalog/app/build.gradle.kts @@ -0,0 +1,5 @@ +dependencies { + implementation(libs.okhttp) + implementation(libs.gson) + implementation("org.bouncycastle:bcprov-jdk15on:1.60") +} diff --git a/fixtures/nightly/mobile/android-gradle-catalog/gradle/libs.versions.toml b/fixtures/nightly/mobile/android-gradle-catalog/gradle/libs.versions.toml new file mode 100644 index 0000000..221b888 --- /dev/null +++ b/fixtures/nightly/mobile/android-gradle-catalog/gradle/libs.versions.toml @@ -0,0 +1,7 @@ +[versions] +okhttp = "3.12.0" +gson = "2.8.8" + +[libraries] +okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } +gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" } diff --git a/fixtures/nightly/mobile/android-gradle-catalog/settings.gradle.kts b/fixtures/nightly/mobile/android-gradle-catalog/settings.gradle.kts new file mode 100644 index 0000000..7c1a18b --- /dev/null +++ b/fixtures/nightly/mobile/android-gradle-catalog/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "pump-app" +include(":app") diff --git a/fixtures/nightly/mobile/android-gradle-lock/app/build.gradle.kts b/fixtures/nightly/mobile/android-gradle-lock/app/build.gradle.kts new file mode 100644 index 0000000..96a5867 --- /dev/null +++ b/fixtures/nightly/mobile/android-gradle-lock/app/build.gradle.kts @@ -0,0 +1,6 @@ +plugins { id("com.android.application") } +dependencies { + implementation("com.squareup.okhttp3:okhttp:3.12.0") + implementation("com.google.code.gson:gson:2.8.8") +} +dependencyLocking { lockAllConfigurations() } diff --git a/fixtures/nightly/mobile/android-gradle-lock/app/gradle.lockfile b/fixtures/nightly/mobile/android-gradle-lock/app/gradle.lockfile new file mode 100644 index 0000000..dc70dd6 --- /dev/null +++ b/fixtures/nightly/mobile/android-gradle-lock/app/gradle.lockfile @@ -0,0 +1,7 @@ +# This is a Gradle generated file for dependency locking. +# Manual edits can break the build and are not advised. +# This file is expected to be part of source control. +com.google.code.gson:gson:2.8.8=debugRuntimeClasspath,releaseRuntimeClasspath +com.squareup.okhttp3:okhttp:3.12.0=debugRuntimeClasspath,releaseRuntimeClasspath +com.squareup.okio:okio:1.15.0=debugRuntimeClasspath,releaseRuntimeClasspath +empty= diff --git a/fixtures/nightly/mobile/android-gradle-lock/app/src/main/java/com/example/pump/PumpClient.kt b/fixtures/nightly/mobile/android-gradle-lock/app/src/main/java/com/example/pump/PumpClient.kt new file mode 100644 index 0000000..bf6638a --- /dev/null +++ b/fixtures/nightly/mobile/android-gradle-lock/app/src/main/java/com/example/pump/PumpClient.kt @@ -0,0 +1,14 @@ +package com.example.pump + +import okhttp3.OkHttpClient +import okhttp3.Request + +/** Reads the pump's status from the plant gateway. */ +class PumpClient(private val gateway: String) { + private val http = OkHttpClient() + + fun status(): String? { + val request = Request.Builder().url("$gateway/api/pump/status").build() + return http.newCall(request).execute().body()?.string() + } +} diff --git a/fixtures/nightly/mobile/android-gradle-lock/build.gradle.kts b/fixtures/nightly/mobile/android-gradle-lock/build.gradle.kts new file mode 100644 index 0000000..c153e67 --- /dev/null +++ b/fixtures/nightly/mobile/android-gradle-lock/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { + id("com.android.application") version "8.5.0" apply false +} diff --git a/fixtures/nightly/mobile/android-gradle-lock/settings.gradle.kts b/fixtures/nightly/mobile/android-gradle-lock/settings.gradle.kts new file mode 100644 index 0000000..7c1a18b --- /dev/null +++ b/fixtures/nightly/mobile/android-gradle-lock/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "pump-app" +include(":app") diff --git a/fixtures/nightly/mobile/flutter/android/app/build.gradle b/fixtures/nightly/mobile/flutter/android/app/build.gradle new file mode 100644 index 0000000..2431c11 --- /dev/null +++ b/fixtures/nightly/mobile/flutter/android/app/build.gradle @@ -0,0 +1,7 @@ +plugins { + id "com.android.application" + id "dev.flutter.flutter-gradle-plugin" +} +dependencies { + implementation "androidx.work:work-runtime:2.7.0" +} diff --git a/fixtures/nightly/mobile/flutter/lib/main.dart b/fixtures/nightly/mobile/flutter/lib/main.dart new file mode 100644 index 0000000..f66f8b3 --- /dev/null +++ b/fixtures/nightly/mobile/flutter/lib/main.dart @@ -0,0 +1,7 @@ +import 'package:dio/dio.dart'; + +/// Reads the pump's status from the plant gateway. +Future pumpStatus(String gateway) async { + final response = await Dio().get('$gateway/api/pump/status'); + return response.data.toString(); +} diff --git a/fixtures/nightly/mobile/flutter/pubspec.lock b/fixtures/nightly/mobile/flutter/pubspec.lock new file mode 100644 index 0000000..d6840ce --- /dev/null +++ b/fixtures/nightly/mobile/flutter/pubspec.lock @@ -0,0 +1,10 @@ +packages: + dio: + dependency: "direct main" + description: + name: dio + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.10" +sdks: + dart: ">=2.12.0 <3.0.0" diff --git a/fixtures/nightly/mobile/flutter/pubspec.yaml b/fixtures/nightly/mobile/flutter/pubspec.yaml new file mode 100644 index 0000000..3136a63 --- /dev/null +++ b/fixtures/nightly/mobile/flutter/pubspec.yaml @@ -0,0 +1,3 @@ +name: pump_app +dependencies: + dio: 3.0.10 diff --git a/fixtures/nightly/mobile/ios-cocoapods/Podfile b/fixtures/nightly/mobile/ios-cocoapods/Podfile new file mode 100644 index 0000000..8d4ceae --- /dev/null +++ b/fixtures/nightly/mobile/ios-cocoapods/Podfile @@ -0,0 +1,4 @@ +platform :ios, '12.0' +target 'PumpApp' do + pod 'AFNetworking', '2.5.1' +end diff --git a/fixtures/nightly/mobile/ios-cocoapods/Podfile.lock b/fixtures/nightly/mobile/ios-cocoapods/Podfile.lock new file mode 100644 index 0000000..5d6a9b6 --- /dev/null +++ b/fixtures/nightly/mobile/ios-cocoapods/Podfile.lock @@ -0,0 +1,18 @@ +PODS: + - AFNetworking (2.5.1): + - AFNetworking/NSURLConnection (= 2.5.1) + - AFNetworking/NSURLConnection (2.5.1) + +DEPENDENCIES: + - AFNetworking (= 2.5.1) + +SPEC REPOS: + trunk: + - AFNetworking + +SPEC CHECKSUMS: + AFNetworking: 9b1a2ed2a6a5d3c87d3d0b13d6a2f2ef1b8f47a4 + +PODFILE CHECKSUM: 0f1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c + +COCOAPODS: 1.15.2 diff --git a/fixtures/nightly/mobile/ios-cocoapods/PumpApp/PumpClient.swift b/fixtures/nightly/mobile/ios-cocoapods/PumpApp/PumpClient.swift new file mode 100644 index 0000000..3e3563e --- /dev/null +++ b/fixtures/nightly/mobile/ios-cocoapods/PumpApp/PumpClient.swift @@ -0,0 +1,12 @@ +import AFNetworking + +/// Reads the pump's status from the plant gateway. +final class PumpClient { + private let manager = AFHTTPRequestOperationManager() + + func status(gateway: String, done: @escaping (Any?) -> Void) { + manager.get("\(gateway)/api/pump/status", parameters: nil, + success: { _, body in done(body) }, + failure: { _, _ in done(nil) }) + } +} diff --git a/fixtures/nightly/mobile/ios-spm-unlocked/PumpApp.xcodeproj/project.pbxproj b/fixtures/nightly/mobile/ios-spm-unlocked/PumpApp.xcodeproj/project.pbxproj new file mode 100644 index 0000000..5974a2a --- /dev/null +++ b/fixtures/nightly/mobile/ios-spm-unlocked/PumpApp.xcodeproj/project.pbxproj @@ -0,0 +1,18 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + objectVersion = 60; + objects = { +/* Begin XCRemoteSwiftPackageReference section */ + A1B2C3D4E5F60718293A4B5C /* XCRemoteSwiftPackageReference "swift-nio-http2" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/apple/swift-nio-http2.git"; + requirement = { + kind = exactVersion; + version = 1.19.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + }; + rootObject = 0F1E2D3C4B5A69788796A5B4; +} diff --git a/fixtures/nightly/mobile/ios-spm-unlocked/PumpApp/PumpServer.swift b/fixtures/nightly/mobile/ios-spm-unlocked/PumpApp/PumpServer.swift new file mode 100644 index 0000000..523dbbc --- /dev/null +++ b/fixtures/nightly/mobile/ios-spm-unlocked/PumpApp/PumpServer.swift @@ -0,0 +1,6 @@ +import NIOHTTP2 + +/// Serves the pump's status to the operator panel over HTTP/2. +enum PumpServer { + static let port = 8443 +} diff --git a/fixtures/nightly/mobile/ios-spm-xcode/PumpApp.xcodeproj/project.pbxproj b/fixtures/nightly/mobile/ios-spm-xcode/PumpApp.xcodeproj/project.pbxproj new file mode 100644 index 0000000..5974a2a --- /dev/null +++ b/fixtures/nightly/mobile/ios-spm-xcode/PumpApp.xcodeproj/project.pbxproj @@ -0,0 +1,18 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + objectVersion = 60; + objects = { +/* Begin XCRemoteSwiftPackageReference section */ + A1B2C3D4E5F60718293A4B5C /* XCRemoteSwiftPackageReference "swift-nio-http2" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/apple/swift-nio-http2.git"; + requirement = { + kind = exactVersion; + version = 1.19.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + }; + rootObject = 0F1E2D3C4B5A69788796A5B4; +} diff --git a/fixtures/nightly/mobile/ios-spm-xcode/PumpApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/fixtures/nightly/mobile/ios-spm-xcode/PumpApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..3c05b82 --- /dev/null +++ b/fixtures/nightly/mobile/ios-spm-xcode/PumpApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "swift-nio-http2", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-http2.git", + "state" : { + "revision" : "326f7f9a8c8c8402e3691adac04911cac9f9d87a", + "version" : "1.19.0" + } + } + ], + "version" : 2 +} diff --git a/fixtures/nightly/mobile/ios-spm-xcode/PumpApp/PumpServer.swift b/fixtures/nightly/mobile/ios-spm-xcode/PumpApp/PumpServer.swift new file mode 100644 index 0000000..523dbbc --- /dev/null +++ b/fixtures/nightly/mobile/ios-spm-xcode/PumpApp/PumpServer.swift @@ -0,0 +1,6 @@ +import NIOHTTP2 + +/// Serves the pump's status to the operator panel over HTTP/2. +enum PumpServer { + static let port = 8443 +} diff --git a/fixtures/nightly/mobile/react-native/android/app/build.gradle b/fixtures/nightly/mobile/react-native/android/app/build.gradle new file mode 100644 index 0000000..32b61df --- /dev/null +++ b/fixtures/nightly/mobile/react-native/android/app/build.gradle @@ -0,0 +1,5 @@ +apply plugin: "com.android.application" +apply plugin: "com.facebook.react" +dependencies { + implementation("com.facebook.react:react-android") +} diff --git a/fixtures/nightly/mobile/react-native/ios/Podfile b/fixtures/nightly/mobile/react-native/ios/Podfile new file mode 100644 index 0000000..688fcdf --- /dev/null +++ b/fixtures/nightly/mobile/react-native/ios/Podfile @@ -0,0 +1,5 @@ +require_relative '../node_modules/react-native/scripts/react_native_pods' +platform :ios, '13.4' +target 'PumpApp' do + use_react_native! +end diff --git a/fixtures/nightly/mobile/react-native/package-lock.json b/fixtures/nightly/mobile/react-native/package-lock.json new file mode 100644 index 0000000..dfdd6ac --- /dev/null +++ b/fixtures/nightly/mobile/react-native/package-lock.json @@ -0,0 +1,32 @@ +{ + "name": "checkout-npm-lock-v3", + "version": "2.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "checkout-npm-lock-v3", + "version": "2.1.0", + "dependencies": { + "axios": "0.21.1", + "express": "4.17.1", + "lodash": "4.17.20" + } + }, + "node_modules/axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==" + }, + "node_modules/express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==" + }, + "node_modules/lodash": { + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" + } + } +} diff --git a/fixtures/nightly/mobile/react-native/package.json b/fixtures/nightly/mobile/react-native/package.json new file mode 100644 index 0000000..2bd21b8 --- /dev/null +++ b/fixtures/nightly/mobile/react-native/package.json @@ -0,0 +1,10 @@ +{ + "name": "checkout-npm-lock-v3", + "version": "2.1.0", + "private": true, + "dependencies": { + "axios": "0.21.1", + "express": "4.17.1", + "lodash": "4.17.20" + } +} diff --git a/fixtures/nightly/targets.json b/fixtures/nightly/targets.json index d785834..93e5268 100644 --- a/fixtures/nightly/targets.json +++ b/fixtures/nightly/targets.json @@ -554,6 +554,105 @@ "expect": { "min_graph_nodes": 1 } + }, + { + "key": "mobile-android-gradle-lock", + "name": "Android · Gradle with gradle.lockfile", + "target_type": "android_app", + "description": "Uploaded as a source archive. A Kotlin app whose app/gradle.lockfile pins okhttp 3.12.0 and gson 2.8.8, both with advisories: the SBOM lists the Maven packages and the CVE lookup finds them (#434).", + "artifacts": [ + { + "kind": "source_archive", + "upload": "fixtures/nightly/mobile/android-gradle-lock" + } + ], + "expect": { + "min_sbom_components": 3 + } + }, + { + "key": "mobile-android-gradle-catalog", + "name": "Android · Gradle without a lockfile", + "target_type": "android_app", + "description": "Uploaded as a source archive. Dependencies declared through gradle/libs.versions.toml and a literal coordinate, nothing locked: the run must record a skipped sbom_dependencies stage instead of an empty SBOM that reads as clean (#434).", + "artifacts": [ + { + "kind": "source_archive", + "upload": "fixtures/nightly/mobile/android-gradle-catalog" + } + ] + }, + { + "key": "mobile-ios-cocoapods", + "name": "iOS · CocoaPods", + "target_type": "ios_app", + "description": "Uploaded as a source archive. Podfile.lock pins AFNetworking 2.5.1. OSV publishes no CocoaPods advisories, so the run must record an incomplete cve_lookup rather than claim the pods have no CVEs (#434).", + "artifacts": [ + { + "kind": "source_archive", + "upload": "fixtures/nightly/mobile/ios-cocoapods" + } + ], + "expect": { + "min_sbom_components": 1 + } + }, + { + "key": "mobile-ios-spm-xcode", + "name": "iOS · Swift packages in an Xcode project", + "target_type": "ios_app", + "description": "Uploaded as a source archive. An Xcode project pinning swift-nio-http2 1.19.0 in its embedded Package.resolved. Syft's Swift purl must be rewritten to the repository form, or OSV matches none of its advisories (#434).", + "artifacts": [ + { + "kind": "source_archive", + "upload": "fixtures/nightly/mobile/ios-spm-xcode" + } + ], + "expect": { + "min_sbom_components": 1 + } + }, + { + "key": "mobile-ios-spm-unlocked", + "name": "iOS · Swift packages without Package.resolved", + "target_type": "ios_app", + "description": "Uploaded as a source archive. The Xcode project references a Swift package but no Package.resolved pins it: the run must record a skipped sbom_dependencies stage naming project.pbxproj (#434).", + "artifacts": [ + { + "kind": "source_archive", + "upload": "fixtures/nightly/mobile/ios-spm-unlocked" + } + ] + }, + { + "key": "mobile-flutter", + "name": "Flutter app", + "target_type": "android_app", + "description": "Uploaded as a source archive. pubspec.lock pins dio 3.0.10 (one advisory); the Android host app's Gradle dependencies are not locked, which the run records as a skipped sbom_dependencies stage (#434).", + "artifacts": [ + { + "kind": "source_archive", + "upload": "fixtures/nightly/mobile/flutter" + } + ], + "expect": { + "min_sbom_components": 1 + } + }, + { + "key": "mobile-react-native", + "name": "React Native app", + "target_type": "android_app", + "description": "Uploaded as a source archive. The JavaScript side is locked (package-lock.json), but neither ios/Podfile nor android/app/build.gradle is: the run lists the npm packages and records both gaps (#434).", + "artifacts": [ + { + "kind": "source_archive", + "upload": "fixtures/nightly/mobile/react-native" + } + ], + "expect": { + "min_sbom_components": 3 + } } ] }