Skip to content

Commit 9d85701

Browse files
committed
chore(ui): drop sharp and its LGPL libvips; the license gate allows no exception
The v0.12.0 release run's license gate blocked @img/sharp-wasm32@0.35.5 (Apache-2.0 AND LGPL-3.0-or-later AND MIT). sharp sat in graph-ui's tree only because @huggingface/transformers lists it for its Node image path. CBM Lens runs Transformers in the browser (a tokenizer and a causal LM on WebGPU), never processes images, and the Transformers web build already replaces sharp with an empty object. Yet sharp installed 14 LGPL packages (10 @img/sharp-libvips-*, 3 @img/sharp-win32-*, @img/sharp-wasm32), and the gate let them through two ways: - a reviewed exception for exactly @img/sharp-wasm32@0.35.0 ("installed but not shipped"), which the 0.35.5 bump in DeusData#2632 tripped; - collect() skipped every os/cpu-restricted package as "build tooling", which hid all ten LGPL libvips binaries. A non-permissive license has no place in the tree, shipped or not: - sharp now resolves to graph-ui/stubs/sharp, our own MIT stand-in that throws if anything ever calls it (direct dependency file:./stubs/sharp plus override "sharp": "$sharp"). The whole sharp family leaves the lockfile: 441 -> 411 packages, zero LGPL/GPL left (audited). - ui_browser_licenses.py loses the exception and keeps only the browser build evidence check; license-gate-check-npm.py validates that evidence unconditionally, checks platform-restricted packages like any other, and has no exclusion path; gen-ui-licenses.py drops the exception section. - tests: the exception tests become guards: an unshipped LGPL package blocks, a platform-restricted LGPL package blocks, a platform-restricted MIT package passes. Against the old scripts both LGPL guards fail. The shipped browser bundle is unchanged: rebuilt, it differs from main's only by the build's own -dirty version marker. License gate stage 3 on this tree: 211 production packages, all allow-listed. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 4942472 commit 9d85701

9 files changed

Lines changed: 105 additions & 704 deletions

File tree

‎graph-ui/package-lock.json‎

Lines changed: 7 additions & 633 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎graph-ui/package.json‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@
6666
"vitest": "4.1.11"
6767
},
6868
"overrides": {
69-
"@huggingface/transformers": {
70-
"sharp": "0.35.5"
71-
},
69+
"sharp": "$sharp",
7270
"monaco-editor": {
7371
"dompurify": "3.4.16"
7472
},
@@ -87,6 +85,7 @@
8785
"react-dom": "19.2.8",
8886
"react-markdown": "10.1.0",
8987
"remark-gfm": "4.0.1",
88+
"sharp": "file:./stubs/sharp",
9089
"three": "0.183.2",
9190
"yaml": "2.8.3"
9291
}

‎graph-ui/stubs/sharp/LICENSE‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2025 DeusData
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

‎graph-ui/stubs/sharp/index.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
// Stand-in for sharp (see package.json). Only the Node image path of
3+
// @huggingface/transformers would call it; CBM Lens runs Transformers in the
4+
// browser and never processes images, so a call here is a bug, not a fallback.
5+
module.exports = function sharp() {
6+
throw new Error('sharp is not part of CBM Lens: image processing is unsupported');
7+
};

‎graph-ui/stubs/sharp/package.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "sharp",
3+
"version": "0.0.0-cbm-stub",
4+
"description": "Empty stand-in for sharp. CBM Lens never processes images, and the Transformers browser build already replaces sharp with an empty object; this keeps sharp and its LGPL libvips binaries out of the dependency tree.",
5+
"license": "MIT",
6+
"private": true,
7+
"main": "index.js"
8+
}

‎scripts/gen-ui-licenses.py‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import os
1717
import subprocess
1818
import sys
19-
from ui_browser_licenses import verified_browser_exclusions
2019

2120

2221
def collect(ui_dir, dep_tree, out, excluded):
@@ -78,20 +77,13 @@ def main():
7877
pkgs = set()
7978
excluded = set()
8079
collect(ui_dir, tree.get("dependencies"), pkgs, excluded)
81-
try:
82-
browser_excluded = verified_browser_exclusions(ui_dir, pkgs)
83-
except ValueError as exc:
84-
print(f"Cannot generate UI notices: {exc}", file=sys.stderr)
85-
sys.exit(1)
86-
pkgs -= browser_excluded
8780

8881
print("## External Graph UI asset pack — bundled npm packages")
8982
print()
9083
print("The `-ui` archives ship a compiled frontend asset pack beside the binary.")
9184
print("The packages below are its production dependency tree; license texts are")
9285
print("reproduced verbatim from the packages as installed at build time.")
93-
print("The build inventory excludes only the reviewed optional package listed below;")
94-
print("other production dependencies remain covered conservatively.")
86+
print("The whole production dependency tree is covered conservatively.")
9587
print()
9688

9789
for name, version in sorted(pkgs):
@@ -117,14 +109,6 @@ def main():
117109
print(f"- {name}@{version}")
118110
print()
119111

120-
if browser_excluded:
121-
print("### Installed optional package absent from the browser pack")
122-
print()
123-
print("Verified against the current application and worker build inputs and asset hashes.")
124-
for name, version in sorted(browser_excluded):
125-
print(f"- {name}@{version}: Transformers uses its reviewed empty browser stub.")
126-
print()
127-
128112

129113
if __name__ == "__main__":
130114
main()

‎scripts/license-gate-check-npm.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
44
Usage: license-gate-check-npm.py <graph-ui-dir> <license-policy.json>
55
6-
Conservatively walks the production tree (including prebundled dependencies;
7-
exclusions are shared with gen-ui-licenses.py) and fails if ANY package's license is not
8-
on the policy allow-list. Packages with no declared license fall back to
9-
the first line of their shipped license file; if that cannot be resolved
10-
either, the gate fails — unknown is not allowed.
6+
Walks the WHOLE production tree (including prebundled dependencies and
7+
platform-restricted native packages) and fails if ANY package's license is not
8+
on the policy allow-list. There are no exceptions: a package that is installed
9+
but never bundled still blocks, because "unshipped" is a claim about a build,
10+
and a non-permissive license must never be one build change away from shipping.
11+
Packages with no declared license fall back to the first line of their shipped
12+
license file; if that cannot be resolved either, the gate fails — unknown is
13+
not allowed. The current app + worker build evidence must also verify.
1114
"""
1215
import json
1316
import os
1417
import re
1518
import subprocess
1619
import sys
17-
from ui_browser_licenses import verified_browser_exclusions
20+
from ui_browser_licenses import validate_browser_build
1821

1922
FILE_HEADER_MAP = {
2023
"mit license": "MIT",
@@ -52,8 +55,8 @@ def collect(ui_dir, dep_tree, out):
5255
meta = json.load(fh)
5356
except (OSError, ValueError):
5457
continue
55-
if meta.get("os") or meta.get("cpu"):
56-
continue # platform-restricted native build tooling, not bundled
58+
# Platform-restricted packages (os/cpu) are checked like any other:
59+
# skipping them is how sharp's LGPL libvips binaries passed unseen.
5760
lic = meta.get("license", "")
5861
if isinstance(lic, dict):
5962
lic = lic.get("type", "")
@@ -82,16 +85,13 @@ def main():
8285
sys.exit(1)
8386

8487
try:
85-
browser_excluded = verified_browser_exclusions(ui_dir, pkgs)
88+
validate_browser_build(ui_dir)
8689
except ValueError as exc:
87-
print(f"BLOCKED: cannot verify browser-only package exclusion: {exc}")
90+
print(f"BLOCKED: browser build evidence does not verify: {exc}")
8891
sys.exit(1)
8992

9093
violations = []
9194
for (name, version), (lic, pkg_dir) in sorted(pkgs.items()):
92-
if (name, version) in browser_excluded:
93-
print(f"Not shipped (verified app + worker build): {name}@{version}")
94-
continue
9595
if name in ignored_pkgs:
9696
continue
9797
if not lic:
@@ -111,7 +111,7 @@ def main():
111111
for pkg, lic in violations[:25]:
112112
print(f" {pkg}: {lic}")
113113
sys.exit(1)
114-
print(f"OK: {len(pkgs) - len(browser_excluded)} npm packages covered, all allow-listed")
114+
print(f"OK: {len(pkgs)} npm packages covered, all allow-listed")
115115

116116

117117
if __name__ == "__main__":

‎scripts/ui_browser_licenses.py‎

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
"""One build-backed exception for an installed, unshipped optional package.
1+
"""Build evidence for the UI browser pack: what ships is exactly the bundler output.
22
3-
Keep the production dependency inventory conservative. Only the reviewed
4-
Transformers browser build may omit this exact native image-processing package;
5-
missing evidence, upgrades, new payloads, or stale builds fail closed.
3+
There are NO license exceptions. Every package in the production dependency
4+
tree must carry an allow-listed license whether or not it reaches the bundle
5+
(license-gate-check-npm.py); this module only proves the bundle itself: every
6+
asset is inventoried bundler output, and neither sharp nor Node inference code
7+
is in the app or worker graph. Missing evidence, new payloads or stale builds
8+
fail closed.
69
"""
710
import hashlib
811
import json
@@ -11,7 +14,6 @@
1114
import sys
1215

