From 2b287ba99141d11ff079c123db1627f1b35be77e Mon Sep 17 00:00:00 2001 From: Rzy <168882072+Iky969@users.noreply.github.com> Date: Mon, 30 Nov 2026 17:39:18 +0000 Subject: [PATCH 1/6] ci: add license artifact check and release note addendum --- .github/workflows/license-check.yml | 32 ++++ RELEASE-NOTES-v1.2.0.md | 31 ++++ .../2026-11-30-phase4-history-rewrite-note.md | 27 ++++ licenses/README.md | 10 ++ licenses/allowlist.json | 153 ++++++++++++++++++ scripts/check-license-artifacts.py | 98 +++++++++++ 6 files changed, 351 insertions(+) create mode 100644 .github/workflows/license-check.yml create mode 100644 archive/2026-11-30-phase4-history-rewrite-note.md create mode 100644 licenses/allowlist.json create mode 100644 scripts/check-license-artifacts.py diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml new file mode 100644 index 0000000..b35583b --- /dev/null +++ b/.github/workflows/license-check.yml @@ -0,0 +1,32 @@ +name: license-check + +on: + push: + branches: [main, master] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + license-artifacts: + name: License & provenance artifact check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential busybox-static python3 tar xz-utils curl + + - name: Build base packages + run: make packages + + - name: Check ELF artifacts against the license allowlist + run: | + python3 scripts/check-license-artifacts.py \ + --root packages \ + --root distro/packages \ + --allowlist licenses/allowlist.json diff --git a/RELEASE-NOTES-v1.2.0.md b/RELEASE-NOTES-v1.2.0.md index a033ba0..d3b49f5 100644 --- a/RELEASE-NOTES-v1.2.0.md +++ b/RELEASE-NOTES-v1.2.0.md @@ -70,3 +70,34 @@ S.A.N.E Linux v1.2.0 is a major milestone release delivering production-grade in - **Guidance for Package Authors & System Deployers**: - Kernel and bootloader installation scripts must perform staging and copy operations within the same filesystem or explicitly handle cross-device copying when updating `/boot`. - Never attempt to symlink `/boot/vmlinuz` to a versioned kernel binary on a FAT32 ESP partition. + +--- + +## 6. Addendum 2026-11-30 — Licensing, provenance & source availability + +This addendum records the follow-up licensing work that landed after the +original v1.2.0 release. It does not change the historical feature list above. + +- Full license texts are bundled under `licenses/`, with provenance recorded in + `licenses/README.md`. +- `SOURCE-OFFER.md` carries the written offer for complete corresponding + source, valid for at least three years after the last distribution of the + covered binaries. +- The permanent source release is `v1.2.1-source`: + . It + contains the kernel bundle, both BusyBox source variants, the dosfstools + source package, and the pinned `build-rootfs-1.36.1.sh` script. +- `packages/kernel/PROVENANCE` and `packages/disk-tools/PROVENANCE` record the + exact upstreams, hashes, and build paths of the shipped kernel and + dosfstools binaries. +- A canonical `packages/busybox/config-1.36.1` is committed and consumed by + `scripts/build-rootfs.sh`. +- A new license-check workflow, `.github/workflows/license-check.yml`, runs + `scripts/check-license-artifacts.py` against `packages/` and the built + `distro/packages/` output, using `licenses/allowlist.json`. Unknown ELF + binaries or hash mismatches now fail the build instead of slipping through + unnoticed. +- Phase 4 (history rewrite with `git filter-repo`) is deliberately **not** + executed. It is recorded as an archive note only, because source offers and + release assets already satisfy the GPL obligations without rewriting public + history. diff --git a/archive/2026-11-30-phase4-history-rewrite-note.md b/archive/2026-11-30-phase4-history-rewrite-note.md new file mode 100644 index 0000000..81dea41 --- /dev/null +++ b/archive/2026-11-30-phase4-history-rewrite-note.md @@ -0,0 +1,27 @@ +# Phase 4 archive note — history rewrite decision + +Date: 2026-11-30. + +The earlier suggestion was to run `git filter-repo` to remove BusyBox and +kernel binaries from all history, followed by force-push of all branches and +tags. + +Decision: **do not execute that rewrite.** This file is the only record of +that decision. + +Reasons: + +- The complete corresponding sources are already published in the permanent + `v1.2.1-source` GitHub Release, so the GPL obligations do not depend on + deleting historical binaries. +- Rewriting published history would invalidate PR heads, release tags, and + existing forks/clones, and would require regenerating release assets and + tags. +- Force-pushing all branches and tags is a destructive operation that should + never be performed as a reflex to a license audit. +- Keeping this note preserves the rationale without pretending the rewrite was + ever carried out. + +If a future maintainer still wants to shrink history, it must be a separate, +explicitly approved migration after the source releases are final and a full +backup exists. This note does not authorize that operation. diff --git a/licenses/README.md b/licenses/README.md index db913b5..b35a1e1 100644 --- a/licenses/README.md +++ b/licenses/README.md @@ -23,3 +23,13 @@ above are recorded for verification. For the GPL-2.0-only binaries shipped in S.A.N.E Linux images, see [`SOURCE-OFFER.md`](../SOURCE-OFFER.md) and [`THIRD_PARTY_LICENSES.md`](../THIRD_PARTY_LICENSES.md). + +## License artifact allowlist + +`allowlist.json` is consumed by `scripts/check-license-artifacts.py` and by the +`license-check` GitHub Actions workflow. Each entry names a binary path or +glob, its license, and its source reference. First-party packages are marked +with `first_party: true` so they are not mistaken for third-party GPL payloads. +Optional `sha256` fields pin critical binaries (BusyBox, kernel, dosfstools). +When adding a new binary, update this file and `THIRD_PARTY_LICENSES.md` in the +same PR, and publish its source asset if it is third-party. diff --git a/licenses/allowlist.json b/licenses/allowlist.json new file mode 100644 index 0000000..0d7e8fe --- /dev/null +++ b/licenses/allowlist.json @@ -0,0 +1,153 @@ +[ + { + "path": "packages/ninit/x/**", + "match": "glob", + "component": "ninit and its companion utilities", + "license": "MIT", + "source_ref": "ninit.c and scripts/ in this repository", + "first_party": true + }, + { + "path": "packages/spm/x/**", + "match": "glob", + "component": "S.A.N.E Package Manager (spm)", + "license": "MIT", + "source_ref": "scripts/spm in this repository", + "first_party": true + }, + { + "path": "packages/busybox/x/bin/busybox", + "component": "BusyBox (Ubuntu build)", + "license": "GPL-2.0-only", + "source_ref": "busybox-ubuntu-1.37.0-7ubuntu1-source.tar.gz in v1.2.1-source", + "sha256": "8d4e5a13ce30fb66fa7156a25f738e690b1dfc4823774dfab5a0f1fd7fed48f7" + }, + { + "path": "packages/busybox/x/bin/*", + "match": "glob", + "component": "BusyBox applets (hardlink/symlink aliases of the packaged BusyBox)", + "license": "GPL-2.0-only", + "source_ref": "Same BusyBox upstream source as the packaged binary in v1.2.1-source" + }, + { + "path": "packages/busybox/x/sbin/*", + "match": "glob", + "component": "BusyBox applets (hardlink/symlink aliases of the packaged BusyBox)", + "license": "GPL-2.0-only", + "source_ref": "Same BusyBox upstream source as the packaged binary in v1.2.1-source" + }, + { + "path": "packages/kernel/x/boot/vmlinuz-virt", + "component": "Linux kernel 6.6.134 virt flavor", + "license": "GPL-2.0-only", + "source_ref": "linux-6.6.134-sane-source.tar.gz in v1.2.1-source", + "sha256": "be523954ad673a78c9cdfd3d473a8d39609f5901adfcc68402c67dc037a64c7e" + }, + { + "path": "packages/kernel/x/lib/modules/*.ko", + "match": "glob", + "component": "Linux kernel modules 6.6.134", + "license": "GPL-2.0-only", + "source_ref": "linux-6.6.134-sane-source.tar.gz in v1.2.1-source" + }, + { + "path": "packages/disk-tools/x/usr/sbin/mkfs.fat", + "component": "dosfstools", + "license": "GPL-3.0-only", + "source_ref": "dosfstools-ubuntu-4.2-1.2build1-source.tar.gz in v1.2.1-source", + "sha256": "3bded05c428857023571416308f0ecf0fce2f9d44f0e5b7ec3b371c1350f45a4" + }, + { + "path": "packages/disk-tools/x/usr/sbin/mkfs.vfat", + "component": "dosfstools", + "license": "GPL-3.0-only", + "source_ref": "dosfstools-ubuntu-4.2-1.2build1-source.tar.gz in v1.2.1-source", + "sha256": "3bded05c428857023571416308f0ecf0fce2f9d44f0e5b7ec3b371c1350f45a4" + }, + { + "path": "packages/disk-tools/x/usr/sbin/sgdisk", + "component": "gptfdisk", + "license": "GPL-2.0-only", + "source_ref": "https://sourceforge.net/projects/gptfdisk/" + }, + { + "path": "packages/disk-tools/x/usr/sbin/mke2fs", + "component": "e2fsprogs", + "license": "GPL-2.0-only", + "source_ref": "https://e2fsprogs.sourceforge.net/" + }, + { + "path": "packages/disk-tools/x/usr/sbin/mkfs.ext2", + "component": "e2fsprogs", + "license": "GPL-2.0-only", + "source_ref": "https://e2fsprogs.sourceforge.net/" + }, + { + "path": "packages/disk-tools/x/usr/sbin/mkfs.ext4", + "component": "e2fsprogs", + "license": "GPL-2.0-only", + "source_ref": "https://e2fsprogs.sourceforge.net/" + }, + { + "path": "packages/curl/x/usr/bin/curl", + "component": "curl", + "license": "curl license (MIT/X derivative)", + "source_ref": "licenses/curl.txt and curl 8.11.0 upstream" + }, + { + "path": "packages/doas/x/usr/bin/doas", + "component": "OpenDoas", + "license": "ISC", + "source_ref": "https://github.com/Duncaen/OpenDoas/releases/download/v6.8.2/opendoas-6.8.2.tar.gz" + }, + { + "path": "packages/libressl/x/usr/bin/openssl", + "component": "LibreSSL", + "license": "ISC (includes OpenSSL-derived code)", + "source_ref": "https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.9.2.tar.gz" + }, + { + "path": "packages/libressl/x/usr/bin/ocspcheck", + "component": "LibreSSL", + "license": "ISC (includes OpenSSL-derived code)", + "source_ref": "https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.9.2.tar.gz" + }, + { + "path": "packages/limine-static/x/usr/bin/limine", + "component": "Limine bootloader", + "license": "BSD-2-Clause", + "source_ref": "https://github.com/Limine-Bootloader/Limine/releases/download/v12.9.6/limine-binary.tar.xz" + }, + { + "path": "packages/wpa-supplicant/x/usr/bin/wpa_supplicant", + "component": "wpa_supplicant", + "license": "BSD-3-Clause (GPL-2.0 alternative)", + "source_ref": "https://w1.fi/releases/wpa_supplicant-2.10.tar.gz" + }, + { + "path": "packages/wpa-supplicant/x/usr/bin/wpa_cli", + "component": "wpa_supplicant", + "license": "BSD-3-Clause (GPL-2.0 alternative)", + "source_ref": "https://w1.fi/releases/wpa_supplicant-2.10.tar.gz" + }, + { + "path": "packages/musl/x/usr/lib/libc.so", + "component": "musl libc", + "license": "MIT", + "source_ref": "https://musl.libc.org/releases/musl-1.2.5.tar.gz" + }, + { + "path": "packages/musl/x/lib/ld-musl-*.so.*", + "match": "glob", + "component": "musl libc dynamic loader", + "license": "MIT", + "source_ref": "https://musl.libc.org/releases/musl-1.2.5.tar.gz" + }, + { + "path": "packages/musl/x/usr/lib/*.o", + "match": "glob", + "component": "musl libc startup objects", + "license": "MIT", + "source_ref": "https://musl.libc.org/releases/musl-1.2.5.tar.gz" + } +] diff --git a/scripts/check-license-artifacts.py b/scripts/check-license-artifacts.py new file mode 100644 index 0000000..c99b1d5 --- /dev/null +++ b/scripts/check-license-artifacts.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 +"""Fail if an ELF binary in a build/output tree is not registered in allowlist. + +Stdlib only. The allowlist is a JSON list of entries: + {"path": "packages/busybox/x/bin/busybox", "component": "BusyBox", + "license": "GPL-2.0-only", "source_ref": "busybox-ubuntu-...tar.gz", + "sha256": "optional", "match": "exact|glob"} + +- `match: exact` compares the repo-relative path exactly. +- `match: glob` uses fnmatch, e.g. packages/kernel/x/lib/modules/*.ko. +- `sha256` is optional; when present it must match the binary's digest. +- `first_party: true` marks entries whose source is this repository itself. +""" +from __future__ import annotations + +import argparse +import fnmatch +import hashlib +import json +import os +from pathlib import Path + + +def sha256_of(path: Path) -> str: + h = hashlib.sha256() + with path.open("rb") as f: + for chunk in iter(lambda: f.read(1024 * 1024), b""): + h.update(chunk) + return h.hexdigest() + + +def iter_elf_files(root: Path): + if not root.exists(): + return + for p in sorted(root.rglob("*")): + if not p.is_file(): + continue + try: + with p.open("rb") as f: + magic = f.read(4) + except OSError: + continue + if magic == b"\x7fELF": + yield p + + +def matches(path: str, entry: dict) -> bool: + if entry.get("match", "exact") == "glob": + return fnmatch.fnmatch(path, entry["path"]) + return path == entry["path"] + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--root", action="append", required=True, + help="Directory to scan; may be repeated.") + ap.add_argument("--allowlist", default="licenses/allowlist.json") + args = ap.parse_args() + + entries = json.loads(Path(args.allowlist).read_text()) + failures = [] + checked = 0 + + for root_arg in args.root: + root = Path(root_arg) + for elf in iter_elf_files(root): + try: + rel = elf.relative_to(Path.cwd()).as_posix() + except ValueError: + rel = elf.as_posix() + checked += 1 + entry = next((e for e in entries if matches(rel, e)), None) + if entry is None: + failures.append((rel, "not registered in licenses/allowlist.json")) + continue + expected = entry.get("sha256") + if expected: + actual = sha256_of(elf) + if actual != expected: + failures.append( + (rel, + f"sha256 mismatch: expected {expected}, got {actual}. " + f"Update the allowlist and its source asset in the same PR.")) + + if failures: + print(f"FAIL: {len(failures)} unlicensed or mismatched artifact(s)") + for rel, why in failures: + print(f" - {rel}: {why}") + print("Add the artifact to licenses/allowlist.json and to " + "THIRD_PARTY_LICENSES.md (plus its source asset if third-party).") + return 1 + + print(f"PASS: {checked} ELF artifact(s) registered in licenses/allowlist.json") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) From bcffbbdf46ab15623ec74d65daf13aacb9527a5d Mon Sep 17 00:00:00 2001 From: Rzy <168882072+Iky969@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:37:37 +0000 Subject: [PATCH 2/6] fix(license-check): hash matched artifacts and skip applet symlinks --- licenses/allowlist.json | 17 ++--------- scripts/check-license-artifacts.py | 48 +++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/licenses/allowlist.json b/licenses/allowlist.json index 0d7e8fe..3f19ad3 100644 --- a/licenses/allowlist.json +++ b/licenses/allowlist.json @@ -16,26 +16,13 @@ "first_party": true }, { - "path": "packages/busybox/x/bin/busybox", + "path": "packages/busybox/x/**", + "match": "glob", "component": "BusyBox (Ubuntu build)", "license": "GPL-2.0-only", "source_ref": "busybox-ubuntu-1.37.0-7ubuntu1-source.tar.gz in v1.2.1-source", "sha256": "8d4e5a13ce30fb66fa7156a25f738e690b1dfc4823774dfab5a0f1fd7fed48f7" }, - { - "path": "packages/busybox/x/bin/*", - "match": "glob", - "component": "BusyBox applets (hardlink/symlink aliases of the packaged BusyBox)", - "license": "GPL-2.0-only", - "source_ref": "Same BusyBox upstream source as the packaged binary in v1.2.1-source" - }, - { - "path": "packages/busybox/x/sbin/*", - "match": "glob", - "component": "BusyBox applets (hardlink/symlink aliases of the packaged BusyBox)", - "license": "GPL-2.0-only", - "source_ref": "Same BusyBox upstream source as the packaged binary in v1.2.1-source" - }, { "path": "packages/kernel/x/boot/vmlinuz-virt", "component": "Linux kernel 6.6.134 virt flavor", diff --git a/scripts/check-license-artifacts.py b/scripts/check-license-artifacts.py index c99b1d5..e5eb6cb 100644 --- a/scripts/check-license-artifacts.py +++ b/scripts/check-license-artifacts.py @@ -8,7 +8,10 @@ - `match: exact` compares the repo-relative path exactly. - `match: glob` uses fnmatch, e.g. packages/kernel/x/lib/modules/*.ko. -- `sha256` is optional; when present it must match the binary's digest. +- `sha256` is optional; when present every matched ELF file is checked, and + exact pinned entries are also checked when the payload is not ELF (vmlinuz). +- Symlinks are skipped because applet symlinks are not independent payloads; + a new regular ELF still fails unless it is registered here. - `first_party: true` marks entries whose source is this repository itself. """ from __future__ import annotations @@ -17,7 +20,6 @@ import fnmatch import hashlib import json -import os from pathlib import Path @@ -30,18 +32,18 @@ def sha256_of(path: Path) -> str: def iter_elf_files(root: Path): - if not root.exists(): - return + """Yield (path, error). Unreadable candidates are reported, not skipped.""" for p in sorted(root.rglob("*")): - if not p.is_file(): + if p.is_symlink() or not p.is_file(): continue try: with p.open("rb") as f: magic = f.read(4) - except OSError: + except OSError as exc: + yield p, f"cannot read: {exc}" continue if magic == b"\x7fELF": - yield p + yield p, None def matches(path: str, entry: dict) -> bool: @@ -58,16 +60,23 @@ def main() -> int: args = ap.parse_args() entries = json.loads(Path(args.allowlist).read_text()) + base = Path(args.allowlist).resolve().parent.parent failures = [] checked = 0 for root_arg in args.root: root = Path(root_arg) - for elf in iter_elf_files(root): + if not root.exists(): + failures.append((root_arg, "scan root does not exist")) + continue + for elf, error in iter_elf_files(root): try: - rel = elf.relative_to(Path.cwd()).as_posix() + rel = elf.relative_to(base).as_posix() except ValueError: rel = elf.as_posix() + if error: + failures.append((rel, error)) + continue checked += 1 entry = next((e for e in entries if matches(rel, e)), None) if entry is None: @@ -80,9 +89,28 @@ def main() -> int: failures.append( (rel, f"sha256 mismatch: expected {expected}, got {actual}. " - f"Update the allowlist and its source asset in the same PR.")) + "Update the allowlist and its source asset in the same PR.")) + + # Pinned exact entries are checked even when the payload is not ELF, e.g. + # vmlinuz. Glob entries were already checked for every ELF they matched. + for entry in entries: + expected = entry.get("sha256") + if not expected or entry.get("match", "exact") == "glob": + continue + rel = entry["path"] + path = base / rel + if not path.exists(): + failures.append((rel, "expected binary is missing")) + continue + actual = sha256_of(path) + if actual != expected: + failures.append( + (rel, + f"sha256 mismatch: expected {expected}, got {actual}. " + "Update the allowlist and its source asset in the same PR.")) if failures: + failures = list(dict.fromkeys(failures)) print(f"FAIL: {len(failures)} unlicensed or mismatched artifact(s)") for rel, why in failures: print(f" - {rel}: {why}") From f251278ca55b2ba9f54a149f75fc4ca4c22dd346 Mon Sep 17 00:00:00 2001 From: Rzy <168882072+Iky969@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:40:47 +0000 Subject: [PATCH 3/6] docs(release): mark v1.2.0 notes historical --- RELEASE-NOTES-v1.2.0.md | 5 +++++ licenses/README.md | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES-v1.2.0.md b/RELEASE-NOTES-v1.2.0.md index d3b49f5..985aab4 100644 --- a/RELEASE-NOTES-v1.2.0.md +++ b/RELEASE-NOTES-v1.2.0.md @@ -1,5 +1,10 @@ # S.A.N.E Linux v1.2.0 Release Notes +> **Document status (2026-11-30):** This file preserves the original v1.2.0 +> release notes. The licensing, provenance, source-availability, and +> license-check work added after that release is recorded in the addendum in +> section 6. For the current source offer, see [`SOURCE-OFFER.md`](SOURCE-OFFER.md). + ## 1. Overview S.A.N.E Linux v1.2.0 is a major milestone release delivering production-grade init lifecycle control, fail-closed privilege drop semantics, a full POSIX-compliant package manager (`spm`) with atomic transactions and hardened archive validation, guest offline installer support for BIOS and UEFI GPT systems, immutable upstream kernel toolchain pinning, and root-owned deterministic initramfs generation. diff --git a/licenses/README.md b/licenses/README.md index b35a1e1..ba148fd 100644 --- a/licenses/README.md +++ b/licenses/README.md @@ -30,6 +30,9 @@ For the GPL-2.0-only binaries shipped in S.A.N.E Linux images, see `license-check` GitHub Actions workflow. Each entry names a binary path or glob, its license, and its source reference. First-party packages are marked with `first_party: true` so they are not mistaken for third-party GPL payloads. -Optional `sha256` fields pin critical binaries (BusyBox, kernel, dosfstools). -When adding a new binary, update this file and `THIRD_PARTY_LICENSES.md` in the -same PR, and publish its source asset if it is third-party. +Optional `sha256` fields pin critical binaries (BusyBox, kernel, dosfstools); +when present they are checked for every matched regular file. Applet symlinks +are skipped because they are aliases, not independent payloads; a new regular +ELF still fails unless it is registered here. When adding a new binary, update +this file and `THIRD_PARTY_LICENSES.md` in the same PR, and publish its source +asset if it is third-party. From 62dd2ba09e2e9798db2ea9a9767328019a1d50cb Mon Sep 17 00:00:00 2001 From: Rzy <168882072+Iky969@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:03:29 +0000 Subject: [PATCH 4/6] fix(license-check): make glob matching explicit and validate config --- .github/workflows/license-check.yml | 2 +- licenses/README.md | 1 + licenses/allowlist.json | 9 +-- scripts/check-license-artifacts.py | 117 ++++++++++++++++++++++++---- 4 files changed, 105 insertions(+), 24 deletions(-) diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml index b35583b..4125814 100644 --- a/.github/workflows/license-check.yml +++ b/.github/workflows/license-check.yml @@ -2,7 +2,7 @@ name: license-check on: push: - branches: [main, master] + branches: [main] pull_request: workflow_dispatch: diff --git a/licenses/README.md b/licenses/README.md index ba148fd..a3787e3 100644 --- a/licenses/README.md +++ b/licenses/README.md @@ -30,6 +30,7 @@ For the GPL-2.0-only binaries shipped in S.A.N.E Linux images, see `license-check` GitHub Actions workflow. Each entry names a binary path or glob, its license, and its source reference. First-party packages are marked with `first_party: true` so they are not mistaken for third-party GPL payloads. +`*` and `?` in globs do not cross `/`; use `**` for recursive matching. Optional `sha256` fields pin critical binaries (BusyBox, kernel, dosfstools); when present they are checked for every matched regular file. Applet symlinks are skipped because they are aliases, not independent payloads; a new regular diff --git a/licenses/allowlist.json b/licenses/allowlist.json index 3f19ad3..b2359cc 100644 --- a/licenses/allowlist.json +++ b/licenses/allowlist.json @@ -31,7 +31,7 @@ "sha256": "be523954ad673a78c9cdfd3d473a8d39609f5901adfcc68402c67dc037a64c7e" }, { - "path": "packages/kernel/x/lib/modules/*.ko", + "path": "packages/kernel/x/lib/modules/**/*.ko", "match": "glob", "component": "Linux kernel modules 6.6.134", "license": "GPL-2.0-only", @@ -44,13 +44,6 @@ "source_ref": "dosfstools-ubuntu-4.2-1.2build1-source.tar.gz in v1.2.1-source", "sha256": "3bded05c428857023571416308f0ecf0fce2f9d44f0e5b7ec3b371c1350f45a4" }, - { - "path": "packages/disk-tools/x/usr/sbin/mkfs.vfat", - "component": "dosfstools", - "license": "GPL-3.0-only", - "source_ref": "dosfstools-ubuntu-4.2-1.2build1-source.tar.gz in v1.2.1-source", - "sha256": "3bded05c428857023571416308f0ecf0fce2f9d44f0e5b7ec3b371c1350f45a4" - }, { "path": "packages/disk-tools/x/usr/sbin/sgdisk", "component": "gptfdisk", diff --git a/scripts/check-license-artifacts.py b/scripts/check-license-artifacts.py index e5eb6cb..7523897 100644 --- a/scripts/check-license-artifacts.py +++ b/scripts/check-license-artifacts.py @@ -7,7 +7,8 @@ "sha256": "optional", "match": "exact|glob"} - `match: exact` compares the repo-relative path exactly. -- `match: glob` uses fnmatch, e.g. packages/kernel/x/lib/modules/*.ko. +- `match: glob` uses POSIX-like globbing: `*` and `?` do not cross `/`; + `**` matches any number of path segments, including none. - `sha256` is optional; when present every matched ELF file is checked, and exact pinned entries are also checked when the payload is not ELF (vmlinuz). - Symlinks are skipped because applet symlinks are not independent payloads; @@ -17,9 +18,10 @@ from __future__ import annotations import argparse -import fnmatch import hashlib import json +import re +import sys from pathlib import Path @@ -46,10 +48,70 @@ def iter_elf_files(root: Path): yield p, None -def matches(path: str, entry: dict) -> bool: +def glob_to_regex(pattern: str) -> re.Pattern[str]: + """Translate the allowlist glob dialect into an anchored regex.""" + out = ["^"] + i = 0 + while i < len(pattern): + char = pattern[i] + if char == "*": + if i + 1 < len(pattern) and pattern[i + 1] == "*": + i += 2 + if i < len(pattern) and pattern[i] == "/": + out.append("(?:.*/)?") + i += 1 + else: + out.append(".*") + else: + out.append("[^/]*") + i += 1 + elif char == "?": + out.append("[^/]") + i += 1 + else: + out.append(re.escape(char)) + i += 1 + out.append("$") + return re.compile("".join(out)) + + +def matches(path: str, entry: dict, cache: dict[str, re.Pattern[str]]) -> bool: + pattern = entry["path"] if entry.get("match", "exact") == "glob": - return fnmatch.fnmatch(path, entry["path"]) - return path == entry["path"] + regex = cache.get(pattern) + if regex is None: + regex = glob_to_regex(pattern) + cache[pattern] = regex + return bool(regex.match(path)) + return path == pattern + + +def load_allowlist(path: Path) -> list[dict]: + try: + data = json.loads(path.read_text()) + except OSError as exc: + print(f"FAIL: cannot read allowlist {path}: {exc}", file=sys.stderr) + raise SystemExit(1) + except json.JSONDecodeError as exc: + print(f"FAIL: invalid JSON in allowlist {path}: {exc}", file=sys.stderr) + raise SystemExit(1) + + if not isinstance(data, list): + print(f"FAIL: allowlist {path} must contain a JSON list", file=sys.stderr) + raise SystemExit(1) + + for index, entry in enumerate(data): + if not isinstance(entry, dict) or not isinstance(entry.get("path"), str): + print(f"FAIL: allowlist entry {index} is missing a string path", file=sys.stderr) + raise SystemExit(1) + if entry.get("match", "exact") not in ("exact", "glob"): + print(f"FAIL: allowlist entry {index} has an invalid match mode", file=sys.stderr) + raise SystemExit(1) + digest = entry.get("sha256") + if digest is not None and not re.fullmatch(r"[0-9a-f]{64}", digest): + print(f"FAIL: allowlist entry {index} has an invalid sha256", file=sys.stderr) + raise SystemExit(1) + return data def main() -> int: @@ -57,15 +119,25 @@ def main() -> int: ap.add_argument("--root", action="append", required=True, help="Directory to scan; may be repeated.") ap.add_argument("--allowlist", default="licenses/allowlist.json") + ap.add_argument("--repo-root", default=".", + help="Base for relative paths; defaults to the current directory.") args = ap.parse_args() - entries = json.loads(Path(args.allowlist).read_text()) - base = Path(args.allowlist).resolve().parent.parent - failures = [] + base = Path(args.repo_root).resolve() + allowlist_path = Path(args.allowlist) + if not allowlist_path.is_absolute(): + allowlist_path = base / allowlist_path + entries = load_allowlist(allowlist_path) + + cache: dict[str, re.Pattern[str]] = {} + failures: list[tuple[str, str]] = [] checked = 0 + scanned: set[str] = set() for root_arg in args.root: root = Path(root_arg) + if not root.is_absolute(): + root = base / root if not root.exists(): failures.append((root_arg, "scan root does not exist")) continue @@ -77,14 +149,21 @@ def main() -> int: if error: failures.append((rel, error)) continue + scanned.add(rel) checked += 1 - entry = next((e for e in entries if matches(rel, e)), None) - if entry is None: + matching = [entry for entry in entries if matches(rel, entry, cache)] + if not matching: failures.append((rel, "not registered in licenses/allowlist.json")) continue - expected = entry.get("sha256") - if expected: - actual = sha256_of(elf) + for entry in matching: + expected = entry.get("sha256") + if not expected: + continue + try: + actual = sha256_of(elf) + except OSError as exc: + failures.append((rel, f"cannot hash: {exc}")) + continue if actual != expected: failures.append( (rel, @@ -98,11 +177,20 @@ def main() -> int: if not expected or entry.get("match", "exact") == "glob": continue rel = entry["path"] + if rel in scanned: + continue path = base / rel if not path.exists(): failures.append((rel, "expected binary is missing")) continue - actual = sha256_of(path) + if path.is_symlink(): + failures.append((rel, "pinned artifact must be a regular file")) + continue + try: + actual = sha256_of(path) + except OSError as exc: + failures.append((rel, f"cannot hash: {exc}")) + continue if actual != expected: failures.append( (rel, @@ -110,7 +198,6 @@ def main() -> int: "Update the allowlist and its source asset in the same PR.")) if failures: - failures = list(dict.fromkeys(failures)) print(f"FAIL: {len(failures)} unlicensed or mismatched artifact(s)") for rel, why in failures: print(f" - {rel}: {why}") From 22de72c5543d9fff1e7ae30b0de5fcf82dde102f Mon Sep 17 00:00:00 2001 From: Rzy <168882072+Iky969@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:13:06 +0000 Subject: [PATCH 5/6] fix(license-check): tighten first-party allowlist entries --- licenses/allowlist.json | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/licenses/allowlist.json b/licenses/allowlist.json index b2359cc..0b4252e 100644 --- a/licenses/allowlist.json +++ b/licenses/allowlist.json @@ -1,20 +1,11 @@ [ { - "path": "packages/ninit/x/**", - "match": "glob", - "component": "ninit and its companion utilities", + "path": "packages/ninit/x/sbin/init", + "component": "ninit", "license": "MIT", "source_ref": "ninit.c and scripts/ in this repository", "first_party": true }, - { - "path": "packages/spm/x/**", - "match": "glob", - "component": "S.A.N.E Package Manager (spm)", - "license": "MIT", - "source_ref": "scripts/spm in this repository", - "first_party": true - }, { "path": "packages/busybox/x/**", "match": "glob", @@ -56,18 +47,6 @@ "license": "GPL-2.0-only", "source_ref": "https://e2fsprogs.sourceforge.net/" }, - { - "path": "packages/disk-tools/x/usr/sbin/mkfs.ext2", - "component": "e2fsprogs", - "license": "GPL-2.0-only", - "source_ref": "https://e2fsprogs.sourceforge.net/" - }, - { - "path": "packages/disk-tools/x/usr/sbin/mkfs.ext4", - "component": "e2fsprogs", - "license": "GPL-2.0-only", - "source_ref": "https://e2fsprogs.sourceforge.net/" - }, { "path": "packages/curl/x/usr/bin/curl", "component": "curl", From 2efd3d8142f46bb6d7ca956975e23fa87a258d12 Mon Sep 17 00:00:00 2001 From: Rzy <168882072+Iky969@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:27:18 +0000 Subject: [PATCH 6/6] fix(license-check): fail on scan errors and validate metadata --- licenses/README.md | 1 + scripts/check-license-artifacts.py | 45 ++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/licenses/README.md b/licenses/README.md index a3787e3..96e099e 100644 --- a/licenses/README.md +++ b/licenses/README.md @@ -31,6 +31,7 @@ For the GPL-2.0-only binaries shipped in S.A.N.E Linux images, see glob, its license, and its source reference. First-party packages are marked with `first_party: true` so they are not mistaken for third-party GPL payloads. `*` and `?` in globs do not cross `/`; use `**` for recursive matching. +Unreadable files or directories fail the gate rather than being skipped. Optional `sha256` fields pin critical binaries (BusyBox, kernel, dosfstools); when present they are checked for every matched regular file. Applet symlinks are skipped because they are aliases, not independent payloads; a new regular diff --git a/scripts/check-license-artifacts.py b/scripts/check-license-artifacts.py index 7523897..9b916f2 100644 --- a/scripts/check-license-artifacts.py +++ b/scripts/check-license-artifacts.py @@ -20,6 +20,7 @@ import argparse import hashlib import json +import os import re import sys from pathlib import Path @@ -33,19 +34,24 @@ def sha256_of(path: Path) -> str: return h.hexdigest() -def iter_elf_files(root: Path): - """Yield (path, error). Unreadable candidates are reported, not skipped.""" - for p in sorted(root.rglob("*")): - if p.is_symlink() or not p.is_file(): - continue - try: - with p.open("rb") as f: - magic = f.read(4) - except OSError as exc: - yield p, f"cannot read: {exc}" - continue - if magic == b"\x7fELF": - yield p, None +def iter_elf_files(root: Path, on_error=None): + """Yield (path, error). Unreadable candidates and directories are reported.""" + for dirpath, dirnames, filenames in os.walk(root, onerror=on_error, + followlinks=False): + dirnames.sort() + filenames.sort() + for name in filenames: + p = Path(dirpath) / name + if p.is_symlink() or not p.is_file(): + continue + try: + with p.open("rb") as f: + magic = f.read(4) + except OSError as exc: + yield p, f"cannot read: {exc}" + continue + if magic == b"\x7fELF": + yield p, None def glob_to_regex(pattern: str) -> re.Pattern[str]: @@ -104,6 +110,12 @@ def load_allowlist(path: Path) -> list[dict]: if not isinstance(entry, dict) or not isinstance(entry.get("path"), str): print(f"FAIL: allowlist entry {index} is missing a string path", file=sys.stderr) raise SystemExit(1) + for field in ("license", "source_ref"): + value = entry.get(field) + if not isinstance(value, str) or not value.strip(): + print(f"FAIL: allowlist entry {index} is missing a non-empty {field}", + file=sys.stderr) + raise SystemExit(1) if entry.get("match", "exact") not in ("exact", "glob"): print(f"FAIL: allowlist entry {index} has an invalid match mode", file=sys.stderr) raise SystemExit(1) @@ -134,6 +146,11 @@ def main() -> int: checked = 0 scanned: set[str] = set() + def on_scan_error(exc: OSError) -> None: + filename = getattr(exc, "filename", None) + failures.append((str(filename) if filename else "scan root", + f"cannot scan: {exc}")) + for root_arg in args.root: root = Path(root_arg) if not root.is_absolute(): @@ -141,7 +158,7 @@ def main() -> int: if not root.exists(): failures.append((root_arg, "scan root does not exist")) continue - for elf, error in iter_elf_files(root): + for elf, error in iter_elf_files(root, on_scan_error): try: rel = elf.relative_to(base).as_posix() except ValueError: