跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

macos-sshfs-sources.test.mjs

61 行 · 3.9 KB历史下载
1import test from 'node:test';
2import assert from 'node:assert/strict';
3import { execFileSync } from 'node:child_process';
4import { mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
5import { tmpdir } from 'node:os';
6import { join } from 'node:path';
7import { extractLicenses, finish, inspectDependency, verifyArchive } from './guest-os/collect-macos-sshfs-sources.mjs';
8
9test('macOS guest source is bound to the final signed binary and release version', t => {
10 const root = mkdtempSync(join(tmpdir(), 'cage-sshfs-source-test-'));
11 t.after(() => rmSync(root, { recursive: true, force: true }));
12 const source = join(root, 'source');
13 mkdirSync(join(source, 'licenses'), { recursive: true });
14 writeFileSync(join(source, 'build.json'), JSON.stringify({ cageVersion: '0.1.7-rc.1' }));
15 writeFileSync(join(source, 'NOTICE'), 'copyright and license notices');
16 writeFileSync(join(source, 'licenses/LICENSE'), 'upstream license');
17 writeFileSync(join(source, 'dependency.a'), 'the actual linked static library');
18 const binary = join(root, 'cage-sshfs');
19 writeFileSync(binary, 'final Developer ID signed executable');
20 const archive = join(root, 'source.tar.gz');
21 finish(source, binary, archive, join(root, 'app-licenses'));
22 assert.equal(readFileSync(join(root, 'app-licenses/LICENSE'), 'utf8'), 'upstream license');
23 assert.doesNotThrow(() => verifyArchive(archive, binary, '0.1.7-rc.1'));
24 assert.throws(() => verifyArchive(archive, binary, '0.1.7-rc.2'), /does not match/);
25 writeFileSync(binary, 'earlier ad-hoc signed executable');
26 assert.throws(() => verifyArchive(archive, binary, '0.1.7-rc.1'), /does not match/);
27 writeFileSync(binary, 'final Developer ID signed executable');
28 writeFileSync(join(source, 'dependency.a'), 'different static library');
29 execFileSync('tar', ['-czf', archive, '-C', source, '.']);
30 assert.throws(() => verifyArchive(archive, binary, '0.1.7-rc.1'), /integrity check failed: dependency.a/);
31});
32
33test('same-version Homebrew formula changes cannot silently substitute another build', t => {
34 const root = mkdtempSync(join(tmpdir(), 'cage-sshfs-formula-test-'));
35 t.after(() => rmSync(root, { recursive: true, force: true }));
36 mkdirSync(join(root, '.brew'));
37 writeFileSync(join(root, 'INSTALL_RECEIPT.json'), JSON.stringify({ source: { spec: 'stable', versions: { stable: '2.90.1' } } }));
38 writeFileSync(join(root, '.brew/glib.rb'), 'same version, unreviewed upstream patch');
39 assert.throws(() => inspectDependency('glib', root), /installed formula\/version differs/);
40});
41
42test('upstream license symlinks and PCRE2 LICENCE.md are distributed as readable texts', t => {
43 const root = mkdtempSync(join(tmpdir(), 'cage-sshfs-license-test-'));
44 t.after(() => rmSync(root, { recursive: true, force: true }));
45 const upstream = join(root, 'upstream');
46 mkdirSync(join(upstream, 'glib/LICENSES'), { recursive: true });
47 writeFileSync(join(upstream, 'glib/LICENSES/LGPL-2.1-or-later.txt'), 'full LGPL text');
48 symlinkSync('LICENSES/LGPL-2.1-or-later.txt', join(upstream, 'glib/COPYING'));
49 mkdirSync(join(upstream, 'pcre2/deps/sljit'), { recursive: true });
50 writeFileSync(join(upstream, 'pcre2/COPYING'), 'See LICENCE.md');
51 writeFileSync(join(upstream, 'pcre2/LICENCE.md'), 'BSD-3-Clause WITH PCRE2-exception');
52 writeFileSync(join(upstream, 'pcre2/deps/sljit/LICENSE'), 'SLJIT license');
53 for (const component of ['glib', 'pcre2']) {
54 const archive = join(root, `${component}.tar.gz`);
55 execFileSync('tar', ['-czf', archive, '-C', upstream, component]);
56 extractLicenses(archive, join(root, 'licenses', component), component);
57 }
58 assert.equal(readFileSync(join(root, 'licenses/glib/COPYING'), 'utf8'), 'full LGPL text');
59 assert.equal(readFileSync(join(root, 'licenses/pcre2/LICENCE.md'), 'utf8'), 'BSD-3-Clause WITH PCRE2-exception');
60 assert.equal(readFileSync(join(root, 'licenses/pcre2/deps/sljit/LICENSE'), 'utf8'), 'SLJIT license');
61});