1316

14-
OPTIONAL_PACKAGE = ("@img/sharp-wasm32", "0.35.0")
1517
BROWSER_ENTRY = "node_modules/@huggingface/transformers/dist/transformers.web.js"
1618
# Transformers 4.2.0's published browser distribution contains the upstream
1719
# empty `ignore-modules:sharp` stub. Updating it requires a new source review.
@@ -30,21 +32,8 @@ def checked_path(root, name):
3032
return root.joinpath(*path.parts)
3133

3234

33-
def verified_browser_exclusions(ui_dir, packages):
34-
if OPTIONAL_PACKAGE not in packages:
35-
return set()
36-
try:
37-
meta = json.loads((Path(ui_dir) / "node_modules/@img/sharp-wasm32/package.json").read_text())
38-
if (meta["name"], meta["version"]) != OPTIONAL_PACKAGE:
39-
raise ValueError("optional package identity changed")
40-
except (OSError, KeyError, TypeError, json.JSONDecodeError) as exc:
41-
raise ValueError("optional package identity is unavailable") from exc
42-
validate_browser_build(ui_dir)
43-
return {OPTIONAL_PACKAGE}
44-
45-
4635
def validate_browser_build(ui_dir):
47-
"""Also check build evidence on hosts where the optional package is absent."""
36+
"""Raise ValueError unless the current app + worker build evidence holds."""
4837
root = Path(ui_dir)
4938
try:
5039
proof = json.loads((root / ".vite/license-build.json").read_text())

‎tests/test_ui_license_inventory.py‎

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ def setUp(self):
2222
self.addCleanup(self.tmp.cleanup)
2323
self.ui = Path(self.tmp.name) / "graph-ui"
2424
self.ui.mkdir()
25-
self.package("@img/sharp-wasm32", "0.35.0",
26-
"Apache-2.0 AND LGPL-3.0-or-later AND MIT")
2725
self.package("@huggingface/transformers", "4.2.0", "Apache-2.0")
2826
source = ROOT / "graph-ui/node_modules/@huggingface/transformers/dist/transformers.web.js"
2927
if not source.is_file():
@@ -62,8 +60,7 @@ def setUp(self):
6260
}
6361
self.write_proof()
6462
self.tree = {"dependencies": {
65-
"@huggingface/transformers": {"version": "4.2.0", "dependencies": {
66-
"@img/sharp-wasm32": {"version": "0.35.0"}}}}}
63+
"@huggingface/transformers": {"version": "4.2.0", "dependencies": {}}}}
6764
self.bin = Path(self.tmp.name) / "bin"
6865
self.bin.mkdir()
6966
shim = self.bin / "npm.py"
@@ -72,13 +69,18 @@ def setUp(self):
7269
(self.bin / "npm").chmod(0o755)
7370
(self.bin / "npm.cmd").write_text('@python "%~dp0npm.py"\r\n')
7471

