fix(sbom): no clean-looking result for mobile apps without readable lockfiles #440

Merged
sharang merged 1 commits from feat/mobile-sbom into main 2026-10-01 18:45:27 +00:00
Owner

Part 1 of #434: a mobile app whose dependencies cannot be listed no longer reads as "0 packages, 0 CVEs". Part 2 (an SBOM for Gradle apps without a lockfile, from the version catalog) follows separately.

What was wrong (measured on fixtures, syft 1.52, OSV)

  • unlocked_ecosystems only looked at the repository root and only at npm, Python and Cargo. An Android, iOS or Flutter app without a lockfile gave an empty SBOM with no warning.
  • SwiftPM never matched an advisory: Syft writes pkg:swift/github.com/apple/swift-nio-http2.git/swift-nio-http2@1.19.0. OSV returns nothing for that; for pkg:swift/github.com/apple/swift-nio-http2@1.19.0 it returns 7 advisories.
  • CocoaPods has no ecosystem in OSV, so pods silently showed 0 CVEs.
  • Misaligned OSV answers: query_osv_batch dropped entries without a purl, but mapped the answers back by index. Every component after such an entry got its neighbour's advisories. Syft emits components without a purl, for example in Swift projects.
  • A batch OSV refused was turned into empty answers, again silently.

Change

  • pipeline/sbom/mobile.rs (new):
    • Walks the tree to depth 8, skipping Pods/, build/, .gradle/, node_modules/, DerivedData/, Carthage/, .dart_tool/ and .symlinks/.
    • Gradle, CocoaPods, SwiftPM and Pub count as locked when any of their lockfiles is anywhere in the tree. A module or Dart library without its own lockfile is normal.
    • An Xcode project that references Swift packages (XCRemoteSwiftPackageReference) counts as a SwiftPM manifest. Its Package.resolved is found inside the .xcodeproj.
    • Carthage is always reported, since no tool reads Cartfile.resolved.
    • Each gap becomes a skipped sbom_dependencies stage naming the shallowest manifest.
    • npm, Python and Cargo stay root-only, so the existing baselines are unchanged.
  • sbom/syft.rs: canonical_purl rewrites Swift purls to the repository form. It is idempotent, and other purls are untouched.
  • pipeline/cve.rs:
    • scan_dependencies returns CveLookup.
    • Answers are mapped by entry index.
    • CocoaPods entries are not queried.
    • Pods and the entries of a refused batch are listed in unchecked, which the orchestrator records as CVE-Abgleich unvollständig (at most 10 named, the rest counted). The hourly CVE monitor uses only the alerts.
  • CRA view (evidence/compliance.rs):
    • has_components: bool becomes SbomCoverage { Complete, Empty, Unresolved(manifests) }.
    • Requirements checked only on components (cra-ai-22/23/33) are Nicht bewertet with the new reason dependencies_unresolved while a manifest is unresolved. Dashboard text is in DE and EN.
    • This applies to the npm, Python and Cargo gaps too: their SBOM is just as incomplete.
  • Docs: docs/guide/sbom.md covers the mobile lockfiles, Gradle dependency locking, Carthage and CocoaPods.

Fixtures (fixtures/nightly/mobile/, 7 targets, baselines blessed)

Target SBOM CVEs Skipped
android-gradle-lock 3 Maven 3 none
android-gradle-catalog none none sbom_dependencies
ios-cocoapods 2 pods none cve_lookup
ios-spm-xcode swift-nio-http2 7 none
ios-spm-unlocked none none sbom_dependencies
flutter dio 1 sbom_dependencies (Android host app)
react-native 4 npm 31 sbom_dependencies (Podfile, Gradle)

