Skip to content

Add SPDX license policy gate#268

Merged
JE-Chen merged 3 commits into
devfrom
feat/license-policy
Jun 20, 2026
Merged

Add SPDX license policy gate#268
JE-Chen merged 3 commits into
devfrom
feat/license-policy

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

build_sbom records 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. deny wins; empty allow = unconstrained; missing license = unknown. SPDX expressions: OR is a choice (any operand allowed), AND requires all.
  • evaluate_sbom(components, *, allow, deny) — violations {name, version, license, status} over the SBOM's licenses field (handles license.name, license.id, and expression).
  • license_findings_to_sarif(violations)denied→SARIF error, unknownwarning. DEFAULT_COPYLEFT is a ready-made denylist.

Pure stdlib (re), fully offline, Qt-free.

Five-layer wiring

  • Headless core: je_auto_control/utils/license_policy/
  • Facade: re-exported from __init__.py + __all__
  • Executor: AC_check_licenses (component list, full SBOM dict, or JSON; optional allow/deny)
  • MCP: ac_check_licenses
  • Script Builder: "Check Dependency Licenses" under Security

Tests & docs

  • test/unit_test/headless/test_license_policy_batch.py (13 tests incl. OR/AND expressions, deny precedence, SARIF levels)
  • v60 feature docs (EN + Zh) + toctree registration
  • What's-new sections in all three READMEs

Lint clean: ruff / pylint / bandit / radon (no function CC > 10).

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.
@codacy-production

codacy-production Bot commented Jun 20, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 57 complexity · 0 duplication

Metric Results
Complexity 57
Duplication 0

View in Codacy

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.

@JE-Chen JE-Chen merged commit 31f00db into dev Jun 20, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/license-policy branch June 20, 2026 18:02
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant