diff --git a/Cargo.lock b/Cargo.lock
index 0ee111b..58556d2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -701,6 +701,7 @@ dependencies = [
"tokio-cron-scheduler",
"tokio-stream",
"tokio-tungstenite 0.26.2",
+ "toml",
"tower",
"tower-http",
"tracing",
diff --git a/compliance-agent/Cargo.toml b/compliance-agent/Cargo.toml
index cf5edc2..bbed909 100644
--- a/compliance-agent/Cargo.toml
+++ b/compliance-agent/Cargo.toml
@@ -51,6 +51,8 @@ hmac = "0.12"
# Constant-time comparison of the GitLab webhook token.
subtle = "2.6"
walkdir = "2"
+# Gradle version catalogs (libs.versions.toml) in mobile and JVM projects.
+toml = "0.8"
# Read-only XML tree parsing for PLCopen project files (POU extraction).
roxmltree = "0.20"
base64 = "0.22"
diff --git a/compliance-agent/src/pipeline/sbom/gradle.rs b/compliance-agent/src/pipeline/sbom/gradle.rs
new file mode 100644
index 0000000..65497a2
--- /dev/null
+++ b/compliance-agent/src/pipeline/sbom/gradle.rs
@@ -0,0 +1,487 @@
+//! Direct dependencies of a Gradle build that has no lockfile.
+//!
+//! Without `gradle.lockfile` the SBOM tooling lists nothing for an Android or
+//! JVM app, and resolving the build would run its build scripts, which a scan
+//! must not do. What the build files *declare* can still be read: the
+//! coordinates written into `build.gradle(.kts)`, versions kept in `ext`
+//! variables or `gradle.properties`, and the version catalog
+//! (`gradle/libs.versions.toml`). Only dependencies that ship with the app
+//! count (implementation, api, runtime; not test, lint or annotation
+//! processors), and only exact versions: a range or a version Gradle resolves
+//! itself (`+`, `latest.release`) says nothing about what is in the app.
+//!
+//! These are the direct dependencies only. What they pull in stays unknown, so
+//! the scan still reports the build as unlocked (see [`super::mobile`]).
+
+use std::collections::{BTreeSet, HashMap};
+use std::path::Path;
+use std::sync::LazyLock;
+
+use compliance_core::models::SbomEntry;
+use regex::Regex;
+
+use super::mobile::{MAX_DEPTH, SKIPPED_DIRS};
+
+/// A literal coordinate after a configuration name:
+/// `implementation 'g:a:v'`, `api("g:a:$v")`, `compile "g:a:${v}@aar"`.
+static COORDINATE: LazyLock> = LazyLock::new(|| {
+ Regex::new(r#"\b(\w+)\s*\(?\s*["']([\w.\-]+):([\w.\-]+):([^"'@\s:]+)(?:@\w+)?["']"#).ok()
+});
+
+/// Groovy's map notation: `implementation group: 'g', name: 'a', version: 'v'`.
+static MAP_COORDINATE: LazyLock > = LazyLock::new(|| {
+ Regex::new(
+ r#"\b(\w+)\s*\(?\s*group\s*:\s*["']([^"']+)["']\s*,\s*name\s*:\s*["']([^"']+)["']\s*,\s*version\s*:\s*["']([^"']+)["']"#,
+ )
+ .ok()
+});
+
+/// A catalog accessor after a configuration name: `implementation(libs.okhttp)`,
+/// `api libs.bundles.network`.
+static CATALOG_USE: LazyLock > =
+ LazyLock::new(|| Regex::new(r"\b(\w+)\s*\(?\s*(\w+)\.([\w.]+)").ok());
+
+/// A version kept in a variable: `ext.okhttp_version = '3.12.0'`,
+/// `def okhttp = "3.12.0"`, `val okhttp = "3.12.0"`, or a line of an
+/// `ext { okhttp = '3.12.0' }` block.
+static VARIABLE: LazyLock > = LazyLock::new(|| {
+ Regex::new(r#"(?m)^\s*(?:ext\.|def\s+|val\s+)?([A-Za-z_]\w*)\s*=\s*["']([^"'$]+)["']"#).ok()
+});
+
+/// A variable reference inside a version: `$okhttp`, `${versions.okhttp}`,
+/// `${rootProject.ext.okhttp}`. The last segment names the variable.
+static REFERENCE: LazyLock > = LazyLock::new(|| Regex::new(r"\$\{?([\w.]+)\}?").ok());
+
+/// Lockfiles that make the parse unnecessary: Syft reads them, and they also
+/// pin what the direct dependencies pull in.
+const LOCKFILES: [&str; 2] = ["gradle.lockfile", "settings-gradle.lockfile"];
+
+/// The build files, catalogs and properties of one tree.
+#[derive(Default)]
+struct GradleFiles {
+ builds: Vec,
+ /// Catalog accessor name (`libs` for `libs.versions.toml`) and its text.
+ catalogs: Vec<(String, String)>,
+ properties: Vec,
+ locked: bool,
+}
+
+/// The dependencies the Gradle builds under `root` declare with an exact
+/// version, as SBOM entries; empty when a Gradle lockfile pins them (Syft
+/// reads that instead) or the tree has no Gradle build.
+///
+/// # Arguments
+///
+/// * `root` - the checked-out or unpacked source tree
+/// * `repo_id` - the target the entries belong to
+///
+/// # Returns
+///
+/// One `maven` entry with a purl per distinct coordinate, so the CVE lookup
+/// matches it.
+pub(crate) fn declared_dependencies(root: &Path, repo_id: &str) -> Vec {
+ let files = read_files(root);
+ if files.locked || files.builds.is_empty() {
+ return Vec::new();
+ }
+ let variables = variables(&files);
+ let mut coordinates: BTreeSet<(String, String, String)> = BTreeSet::new();
+ for build in &files.builds {
+ coordinates.extend(literal_coordinates(build, &variables));
+ }
+ for (accessor, catalog) in &files.catalogs {
+ coordinates.extend(catalog_coordinates(accessor, catalog, &files.builds));
+ }
+ coordinates
+ .into_iter()
+ .map(|(group, artifact, version)| {
+ let mut entry = SbomEntry::new(
+ repo_id.to_string(),
+ artifact.clone(),
+ version.clone(),
+ "maven".to_string(),
+ );
+ entry.purl = Some(format!("pkg:maven/{group}/{artifact}@{version}"));
+ entry
+ })
+ .collect()
+}
+
+/// Walk `root` once for build files, catalogs, properties and lockfiles.
+fn read_files(root: &Path) -> GradleFiles {
+ let mut files = GradleFiles::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();
+ if LOCKFILES.contains(&name.as_ref()) {
+ files.locked = true;
+ continue;
+ }
+ let read = || std::fs::read_to_string(entry.path()).ok();
+ match name.as_ref() {
+ "build.gradle" | "build.gradle.kts" => files.builds.extend(read()),
+ "gradle.properties" => files.properties.extend(read()),
+ _ => {
+ if let Some(accessor) = name.strip_suffix(".versions.toml") {
+ if let Some(text) = read() {
+ files.catalogs.push((accessor.to_string(), text));
+ }
+ }
+ }
+ }
+ }
+ files
+}
+
+/// Every variable a build file or `gradle.properties` sets to a plain
+/// string, by name. A name set twice keeps its first value.
+fn variables(files: &GradleFiles) -> HashMap {
+ let mut out = HashMap::new();
+ for text in &files.properties {
+ for line in text.lines() {
+ if let Some((key, value)) = line.split_once('=') {
+ let key = key.trim();
+ if !key.starts_with('#') && !key.is_empty() {
+ out.entry(key.to_string())
+ .or_insert_with(|| value.trim().to_string());
+ }
+ }
+ }
+ }
+ if let Some(re) = VARIABLE.as_ref() {
+ for build in &files.builds {
+ for caps in re.captures_iter(build) {
+ out.entry(caps[1].to_string())
+ .or_insert_with(|| caps[2].to_string());
+ }
+ }
+ }
+ out
+}
+
+/// Whether a dependency in configuration `config` ships with the app.
+fn ships(config: &str) -> bool {
+ let config = config.to_ascii_lowercase();
+ let build_only = [
+ "test",
+ "androidtest",
+ "kapt",
+ "ksp",
+ "annotationprocessor",
+ "lint",
+ "classpath",
+ "detekt",
+ ];
+ if build_only.iter().any(|p| config.starts_with(p)) {
+ return false;
+ }
+ ["implementation", "api", "compile", "runtimeonly", "runtime"]
+ .iter()
+ .any(|s| config.ends_with(s))
+}
+
+/// `version` with its variable references filled in from `variables`, if it
+/// is then an exact version.
+fn exact_version(version: &str, variables: &HashMap) -> Option {
+ let resolved = match REFERENCE.as_ref() {
+ Some(re) if version.contains('$') => {
+ let mut unresolved = false;
+ let text = re.replace_all(version, |caps: ®ex::Captures<'_>| {
+ let name = caps[1].rsplit('.').next().unwrap_or_default();
+ variables.get(name).cloned().unwrap_or_else(|| {
+ unresolved = true;
+ String::new()
+ })
+ });
+ if unresolved {
+ return None;
+ }
+ text.into_owned()
+ }
+ _ => version.to_string(),
+ };
+ let exact = resolved.chars().next().is_some_and(|c| c.is_ascii_digit())
+ && !resolved.contains(['+', '[', ']', '(', ')', ',', '*', '$'])
+ && !resolved.contains("latest");
+ exact.then_some(resolved)
+}
+
+/// The shipped coordinates written into one build file.
+fn literal_coordinates(
+ build: &str,
+ variables: &HashMap,
+) -> Vec<(String, String, String)> {
+ [COORDINATE.as_ref(), MAP_COORDINATE.as_ref()]
+ .into_iter()
+ .flatten()
+ .flat_map(|re| re.captures_iter(build))
+ .filter(|caps| ships(&caps[1]))
+ .filter_map(|caps| {
+ let version = exact_version(&caps[4], variables)?;
+ Some((caps[2].to_string(), caps[3].to_string(), version))
+ })
+ .collect()
+}
+
+/// A catalog alias as Gradle's accessor spells it: `androidx-core_ktx`
+/// becomes `androidx.core.ktx`.
+fn accessor_path(alias: &str) -> String {
+ alias.replace(['-', '_'], ".").to_ascii_lowercase()
+}
+
+/// The shipped coordinates a version catalog contributes: its libraries and
+/// bundles that a build file uses in a shipped configuration.
+fn catalog_coordinates(
+ accessor: &str,
+ catalog: &str,
+ builds: &[String],
+) -> Vec<(String, String, String)> {
+ let Ok(table) = catalog.parse::() else {
+ tracing::warn!(accessor, "unreadable Gradle version catalog");
+ return Vec::new();
+ };
+ let versions = table.get("versions").and_then(toml::Value::as_table);
+ let libraries: HashMap = table
+ .get("libraries")
+ .and_then(toml::Value::as_table)
+ .into_iter()
+ .flatten()
+ .filter_map(|(alias, spec)| Some((accessor_path(alias), library(spec, versions)?)))
+ .collect();
+ let bundles: HashMap> = table
+ .get("bundles")
+ .and_then(toml::Value::as_table)
+ .into_iter()
+ .flatten()
+ .map(|(alias, members)| {
+ let members = members
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(toml::Value::as_str)
+ .map(accessor_path)
+ .collect();
+ (accessor_path(alias), members)
+ })
+ .collect();
+
+ let Some(re) = CATALOG_USE.as_ref() else {
+ return Vec::new();
+ };
+ let mut out = Vec::new();
+ for build in builds {
+ for caps in re.captures_iter(build) {
+ if &caps[2] != accessor || !ships(&caps[1]) {
+ continue;
+ }
+ let path = caps[3].to_ascii_lowercase();
+ let used: Vec<&String> = match path.strip_prefix("bundles.") {
+ Some(bundle) => bundles.get(bundle).into_iter().flatten().collect(),
+ None => vec![&path],
+ };
+ out.extend(used.into_iter().filter_map(|p| libraries.get(p).cloned()));
+ }
+ }
+ out
+}
+
+/// A catalog library's coordinate with an exact version: `"g:a:v"`,
+/// `{ module = "g:a", version = "v" }`, `{ group, name, version.ref }` or a
+/// version table (`strictly`, `require`).
+fn library(spec: &toml::Value, versions: Option<&toml::Table>) -> Option<(String, String, String)> {
+ if let Some(text) = spec.as_str() {
+ let mut parts = text.split(':');
+ let (group, artifact, version) = (parts.next()?, parts.next()?, parts.next()?);
+ let version = exact_version(version, &HashMap::new())?;
+ return Some((group.to_string(), artifact.to_string(), version));
+ }
+ let spec = spec.as_table()?;
+ let (group, artifact) = match spec.get("module").and_then(toml::Value::as_str) {
+ Some(module) => module.split_once(':')?,
+ None => (spec.get("group")?.as_str()?, spec.get("name")?.as_str()?),
+ };
+ let version = match spec.get("version")? {
+ toml::Value::String(v) => v.clone(),
+ toml::Value::Table(t) => match t.get("ref").and_then(toml::Value::as_str) {
+ Some(name) => version_of(versions?.get(name)?)?,
+ None => version_of(&toml::Value::Table(t.clone()))?,
+ },
+ _ => return None,
+ };
+ let version = exact_version(&version, &HashMap::new())?;
+ Some((group.to_string(), artifact.to_string(), version))
+}
+
+/// The version a `[versions]` entry pins: the string, or its `strictly` or
+/// `require` part.
+fn version_of(value: &toml::Value) -> Option {
+ match value {
+ toml::Value::String(v) => Some(v.clone()),
+ toml::Value::Table(t) => ["strictly", "require"]
+ .iter()
+ .find_map(|k| t.get(*k).and_then(toml::Value::as_str))
+ .map(str::to_string),
+ _ => None,
+ }
+}
+
+#[cfg(test)]
+#[allow(clippy::expect_used, clippy::unwrap_used)]
+mod tests {
+ use super::*;
+
+ /// A scratch tree holding `files` (relative path, content), removed on
+ /// drop.
+ struct Tree(std::path::PathBuf);
+ 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-gradle-{}", uuid::Uuid::new_v4()));
+ for (path, content) in files {
+ let full = dir.join(path);
+ std::fs::create_dir_all(full.parent().expect("parent")).expect("mkdir");
+ std::fs::write(full, content).expect("write");
+ }
+ Tree(dir)
+ }
+
+ fn purls(files: &[(&str, &str)]) -> Vec {
+ let dir = tree(files);
+ declared_dependencies(&dir.0, "t")
+ .into_iter()
+ .filter_map(|e| e.purl)
+ .collect()
+ }
+
+ #[test]
+ fn every_pattern_compiles() {
+ for re in [
+ &COORDINATE,
+ &MAP_COORDINATE,
+ &CATALOG_USE,
+ &VARIABLE,
+ &REFERENCE,
+ ] {
+ assert!(re.is_some());
+ }
+ }
+
+ #[test]
+ fn a_legacy_android_build_lists_its_shipped_dependencies() {
+ let root = r#"
+buildscript {
+ ext.okhttp_version = '3.12.0'
+ dependencies { classpath 'com.android.tools.build:gradle:3.5.0' }
+}
+"#;
+ let app = r#"
+dependencies {
+ implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
+ implementation 'com.google.code.gson:gson:2.8.8'
+ phoneImplementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.60'
+ compile 'com.android.support:appcompat-v7:28.0.0@aar'
+ testImplementation 'junit:junit:4.12'
+ annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
+ implementation 'com.example:dynamic:1.+'
+ implementation "com.example:unknown:$notDefined"
+}
+"#;
+ assert_eq!(
+ purls(&[("build.gradle", root), ("app/build.gradle", app)]),
+ vec![
+ "pkg:maven/com.android.support/appcompat-v7@28.0.0",
+ "pkg:maven/com.google.code.gson/gson@2.8.8",
+ "pkg:maven/com.squareup.okhttp3/okhttp@3.12.0",
+ "pkg:maven/org.bouncycastle/bcprov-jdk15on@1.60",
+ ]
+ );
+ }
+
+ #[test]
+ fn a_version_catalog_counts_only_what_a_build_ships() {
+ let catalog = r#"
+[versions]
+okhttp = "3.12.0"
+room = { strictly = "2.6.1" }
+junit = "4.13.2"
+
+[libraries]
+okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
+room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
+gson = "com.google.code.gson:gson:2.8.8"
+junit = { module = "junit:junit", version.ref = "junit" }
+core-ktx = { module = "androidx.core:core-ktx" }
+
+[bundles]
+storage = ["room-runtime", "gson"]
+"#;
+ let app = r#"
+dependencies {
+ implementation(libs.okhttp)
+ implementation(libs.bundles.storage)
+ implementation(libs.core.ktx)
+ testImplementation(libs.junit)
+}
+"#;
+ assert_eq!(
+ purls(&[
+ ("gradle/libs.versions.toml", catalog),
+ ("app/build.gradle.kts", app),
+ ]),
+ vec![
+ "pkg:maven/androidx.room/room-runtime@2.6.1",
+ "pkg:maven/com.google.code.gson/gson@2.8.8",
+ "pkg:maven/com.squareup.okhttp3/okhttp@3.12.0",
+ ]
+ );
+ }
+
+ #[test]
+ fn versions_from_gradle_properties_are_resolved() {
+ assert_eq!(
+ purls(&[
+ ("gradle.properties", "# versions\nokhttpVersion=3.12.0\n"),
+ (
+ "app/build.gradle.kts",
+ "dependencies { implementation(\"com.squareup.okhttp3:okhttp:${okhttpVersion}\") }",
+ ),
+ ]),
+ vec!["pkg:maven/com.squareup.okhttp3/okhttp@3.12.0"]
+ );
+ }
+
+ #[test]
+ fn a_locked_build_is_left_to_the_lockfile() {
+ assert!(purls(&[
+ (
+ "app/build.gradle",
+ "dependencies { implementation 'a.b:c:1.0' }"
+ ),
+ ("app/gradle.lockfile", "a.b:c:1.0=releaseRuntimeClasspath"),
+ ])
+ .is_empty());
+ }
+
+ #[test]
+ fn build_output_is_not_read() {
+ assert!(purls(&[(
+ "app/build/intermediates/build.gradle",
+ "dependencies { implementation 'a.b:c:1.0' }"
+ )])
+ .is_empty());
+ }
+}
diff --git a/compliance-agent/src/pipeline/sbom/mobile.rs b/compliance-agent/src/pipeline/sbom/mobile.rs
index 16754be..17fdd60 100644
--- a/compliance-agent/src/pipeline/sbom/mobile.rs
+++ b/compliance-agent/src/pipeline/sbom/mobile.rs
@@ -20,11 +20,11 @@ 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;
+pub(super) 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] = &[
+pub(super) const SKIPPED_DIRS: &[&str] = &[
".git",
".gradle",
".dart_tool",
@@ -58,7 +58,8 @@ const GRADLE: Ecosystem = Ecosystem {
"settings.gradle.kts",
],
lockfiles: &["gradle.lockfile", "settings-gradle.lockfile"],
- problem: "declares Gradle dependencies but no gradle.lockfile pins them",
+ problem: "declares Gradle dependencies but no gradle.lockfile pins them; only the direct \
+ dependencies with an exact version are listed, not what they pull in",
remedy: "enable Gradle dependency locking (`dependencyLocking { lockAllConfigurations() }`) \
and commit the gradle.lockfile files (`./gradlew dependencies --write-locks`)",
};
diff --git a/compliance-agent/src/pipeline/sbom/mod.rs b/compliance-agent/src/pipeline/sbom/mod.rs
index 7c65a09..467f1a2 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 gradle;
mod mobile;
mod syft;
@@ -42,6 +43,20 @@ impl Scanner for SbomScanner {
Err(e) => tracing::warn!("syft failed: {e}"),
}
+ // A Gradle build without a lockfile gives Syft nothing; its build files
+ // still name the direct dependencies.
+ let tree = repo_path.to_path_buf();
+ let target = repo_id.to_string();
+ let declared =
+ tokio::task::spawn_blocking(move || gradle::declared_dependencies(&tree, &target))
+ .await
+ .unwrap_or_default();
+ for entry in declared {
+ if !entries.iter().any(|e| e.purl == entry.purl) {
+ entries.push(entry);
+ }
+ }
+
// Enrich Cargo entries with license info from cargo metadata
enrich_cargo_licenses(repo_path, &mut entries, self.exec).await;
diff --git a/docs/guide/sbom.md b/docs/guide/sbom.md
index 49afb9d..0ed8f70 100644
--- a/docs/guide/sbom.md
+++ b/docs/guide/sbom.md
@@ -22,7 +22,11 @@ Prüfwerk builds the SBOM during each scan:
`*.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
+ `./gradlew dependencies --write-locks`). Without it, Prüfwerk reads the
+ direct dependencies from the build files (`build.gradle(.kts)`, versions in
+ `ext` variables, `gradle.properties` and `gradle/libs.versions.toml`), but
+ only those that ship with the app and have an exact version; what they pull
+ in stays unknown. In that case, 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
diff --git a/fixtures/nightly/baselines/mobile-android-gradle-catalog.json b/fixtures/nightly/baselines/mobile-android-gradle-catalog.json
index c18f738..288466d 100644
--- a/fixtures/nightly/baselines/mobile-android-gradle-catalog.json
+++ b/fixtures/nightly/baselines/mobile-android-gradle-catalog.json
@@ -3,7 +3,20 @@
"skipped_stages": [
"sbom_dependencies"
],
- "sbom": [],
+ "sbom": [
+ "maven:bcprov-jdk15on@1.60",
+ "maven:gson@2.8.8",
+ "maven:okhttp@3.12.0"
+ ],
"findings": [],
- "cves": []
+ "cves": [
+ "GHSA-3cqm-mf7h-prrj",
+ "GHSA-4jrv-ppp4-jm57",
+ "GHSA-6xx3-rg99-gc3p",
+ "GHSA-72m5-fvvv-55m6",
+ "GHSA-8xfc-gm6g-vgpv",
+ "GHSA-hr8g-6v94-x4m9",
+ "GHSA-v435-xc8x-wvr9",
+ "GHSA-wjxj-5m7g-mg7q"
+ ]
}
diff --git a/fixtures/nightly/baselines/mobile-android-legacy-groovy.json b/fixtures/nightly/baselines/mobile-android-legacy-groovy.json
new file mode 100644
index 0000000..2f64920
--- /dev/null
+++ b/fixtures/nightly/baselines/mobile-android-legacy-groovy.json
@@ -0,0 +1,23 @@
+{
+ "scan_status": "completed",
+ "skipped_stages": [
+ "sbom_dependencies"
+ ],
+ "sbom": [
+ "maven:appcompat-v7@28.0.0",
+ "maven:bcprov-jdk15on@1.60",
+ "maven:gson@2.8.8",
+ "maven:okhttp@3.12.0"
+ ],
+ "findings": [],
+ "cves": [
+ "GHSA-3cqm-mf7h-prrj",
+ "GHSA-4jrv-ppp4-jm57",
+ "GHSA-6xx3-rg99-gc3p",
+ "GHSA-72m5-fvvv-55m6",
+ "GHSA-8xfc-gm6g-vgpv",
+ "GHSA-hr8g-6v94-x4m9",
+ "GHSA-v435-xc8x-wvr9",
+ "GHSA-wjxj-5m7g-mg7q"
+ ]
+}
diff --git a/fixtures/nightly/baselines/mobile-flutter.json b/fixtures/nightly/baselines/mobile-flutter.json
index a4eff81..d7d0237 100644
--- a/fixtures/nightly/baselines/mobile-flutter.json
+++ b/fixtures/nightly/baselines/mobile-flutter.json
@@ -4,6 +4,7 @@
"sbom_dependencies"
],
"sbom": [
+ "maven:work-runtime@2.7.0",
"pub:dio@3.0.10",
"pub:pump_app@UNKNOWN"
],
diff --git a/fixtures/nightly/mobile/README.md b/fixtures/nightly/mobile/README.md
index 01dd0b0..15597d2 100644
--- a/fixtures/nightly/mobile/README.md
+++ b/fixtures/nightly/mobile/README.md
@@ -7,11 +7,12 @@ as a source archive. They prove that no mobile app ends with "0 packages,
| 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 |
+| `android-gradle-catalog` | nothing: `libs.versions.toml` plus a literal coordinate | the 3 direct dependencies read from the catalog and the build file, with their advisories; a recorded `sbom_dependencies` skip (what they pull in is unknown) |
+| `android-legacy-groovy` | nothing: `ext` and `gradle.properties` versions, phone/tablet flavors, map notation, one `1.+` | the 4 shipped direct dependencies with exact versions (no test, annotation processor or dynamic one); 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 |
+| `flutter` | `pubspec.lock` (dio 3.0.10); the Android host app is unlocked | the Dart packages and the host app's direct Gradle dependency; 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 |
| `android-insecure` | nothing (no Gradle lock) | mobsfscan: manifest (debuggable, backups, cleartext, minSdk), Kotlin (JavaScript bridge, MD5), Java under `inspection/` (world-readable, `Random`) |
diff --git a/fixtures/nightly/mobile/android-legacy-groovy/app/build.gradle b/fixtures/nightly/mobile/android-legacy-groovy/app/build.gradle
new file mode 100644
index 0000000..9231411
--- /dev/null
+++ b/fixtures/nightly/mobile/android-legacy-groovy/app/build.gradle
@@ -0,0 +1,20 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+ flavorDimensions "device"
+ productFlavors {
+ phone { dimension "device" }
+ tablet { dimension "device" }
+ }
+}
+
+dependencies {
+ implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
+ implementation "com.google.code.gson:gson:${gsonVersion}"
+ tabletImplementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.60'
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'com.example:nightly-snapshot:1.+'
+ testImplementation 'junit:junit:4.12'
+ annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
+}
diff --git a/fixtures/nightly/mobile/android-legacy-groovy/app/src/main/java/com/example/pump/PumpClient.java b/fixtures/nightly/mobile/android-legacy-groovy/app/src/main/java/com/example/pump/PumpClient.java
new file mode 100644
index 0000000..bd393fa
--- /dev/null
+++ b/fixtures/nightly/mobile/android-legacy-groovy/app/src/main/java/com/example/pump/PumpClient.java
@@ -0,0 +1,17 @@
+package com.example.pump;
+
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+
+/** Reads the pump's status from the plant gateway. */
+public class PumpClient {
+ private final OkHttpClient http = new OkHttpClient();
+
+ public String status(String gateway) throws java.io.IOException {
+ Request request = new Request.Builder().url(gateway + "/api/pump/status").build();
+ try (Response response = http.newCall(request).execute()) {
+ return response.body().string();
+ }
+ }
+}
diff --git a/fixtures/nightly/mobile/android-legacy-groovy/build.gradle b/fixtures/nightly/mobile/android-legacy-groovy/build.gradle
new file mode 100644
index 0000000..01621a3
--- /dev/null
+++ b/fixtures/nightly/mobile/android-legacy-groovy/build.gradle
@@ -0,0 +1,11 @@
+buildscript {
+ ext.okhttp_version = '3.12.0'
+ repositories { google(); jcenter() }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.5.0'
+ }
+}
+
+allprojects {
+ repositories { google(); jcenter() }
+}
diff --git a/fixtures/nightly/mobile/android-legacy-groovy/gradle.properties b/fixtures/nightly/mobile/android-legacy-groovy/gradle.properties
new file mode 100644
index 0000000..0c7131b
--- /dev/null
+++ b/fixtures/nightly/mobile/android-legacy-groovy/gradle.properties
@@ -0,0 +1,3 @@
+# Versions shared by the modules.
+gsonVersion=2.8.8
+android.useAndroidX=true
diff --git a/fixtures/nightly/mobile/android-legacy-groovy/settings.gradle b/fixtures/nightly/mobile/android-legacy-groovy/settings.gradle
new file mode 100644
index 0000000..e7b4def
--- /dev/null
+++ b/fixtures/nightly/mobile/android-legacy-groovy/settings.gradle
@@ -0,0 +1 @@
+include ':app'
diff --git a/fixtures/nightly/targets.json b/fixtures/nightly/targets.json
index 0e8de72..41f4456 100644
--- a/fixtures/nightly/targets.json
+++ b/fixtures/nightly/targets.json
@@ -709,6 +709,21 @@
"CWE-327"
]
}
+ },
+ {
+ "key": "mobile-android-legacy-groovy",
+ "name": "Android · Groovy build without a lockfile",
+ "target_type": "android_app",
+ "description": "Uploaded as a source archive. An older Java app with phone and tablet flavors and no gradle.lockfile: versions live in ext variables and gradle.properties, one dependency in map notation, one dynamic (1.+). The SBOM must list the shipped direct dependencies with exact versions (not test, annotation processor or the dynamic one), match their CVEs, and still record the build as unlocked (#434).",
+ "artifacts": [
+ {
+ "kind": "source_archive",
+ "upload": "fixtures/nightly/mobile/android-legacy-groovy"
+ }
+ ],
+ "expect": {
+ "min_sbom_components": 4
+ }
}
]
}