Checks

  • fmt, plus clippy with the CI flags on the agent and on both dashboard feature sets.
  • Agent lib tests: 492. Dashboard i18n tests: 14.
  • Local nightly on the staging image with this binary: the 7 mobile targets plus js-no-lockfile, js-pnpm, py-poetry, fw-embedded-libs and archive-order-intake. Both the bless run and the compare run on a fresh database pass. No existing baseline changed: py-poetry gained one new OSV advisory that has nothing to do with this PR, and I left it out.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Part 1 of #434: a mobile app whose dependencies cannot be listed no longer reads as "0 packages, 0 CVEs". Part 2 (an SBOM for Gradle apps without a lockfile, from the version catalog) follows separately. ## What was wrong (measured on fixtures, syft 1.52, OSV) - `unlocked_ecosystems` only looked at the repository root and only at npm, Python and Cargo. An Android, iOS or Flutter app without a lockfile gave an empty SBOM with no warning. - **SwiftPM never matched an advisory:** Syft writes `pkg:swift/github.com/apple/swift-nio-http2.git/swift-nio-http2@1.19.0`. OSV returns nothing for that; for `pkg:swift/github.com/apple/swift-nio-http2@1.19.0` it returns 7 advisories. - **CocoaPods** has no ecosystem in OSV, so pods silently showed 0 CVEs. - **Misaligned OSV answers:** `query_osv_batch` dropped entries without a purl, but mapped the answers back by index. Every component after such an entry got its neighbour's advisories. Syft emits components without a purl, for example in Swift projects. - A batch OSV refused was turned into empty answers, again silently. ## Change - **`pipeline/sbom/mobile.rs` (new):** - Walks the tree to depth 8, skipping `Pods/`, `build/`, `.gradle/`, `node_modules/`, `DerivedData/`, `Carthage/`, `.dart_tool/` and `.symlinks/`. - Gradle, CocoaPods, SwiftPM and Pub count as locked when any of their lockfiles is anywhere in the tree. A module or Dart library without its own lockfile is normal. - An Xcode project that references Swift packages (`XCRemoteSwiftPackageReference`) counts as a SwiftPM manifest. Its `Package.resolved` is found inside the `.xcodeproj`. - Carthage is always reported, since no tool reads `Cartfile.resolved`. - Each gap becomes a skipped `sbom_dependencies` stage naming the shallowest manifest. - npm, Python and Cargo stay root-only, so the existing baselines are unchanged. - **`sbom/syft.rs`:** `canonical_purl` rewrites Swift purls to the repository form. It is idempotent, and other purls are untouched. - **`pipeline/cve.rs`:** - `scan_dependencies` returns `CveLookup`. - Answers are mapped by entry index. - CocoaPods entries are not queried. - Pods and the entries of a refused batch are listed in `unchecked`, which the orchestrator records as `CVE-Abgleich unvollständig` (at most 10 named, the rest counted). The hourly CVE monitor uses only the alerts. - **CRA view (`evidence/compliance.rs`):** - `has_components: bool` becomes `SbomCoverage { Complete, Empty, Unresolved(manifests) }`. - Requirements checked only on components (cra-ai-22/23/33) are *Nicht bewertet* with the new reason `dependencies_unresolved` while a manifest is unresolved. Dashboard text is in DE and EN. - This applies to the npm, Python and Cargo gaps too: their SBOM is just as incomplete. - **Docs:** `docs/guide/sbom.md` covers the mobile lockfiles, Gradle dependency locking, Carthage and CocoaPods. ## Fixtures (`fixtures/nightly/mobile/`, 7 targets, baselines blessed) | Target | SBOM | CVEs | Skipped | |---|---|---|---| | android-gradle-lock | 3 Maven | 3 | none | | android-gradle-catalog | none | none | sbom_dependencies | | ios-cocoapods | 2 pods | none | cve_lookup | | ios-spm-xcode | swift-nio-http2 | 7 | none | | ios-spm-unlocked | none | none | sbom_dependencies | | flutter | dio | 1 | sbom_dependencies (Android host app) | | react-native | 4 npm | 31 | sbom_dependencies (Podfile, Gradle) | ## Checks - fmt, plus clippy with the CI flags on the agent and on both dashboard feature sets. - Agent lib tests: 492. Dashboard i18n tests: 14. - **Local nightly on the staging image with this binary:** the 7 mobile targets plus js-no-lockfile, js-pnpm, py-poetry, fw-embedded-libs and archive-order-intake. Both the bless run and the compare run on a fresh database pass. No existing baseline changed: py-poetry gained one new OSV advisory that has nothing to do with this PR, and I left it out. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-01 15:43:07 +00:00
fix(sbom): no clean-looking result for mobile apps without readable lockfiles
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 7m8s
0b6c7a46d3
A Gradle, CocoaPods, SwiftPM or Flutter app without a lockfile got an SBOM
with no packages and no CVEs and no word about it. Now:

- sbom/mobile.rs walks the tree (android/, ios/, Xcode projects) and
  records a skipped sbom_dependencies stage for each mobile ecosystem whose
  manifest has no lockfile anywhere (Gradle, CocoaPods, SwiftPM incl.
  Xcode package references, Pub), and for Carthage, which no tool reads.
- The CRA view rates the SBOM requirements Nicht bewertet with the new
  reason dependencies_unresolved when a manifest was not resolved.
- Swift purls are rewritten to the repository form OSV keys advisories
  by; in Syft's form no Swift package ever matched an advisory.
- CocoaPods components are not sent to OSV (it has no such ecosystem) and
  are listed as unchecked, as are components of a batch OSV refused.
- OSV answers are mapped back by entry index: an entry without a purl
  shifted every later answer onto the wrong component.
- Seven nightly fixtures (Android with and without lockfile, CocoaPods,
  SwiftPM in Xcode with and without Package.resolved, Flutter, React
  Native) with blessed baselines; docs/guide/sbom.md covers mobile.

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 9b85d5148e into main 2026-10-01 18:45:27 +00:00
Sign in to join this conversation.