feat(sbom): direct dependencies of Gradle builds without a lockfile #446

Merged
sharang merged 1 commits from feat/gradle-direct-deps into main 2026-10-05 13:39:03 +00:00
Owner

#434 part 2: an Android or JVM app without gradle.lockfile now gets its direct dependencies into the SBOM, and through it the CVE lookup. Before, it got none; since #440 it got at least a warning.

How (no Gradle run, no project code executed)

pipeline/sbom/gradle.rs reads what the build files declare:

  • Literal coordinates in build.gradle(.kts): implementation 'g:a:v', api("g:a:v"), map notation group:/name:/version:, and @aar.
  • Versions from variables: ext.x = '…', def/val, ext { x = '…' } and gradle.properties. References may be $x, ${x} or ${rootProject.ext.x}.
  • The version catalog (*.versions.toml, accessor taken from the file name): the libraries and bundles a build file actually uses (libs.okhttp, libs.bundles.storage), with version.ref, strictly and require.

Only shipped dependencies with an exact version count.

  • In: implementation, api, compile and runtime, including flavor and build-type prefixes (phoneImplementation, tabletImplementation).
  • Out: test, lint, kapt/ksp, annotation processors, the buildscript classpath, ranges, 1.+ and latest.*.

The entries are maven with a purl, so OSV matches them. They are added only when the tree has no Gradle lockfile; with one, Syft reads it instead.

The build still counts as unlocked, so the sbom_dependencies skip stays and the CRA SBOM requirements stay Nicht bewertet. The skip text now says only the direct dependencies are listed, not what they pull in.

Fixtures

Target SBOM now
mobile-android-legacy-groovy (new; like a typical older Java app: phone/tablet flavors, ext and gradle.properties versions, no lockfile) okhttp 3.12.0, gson 2.8.8, bcprov 1.60, appcompat-v7 28.0.0, with 8 advisories. The test, annotation-processor and 1.+ dependencies are left out.
mobile-android-gradle-catalog okhttp, gson, bcprov (was empty), with 8 advisories
mobile-flutter plus work-runtime 2.7.0 from the Android host app

Checks

  • fmt, plus clippy with the CI flags on the agent.
  • Agent lib tests: 525, including 6 new ones for the parser (legacy build, catalog with bundles and version tables, gradle.properties, locked build, build output not read, regexes compile).
  • Local nightly on the staging image with this binary, for all mobile targets plus 2 others: both bless and compare pass. Only the three baselines above changed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

#434 part 2: an Android or JVM app **without `gradle.lockfile`** now gets its **direct dependencies** into the SBOM, and through it the CVE lookup. Before, it got none; since #440 it got at least a warning. ## How (no Gradle run, no project code executed) `pipeline/sbom/gradle.rs` reads what the build files declare: - **Literal coordinates** in `build.gradle(.kts)`: `implementation 'g:a:v'`, `api("g:a:v")`, map notation `group:/name:/version:`, and `@aar`. - **Versions from variables:** `ext.x = '…'`, `def`/`val`, `ext { x = '…' }` and `gradle.properties`. References may be `$x`, `${x}` or `${rootProject.ext.x}`. - **The version catalog** (`*.versions.toml`, accessor taken from the file name): the libraries and bundles a build file actually uses (`libs.okhttp`, `libs.bundles.storage`), with `version.ref`, `strictly` and `require`. **Only shipped dependencies with an exact version count.** - In: `implementation`, `api`, `compile` and `runtime`, including flavor and build-type prefixes (`phoneImplementation`, `tabletImplementation`). - Out: test, lint, kapt/ksp, annotation processors, the buildscript `classpath`, ranges, `1.+` and `latest.*`. The entries are `maven` with a purl, so OSV matches them. They are added only when the tree has no Gradle lockfile; with one, Syft reads it instead. The build still counts as unlocked, so the `sbom_dependencies` skip stays and the CRA SBOM requirements stay *Nicht bewertet*. The skip text now says only the direct dependencies are listed, not what they pull in. ## Fixtures | Target | SBOM now | |---|---| | `mobile-android-legacy-groovy` (new; like a typical older Java app: phone/tablet flavors, ext and gradle.properties versions, no lockfile) | okhttp 3.12.0, gson 2.8.8, bcprov 1.60, appcompat-v7 28.0.0, with 8 advisories. The test, annotation-processor and `1.+` dependencies are left out. | | `mobile-android-gradle-catalog` | okhttp, gson, bcprov (was empty), with 8 advisories | | `mobile-flutter` | plus `work-runtime 2.7.0` from the Android host app | ## Checks - fmt, plus clippy with the CI flags on the agent. - Agent lib tests: 525, including 6 new ones for the parser (legacy build, catalog with bundles and version tables, gradle.properties, locked build, build output not read, regexes compile). - **Local nightly on the staging image with this binary, for all mobile targets plus 2 others:** both bless and compare pass. Only the three baselines above changed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-05 13:16:43 +00:00
feat(sbom): direct dependencies of Gradle builds without a lockfile
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 10m46s
893076eb8c
Without gradle.lockfile, Syft lists nothing for an Android or JVM app, and
resolving the build would run its scripts. sbom/gradle.rs now reads what
the build files declare, without executing anything:
- literal coordinates in build.gradle(.kts), including map notation and
  `@aar`;
- versions from `ext`/`def`/`val` variables and gradle.properties
  (`$v`, `${v}`, `${rootProject.ext.v}`);
- the version catalog (`*.versions.toml`): libraries and bundles a build
  file uses, with `version.ref`, `strictly` and `require`.

Only dependencies that ship (implementation, api, compile, runtime, any
flavor prefix) with an exact version count: test, lint, kapt/ksp and
annotation processors, buildscript classpath, ranges and `1.+` do not.
Entries are `maven` with a purl, so OSV matches them. The build is still
reported as unlocked, with a note that only direct dependencies are listed.

New nightly fixture android-legacy-groovy (phone/tablet flavors, ext and
gradle.properties versions); the catalog and Flutter baselines gain their
direct dependencies.

Refs #434.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit 04d0ad5113 into main 2026-10-05 13:39:03 +00:00
Sign in to join this conversation.