Skip to content

Commit 22de979

Browse files
committed
fix(ci): pin the canonical Apache-2.0 text by digest instead of fetching it
audit-license-provenance.py ran `curl https://www.apache.org/licenses/LICENSE-2.0.txt` every time the gate executed and byte-compared the result against vendored/nomic/LICENSE, with capture_output and no error check. Any fetch failure therefore produced an empty string, compared unequal, and reported: vendored/nomic: DIFFERS [apache.org canonical LICENSE-2.0.txt] PROVENANCE AUDIT FAILED: 1 unexplained verdict(s) which is indistinguishable from a real licence discrepancy. A gating verdict must be a pure function of the tree, not of whether a web server answered. This one was neither reproducible nor attributable: it reddened `security / license-gate` on PR DeusData#1337 - a branch touching cli.h, hook_augment.c and test_cli.c, and no licence at all - and left that contributor blocked for over two weeks on a signal that had nothing to do with their change. Verified before pinning: our vendored copy is byte-identical to the upstream canonical text, 11358 bytes on both sides, diff clean. The Apache-2.0 text is immutable and versioned, so a digest is the honest way to express "this is that text". A mismatch now means our vendored copy changed, which is exactly - and only - what this audit exists to detect. The audit passes locally with no network access on the nomic entry. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent c360440 commit 22de979

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

‎scripts/audit-license-provenance.py‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
ERROR upstream fetch failed
1111
"""
1212
import base64
13+
import hashlib
1314
import json
1415
import os
1516
import re
@@ -159,13 +160,24 @@ def check_upstream(key, dirpath, repo, pinned=None, exact_path=None):
159160
check_upstream(rel, os.path.join(ROOT, rel), repo, exact_path=exact)
160161

161162
# Special: nomic = canonical Apache-2.0 text; sqlite3 = first-party notice
163+
#
164+
# This used to `curl` https://www.apache.org/licenses/LICENSE-2.0.txt at
165+
# gate time and byte-compare. A gating verdict must not depend on a live
166+
# HTTP request: any fetch failure yielded an empty string, compared unequal,
167+
# and reported DIFFERS -- indistinguishable from a real licence change. That
168+
# is what reddened `security / license-gate` on PR #1337 for over two weeks,
169+
# on a branch touching three CLI files and no licence at all.
170+
#
171+
# The canonical Apache-2.0 text is immutable and versioned, so it is pinned
172+
# by digest instead. Verified byte-identical to the upstream text at the time
173+
# of pinning (11358 bytes). A mismatch now means our vendored copy changed --
174+
# which is exactly, and only, what this audit is meant to detect.
175+
APACHE_2_0_SHA256 = "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30"
162176
fname, ours = local_license(os.path.join(ROOT, "vendored/nomic"))
163-
apache = subprocess.run(
164-
["curl", "-fsSL", "https://www.apache.org/licenses/LICENSE-2.0.txt"],
165-
capture_output=True, text=True).stdout
177+
ours_digest = hashlib.sha256(ours.encode("utf-8")).hexdigest() if ours is not None else None
166178
results["vendored/nomic"] = (
167-
"IDENTICAL" if ours == apache else "DIFFERS",
168-
"apache.org canonical LICENSE-2.0.txt")
179+
"IDENTICAL" if ours_digest == APACHE_2_0_SHA256 else "DIFFERS",
180+
"canonical Apache-2.0 text, pinned by sha256")
169181
results["vendored/sqlite3"] = ("FIRST-PARTY-NOTICE",
170182
"own public-domain notice (sqlite has no upstream LICENSE)")
171183

0 commit comments

Comments
 (0)