|
| 1 | +# Detailed SBOM Implementation Approach for Eclipse SCORE |
| 2 | + |
| 3 | +## Executive Summary |
| 4 | + |
| 5 | +This proposal addresses the existing backlog items ([#2144](https://github.com/eclipse-score/score/issues/2144), [#2232](https://github.com/eclipse-score/score/issues/2232), [#2060](https://github.com/eclipse-score/score/issues/2060), [#2103](https://github.com/eclipse-score/score/issues/2103)) and provides a comprehensive implementation roadmap for SBOM generation in Eclipse SCORE. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## High-Level Architecture |
| 10 | + |
| 11 | + |
| 12 | +``` |
| 13 | +┌─────────────────────────────────────────────────────────────────────────────┐ |
| 14 | +│ SCORE SBOM ARCHITECTURE │ |
| 15 | +├─────────────────────────────────────────────────────────────────────────────┤ |
| 16 | +│ │ |
| 17 | +│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ |
| 18 | +│ │ Rust │ │ C++ │ │ Bazel │ │ |
| 19 | +│ │ Cargo.toml │ │ http_archive│ │ MODULE.bazel│ │ |
| 20 | +│ │ (metadata) │ │ git_override│ │ (bazel_dep) │ │ |
| 21 | +│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │ |
| 22 | +│ │ │ │ │ |
| 23 | +│ ▼ ▼ ▼ │ |
| 24 | +│ ┌─────────────────────────────────────────────────────────────────────┐ │ |
| 25 | +│ │ SBOM GENERATOR MODULE │ │ |
| 26 | +│ │ ┌──────────────────────┐ ┌──────────────────────┐ │ │ |
| 27 | +│ │ │ Bazel Aspect │ │ Metadata Extension │ │ │ |
| 28 | +│ │ │ (dep graph traversal│ │ (license/supplier │ │ │ |
| 29 | +│ │ │ via sbom_aspect) │ │ from MODULE.bazel)│ │ │ |
| 30 | +│ │ └──────────────────────┘ └──────────────────────┘ │ │ |
| 31 | +│ └─────────────────────────────────────────────────────────────────────┘ │ |
| 32 | +│ │ │ |
| 33 | +│ ┌─────────────────┴─────────────────┐ │ |
| 34 | +│ ▼ ▼ │ |
| 35 | +│ ┌─────────────┐ ┌─────────────┐ │ |
| 36 | +│ │ SPDX 2.3 │ │ CycloneDX │ │ |
| 37 | +│ │ .spdx.json │ │ 1.6 .json │ │ |
| 38 | +│ └─────────────┘ └─────────────┘ │ |
| 39 | +│ │ |
| 40 | +└─────────────────────────────────────────────────────────────────────────────┘ |
| 41 | +``` |
| 42 | + |
| 43 | +### 2.2 Integration with Existing SCORE Tooling |
| 44 | + |
| 45 | +Dash is a **license compliance checker** only (no SBOM output, no VEX). |
| 46 | +SBOM generation is a new, separate module that complements Dash. |
| 47 | + |
| 48 | +``` |
| 49 | +┌─────────────────────────────────────────────────────────────────────────────┐ |
| 50 | +│ eclipse-score/tooling │ |
| 51 | +├─────────────────────────────────────────────────────────────────────────────┤ |
| 52 | +│ │ |
| 53 | +│ EXISTING NEW (IMPLEMENTED) │ |
| 54 | +│ ──────── ────────────────── │ |
| 55 | +│ ├── dash/ ├── sbom/ │ |
| 56 | +│ │ └── dash_license_checker │ ├── defs.bzl │ |
| 57 | +│ │ (license compliance) │ │ └── sbom() macro │ |
| 58 | +│ ├── cr_checker/ │ ├── extensions.bzl │ |
| 59 | +│ │ └── copyright_checker │ │ └── sbom.license() │ |
| 60 | +│ │ (header validation) │ ├── internal/ │ |
| 61 | +│ │ │ │ ├── aspect.bzl (dep traversal) │ |
| 62 | +│ │ │ │ ├── rules.bzl (build rule) │ |
| 63 | +│ │ │ │ └── generator/ │ |
| 64 | +│ │ │ │ ├── sbom_generator.py │ |
| 65 | +│ │ │ │ ├── spdx_formatter.py │ |
| 66 | +│ │ │ │ ├── cyclonedx_formatter.py │ |
| 67 | +│ │ │ │ └── purl.py │ |
| 68 | +│ │ │ └── tests/ │ |
| 69 | +│ │ │ │ |
| 70 | +│ COMPLEMENTARY WORKFLOW │ │ |
| 71 | +│ ────────────────────── │ │ |
| 72 | +│ Dash: checks if dependency │ │ |
| 73 | +│ licenses are allowed by policy │ │ |
| 74 | +│ SBOM: generates .spdx.json / │ │ |
| 75 | +│ .cdx.json listing all deps │ │ |
| 76 | +│ with name, version, license, │ │ |
| 77 | +│ supplier, PURL │ │ |
| 78 | +│ │ │ |
| 79 | +│ VALIDATION (external, optional) │ │ |
| 80 | +│ ──────────────────────────── │ │ |
| 81 | +│ pip install spdx-tools │ │ |
| 82 | +│ pyspdxtools -i out.spdx.json │ │ |
| 83 | +│ Or: https://tools.spdx.org │ │ |
| 84 | +│ │ |
| 85 | +└─────────────────────────────────────────────────────────────────────────────┘ |
| 86 | +``` |
| 87 | + |
| 88 | +## 3. SBOM Generation Chain |
| 89 | + |
| 90 | +When `bazel build //:my_sbom` is invoked, the following chain executes: |
| 91 | + |
| 92 | +``` |
| 93 | + ┌──────────────────────────────────────────────────────────────────────┐ |
| 94 | + │ PHASE 1: Loading (MODULE.bazel) │ |
| 95 | + │ │ |
| 96 | + │ sbom_metadata module extension iterates ALL modules in workspace: │ |
| 97 | + │ - Collects sbom.license() tags (name, license, supplier, version) │ |
| 98 | + │ - Collects sbom.license(type="cargo") tags (Rust crates) │ |
| 99 | + │ - Writes metadata.json to @sbom_metadata repository │ |
| 100 | + └──────────────────────────┬───────────────────────────────────────────┘ |
| 101 | + │ |
| 102 | + ▼ |
| 103 | + ┌──────────────────────────────────────────────────────────────────────┐ |
| 104 | + │ PHASE 2: Analysis (aspect.bzl) │ |
| 105 | + │ │ |
| 106 | + │ sbom_aspect is attached to `targets` attr of sbom_rule. │ |
| 107 | + │ For each target in targets = ["//src:app"]: │ |
| 108 | + │ - Traverses deps, srcs, proc_macro_deps, hdrs, etc. │ |
| 109 | + │ - Recursively collects SbomDepsInfo from all transitive deps │ |
| 110 | + │ - Builds depsets of: │ |
| 111 | + │ * external_repos (e.g. "score_kyron", "crates__tokio-1.10") │ |
| 112 | + │ * transitive_deps (all labels in the dep graph) │ |
| 113 | + └──────────────────────────┬───────────────────────────────────────────┘ |
| 114 | + │ |
| 115 | + ▼ |
| 116 | + ┌──────────────────────────────────────────────────────────────────────┐ |
| 117 | + │ PHASE 3: Execution (rules.bzl → sbom_generator.py) │ |
| 118 | + │ │ |
| 119 | + │ _sbom_impl combines aspect output + extension metadata: │ |
| 120 | + │ 1. Reads external_repos and transitive_deps from SbomDepsInfo │ |
| 121 | + │ 2. Reads metadata.json from @sbom_metadata extension │ |
| 122 | + │ 3. Writes _deps.json with all data + config │ |
| 123 | + │ 4. Runs sbom_generator.py which: │ |
| 124 | + │ a. Filters repos by exclude_patterns (removes build tools) │ |
| 125 | + │ b. Resolves each repo to a component (name, version, PURL) │ |
| 126 | + │ c. Merges extension metadata (license, supplier, version) │ |
| 127 | + │ d. Calls spdx_formatter.py → {name}.spdx.json │ |
| 128 | + │ e. Calls cyclonedx_formatter.py → {name}.cdx.json │ |
| 129 | + └──────────────────────────────────────────────────────────────────────┘ |
| 130 | +``` |
| 131 | + |
| 132 | +### Key files in the chain |
| 133 | + |
| 134 | +| File | Phase | Role | |
| 135 | +|------|-------|------| |
| 136 | +| `extensions.bzl` | Loading | Collects `sbom.license()` from all modules (all dep types) | |
| 137 | +| `internal/aspect.bzl` | Analysis | Traverses target dep graph, returns `SbomDepsInfo` | |
| 138 | +| `internal/providers.bzl` | Analysis | Defines `SbomDepsInfo` provider (external_repos, transitive_deps) | |
| 139 | +| `internal/rules.bzl` | Execution | Joins aspect + extension data, invokes Python generator | |
| 140 | +| `internal/generator/sbom_generator.py` | Execution | Resolves repos to components, calls formatters | |
| 141 | +| `internal/generator/spdx_formatter.py` | Execution | Produces SPDX 2.3 JSON | |
| 142 | +| `internal/generator/cyclonedx_formatter.py` | Execution | Produces CycloneDX 1.6 JSON | |
| 143 | +| `internal/generator/purl.py` | Execution | Generates Package URLs for components | |
| 144 | +| `defs.bzl` | Public API | `sbom()` macro | |
| 145 | + |
| 146 | +## 4. Tool Selection |
| 147 | + |
| 148 | +### 4.1 Implemented Tool Stack |
| 149 | + |
| 150 | +| Component | Tool Used | Status | Rationale | |
| 151 | +|-----------|-----------|--------|-----------| |
| 152 | +| SBOM Framework | Custom Bazel rules (aspects + module extension) | Implemented | Native Bazel integration, hermetic builds | |
| 153 | +| Dependency Discovery | Bazel aspect (sbom_aspect) | Implemented | Traverses transitive deps of any target | |
| 154 | +| Rust Crate Metadata | `sbom.license(type = "cargo")` in MODULE.bazel | Implemented | Manual license/supplier, auto PURL | |
| 155 | +| SPDX Generation | Custom Python formatter (spdx_formatter.py) | Implemented | SPDX 2.3 JSON, validated at tools.spdx.org | |
| 156 | +| CycloneDX Generation | Custom Python formatter (cyclonedx_formatter.py) | Implemented | CycloneDX 1.6 JSON | |
| 157 | +| License Data | `sbom.license()` in MODULE.bazel | Implemented | Manual declaration per dependency | |
| 158 | +| SPDX Validation | [spdx-tools](https://github.com/spdx/tools-python) (external) | Available | For offline validation | |
| 159 | +| License Compliance | Existing Dash (separate tool) | Existing | Complements SBOM, not integrated | |
| 160 | + |
| 161 | +--- |
0 commit comments