Add SPDX license policy gate#268
Merged
Merged
Conversation
The SBOM recorded each component's license name but never judged it, so a disallowed or copyleft license could ship unnoticed. Add a policy gate that normalizes license strings to SPDX ids and evaluates them against allow/deny lists (with a built-in strong-copyleft set), understanding SPDX OR/AND expressions, then bridges violations into the SARIF exporter. Pure stdlib and fully offline; wired through the facade, AC_check_licenses executor command, ac_check_licenses MCP tool and Script Builder.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 57 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
build_sbomrecords each component's license name but nothing ever judged it — a copyleft or otherwise-disallowed license could ship unnoticed. This adds the policy gate, completing the supply-chain governance lane (SBOM inventory → OSV vuln scan → VEX triage → license policy, all feeding SARIF).normalize_spdx(raw)— map loose names ("MIT License"→MIT,"Apache 2.0"→Apache-2.0) to SPDX ids.evaluate_license(s, *, allow, deny)—allowed/denied/unknown.denywins; emptyallow= unconstrained; missing license =unknown. SPDX expressions:ORis a choice (any operand allowed),ANDrequires all.evaluate_sbom(components, *, allow, deny)— violations{name, version, license, status}over the SBOM'slicensesfield (handleslicense.name,license.id, andexpression).license_findings_to_sarif(violations)—denied→SARIFerror,unknown→warning.DEFAULT_COPYLEFTis a ready-made denylist.Pure stdlib (
re), fully offline, Qt-free.Five-layer wiring
je_auto_control/utils/license_policy/__init__.py+__all__AC_check_licenses(component list, full SBOM dict, or JSON; optionalallow/deny)ac_check_licensesTests & docs
test/unit_test/headless/test_license_policy_batch.py(13 tests incl. OR/AND expressions, deny precedence, SARIF levels)Lint clean: ruff / pylint / bandit / radon (no function CC > 10).