Generating a Software Bill of Materials (SBOM) for a Flutter app helps identify and track components, libraries, and dependencies used in your application, which is crucial for security and compliance.
As of now, Flutter doesn't provide a built-in SBOM generator, but you can create one by analyzing the project's dependencies using available tools. Here's how to do it:
🔧 Steps to Generate an SBOM for a Flutter App
✅ 1. Understand What You Want in the SBOM
Typical SBOMs include:
Package name
Version
Dependencies (transitive or direct)
Source/origin (e.g., Git repo or package registry)
If you're targeting a specific platform (Android, iOS, Web), let me know — I can tailor the instructions further!
User
does trivy could generate sbom with a pubspec.lock
Assistant
Great question!
As of now (latest updates till mid-2024), Trivycannot directly generate an SBOM from a pubspec.lock file because it does not natively parse Dart/Flutter dependency manifests like pubspec.yaml or pubspec.lock.
However, Trivy can generate SBOMs for compiled artifacts, such as Docker images or filesystem directories — but not for raw Dart/Flutter source code projects using pubspec.lock alone.
🔍 Trivy's Current Capabilities (as of 2024)
Feature
Supported?
Notes
SBOM from pubspec.lock
❌ No
Trivy doesn’t parse Dart/Flutter lock files
SBOM from compiled binary
✅ Yes
E.g., APK, IPA, or Docker image built from Flutter app
SBOM from directory
✅ Partial
Trivy FS mode detects installed OS packages, not language dependencies
SBOM Formats
✅ SPDX, CycloneDX
Supports multiple SBOM standards when applicable
✅ Workaround: Generate SBOM from Compiled Flutter App Using Trivy
If your goal is to generate an SBOM for a deployed Flutter app, you can:
⚠️ Note: Trivy will analyze the contents of the APK (compiled bytecode, embedded assets, and native libs), but won’t map them back to high-level Dart packages from pubspec.yaml. So the SBOM will show OS-level libraries and possibly some native deps — but not Flutter/Dart dependencies.
🔄 Alternative: Combine cyclonedx-pub + Trivy
To get a complete picture, consider this hybrid approach:
Tool
Input
Output
Purpose
cyclonedx-pub
pubspec.lock
CycloneDX (Dart packages)
High-level app dependencies
trivy sbom
app-release.apk
CycloneDX (native libs)
Low-level binary/components
You can merge these two SBOMs manually or via tooling (e.g., Syft + SPDX merger, or custom scripts) for full visibility across app layers.
🧩 Better Alternatives for Dart/Flutter SBOMs Today
If you're specifically looking to generate SBOMs from pubspec.lock, these tools are better suited:
Tool
Format
Pubspec Support
Notes
cyclonedx-pub
CycloneDX
✅ Yes
Maintained by community
sbom
SPDX
✅ Yes
Still early-stage but improving
dependabot
Various
✅ (indirectly)
GitHub-native, limited SBOM output
✅ Summary
Question
Answer
Can Trivy generate SBOM from pubspec.lock?
❌ No
Can Trivy generate SBOM from compiled Flutter app?
✅ Yes
Best tool for Dart/Flutter SBOM today?
cyclonedx-pub or sbom
Would you like a script to combine cyclonedx-pub and trivy outputs into a unified SBOM?