You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: SPDX expression handling is the SDK's, not a local wrapper (#428)
Phase 2.2, which the train skipped: internal/licenseexpr exposed Valid,
ValidateAll, Identifier, Compose, Satisfies and Extract, and bomly-sdk/spdxkit
exposes the same six with the same signatures. Two implementations of one
specification's semantics is the drift this program exists to remove, and it
was sitting directly under the next phase's work.
The call sites move to the kit, the package is deleted, and go-spdx drops to
indirect. No golden moves: the two Compose implementations agree on every
fixture the smoke suite produces, which is the check that mattered, since
composition is the one function where parenthesization could have differed.
The panic guard survives the move -- the kit carries it -- so the rule it
protected changes shape rather than disappearing. It used to be "route through
the local wrapper"; it is now "do not import the parser at all", and
TestNoDirectSPDXExpressionUse moves to internal/detectors/guards_test.go where
the other tree-wide structural guards live. It scans test files too, because a
test reaching the parser directly proves the same crash is reachable and is
where the temptation lives. Mutation-checked by importing go-spdx into
internal/sbom.
This is the prerequisite for 2.4 (#410): LicenseRef-* minting,
hasExtractedLicensingInfos, and mixed-validity composition are all already in
spdxkit -- MintLicenseRef, Classify, Compose -- and its doc comments cite the
issue by number. Building that on the local wrapper would have meant
hand-rolling identifier sanitization and collision-avoidance beside a library
that already owns both.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|`internal/licenseexpr`| SPDX license expression parsing and identifier classification (guards the parser's panics) |
71
70
|`internal/benchmark`| Hidden local dependency-graph benchmark, baseline comparison, scoring, and embedded presets |
72
71
|`internal/output`| Output rendering plus structured command payloads and schema generation for `scan`, `diff`, `explain`, JSON, and SARIF 2.1.0 |
73
72
|`internal/plugin`| Plugin discovery, protocol, handshake, and pooled subprocess execution |
@@ -111,7 +110,7 @@ Runtime preparation is owned by `internal/engine`: build the filtered registry o
111
110
-`internal/testnodes` is test-only: it routes fixture shapes through the real node constructors, panicking rather than taking a `testing.TB` so a table entry stays one expression. Label lookups ("name@version" to the canonical package URLs node IDs now are) delegate to `bomly-sdk/testkit` — the matching rules have one home, not two. Non-test code must not import it.
112
111
-`internal/baseline` owns the baseline document and matching implementation. It depends on the SDK policy contracts and must not be imported by `internal/engine`.
113
112
-`internal/remediation` owns canonical vulnerability remediation decisions. Detectors may supply validated read-only strategy hints, but they do not choose final actions or versions.
114
-
-`internal/licenseexpr` owns all SPDX license expression parsing. The underlying parser panics on some malformed input, and license strings come from untrusted lockfiles and registry APIs, so no other package under `internal/` may import `github.com/github/go-spdx` directly; `TestNoDirectSPDXExpressionUse` enforces this.
113
+
-SPDX license expression handling is `bomly-sdk/spdxkit`'s: validation, identifier classification, composition, deprecated-ID canonicalization, and `LicenseRef-*` minting. The underlying parser panics on some malformed input, and license strings come from untrusted lockfiles and registry APIs, so no package under `internal/` may import `github.com/github/go-spdx` directly — the kit carries the panic guard. `TestNoDirectSPDXExpressionUse`(in `internal/detectors/guards_test.go`) enforces this across the whole tree, test files included. The CLI's own `internal/licenseexpr` wrapper is deleted; it duplicated the kit function for function.
115
114
-`internal/registry` owns package-manager discovery, support lookups, and built-in registry wiring in `internal/registry/builder.go`. Do not create or reintroduce a separate `registrybuilder` package.
116
115
-`internal/engine` may import `internal/detectors` and `internal/registry`, but detector packages must not point back into `internal/engine`. Runtime planning, prepared subprojects, and detector-chain reuse belong in `internal/engine`.
|`internal/licenseexpr`| SPDX license expression parsing and identifier classification (guards the parser's panics) |
71
70
|`internal/benchmark`| Hidden local dependency-graph benchmark, baseline comparison, scoring, and embedded presets |
72
71
|`internal/output`| Output rendering plus structured command payloads and schema generation for `scan`, `diff`, `explain`, JSON, and SARIF 2.1.0 |
73
72
|`internal/plugin`| Plugin discovery, protocol, handshake, and pooled subprocess execution |
@@ -111,7 +110,7 @@ Runtime preparation is owned by `internal/engine`: build the filtered registry o
111
110
-`internal/testnodes` is test-only: it routes fixture shapes through the real node constructors, panicking rather than taking a `testing.TB` so a table entry stays one expression. Label lookups ("name@version" to the canonical package URLs node IDs now are) delegate to `bomly-sdk/testkit` — the matching rules have one home, not two. Non-test code must not import it.
112
111
-`internal/baseline` owns the baseline document and matching implementation. It depends on the SDK policy contracts and must not be imported by `internal/engine`.
113
112
-`internal/remediation` owns canonical vulnerability remediation decisions. Detectors may supply validated read-only strategy hints, but they do not choose final actions or versions.
114
-
-`internal/licenseexpr` owns all SPDX license expression parsing. The underlying parser panics on some malformed input, and license strings come from untrusted lockfiles and registry APIs, so no other package under `internal/` may import `github.com/github/go-spdx` directly; `TestNoDirectSPDXExpressionUse` enforces this.
113
+
-SPDX license expression handling is `bomly-sdk/spdxkit`'s: validation, identifier classification, composition, deprecated-ID canonicalization, and `LicenseRef-*` minting. The underlying parser panics on some malformed input, and license strings come from untrusted lockfiles and registry APIs, so no package under `internal/` may import `github.com/github/go-spdx` directly — the kit carries the panic guard. `TestNoDirectSPDXExpressionUse`(in `internal/detectors/guards_test.go`) enforces this across the whole tree, test files included. The CLI's own `internal/licenseexpr` wrapper is deleted; it duplicated the kit function for function.
115
114
-`internal/registry` owns package-manager discovery, support lookups, and built-in registry wiring in `internal/registry/builder.go`. Do not create or reintroduce a separate `registrybuilder` package.
116
115
-`internal/engine` may import `internal/detectors` and `internal/registry`, but detector packages must not point back into `internal/engine`. Runtime planning, prepared subprojects, and detector-chain reuse belong in `internal/engine`.
0 commit comments