75-
def package(self, name, version, license_id):
72+
def package(self, name, version, license_id, **platform):
7673
folder = self.ui / "node_modules" / name
7774
folder.mkdir(parents=True)
7875
(folder / "package.json").write_text(json.dumps({
79-
"name": name, "version": version, "license": license_id}))
76+
"name": name, "version": version, "license": license_id, **platform}))
8077
(folder / "LICENSE").write_text(license_id)
8178

79+
def add_transformers_dependency(self, name, version, license_id, **platform):
80+
self.package(name, version, license_id, **platform)
81+
deps = self.tree["dependencies"]["@huggingface/transformers"]["dependencies"]
82+
deps[name] = {"version": version}
83+
8284
def write_proof(self):
8385
path = self.ui / ".vite/license-build.json"
8486
path.parent.mkdir(exist_ok=True)
@@ -96,17 +98,41 @@ def assert_blocked(self):
9698
result = self.run_script("license-gate-check-npm.py")
9799
self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)
98100

99-
def test_verified_absent_package_does_not_block_browser_release(self):
101+
def test_permissive_tree_with_verified_build_passes(self):
100102
result = self.run_script("license-gate-check-npm.py")
101103
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
102-
self.assertIn("@img/sharp-wasm32@0.35.0", result.stdout)
104+
self.assertIn("all allow-listed", result.stdout)
103105

104-
def test_notices_use_the_same_shipped_package_decision(self):
106+
def test_notices_cover_the_production_tree(self):
105107
result = self.run_script("gen-ui-licenses.py")
106108
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
107-
self.assertNotIn("### @img/sharp-wasm32@", result.stdout)
108109
self.assertIn("### @huggingface/transformers@4.2.0", result.stdout)
109110

111+
def test_lgpl_package_blocks_even_when_unshipped(self):
112+
# No exception for "installed but not bundled": sharp's wasm build
113+
# (LGPL libvips inside) once passed that way. It must block now.
114+
self.add_transformers_dependency("@img/sharp-wasm32", "0.35.0",
115+
"Apache-2.0 AND LGPL-3.0-or-later AND MIT")
116+
result = self.run_script("license-gate-check-npm.py")
117+
self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)
118+
self.assertIn("@img/sharp-wasm32@0.35.0", result.stdout)
119+
120+
def test_platform_restricted_lgpl_package_blocks(self):
121+
# os/cpu-restricted native packages used to be skipped as build
122+
# tooling; that skip let all ten @img/sharp-libvips-* (LGPL) through.
123+
self.add_transformers_dependency("@img/sharp-libvips-darwin-arm64", "1.3.4",
124+
"LGPL-3.0-or-later", os=["darwin"], cpu=["arm64"])
125+
result = self.run_script("license-gate-check-npm.py")
126+
self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)
127+
self.assertIn("@img/sharp-libvips-darwin-arm64@1.3.4", result.stdout)
128+
129+
def test_platform_restricted_permissive_package_passes(self):
130+
# Checking platform packages must not turn into blocking them.
131+
self.add_transformers_dependency("@example/native-darwin-arm64", "1.0.0", "MIT",
132+
os=["darwin"], cpu=["arm64"])
133+
result = self.run_script("license-gate-check-npm.py")
134+
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
135+
110136
def test_missing_proof_blocks(self):
111137
(self.ui / ".vite/license-build.json").unlink()
112138
self.assert_blocked()
@@ -234,14 +260,6 @@ def test_unrelated_disallowed_dependency_still_blocks(self):
234260
self.tree["dependencies"]["unrelated"] = {"version": "1.0.0"}
235261
self.assert_blocked()
236262

237-
def test_new_package_version_requires_review(self):
238-
package = self.ui / "node_modules/@img/sharp-wasm32/package.json"
239-
meta = json.loads(package.read_text())
240-
meta["version"] = "0.36.0"
241-
package.write_text(json.dumps(meta))
242-
self.tree["dependencies"]["@huggingface/transformers"]["dependencies"]["@img/sharp-wasm32"]["version"] = "0.36.0"
243-
self.assert_blocked()
244-
245263

246264
if __name__ == "__main__":
247265
unittest.main()

0 commit comments

Comments
 (0)