提交记录修改.github/workflows/macos-build.yml+1 −1看文件
修改scripts/verify-macos-release.sh+10 −3看文件
修改www/scripts/sync-release.test.mjs+4 −3看文件
| @@ -163,7 +163,7 @@ jobs: | ||
| 163 | 163 | release="$PWD/_output/releases/$version" |
| 164 | 164 | node scripts/release-version.mjs metadata macos "$release/build-metadata.json" |
| 165 | 165 | mkdir -p _output/ci-macos-release |
| 166 | 删除: cp "$release/Cage-$version-macos-arm64.dmg" "$release/mihomo-$source_version-source.tar.gz" "$release/SHA256SUMS" "$release/build-metadata.json" _output/ci-macos-release/ | |
| 166 | 新增: cp "$release/Cage-$version-macos-arm64.dmg" "$release/mihomo-$source_version-source.tar.gz" "$release/cage-macos-guest-$version-source.tar.gz" "$release/SHA256SUMS" "$release/build-metadata.json" _output/ci-macos-release/ | |
| 167 | 167 | (cd _output/ci-macos-release && shasum -a 256 --check SHA256SUMS) |
| 168 | 168 | - uses: actions/upload-artifact@v4 |
| 169 | 169 | with: |
| @@ -21,14 +21,17 @@ if [[ ${#sources[@]} != 1 ]]; then echo 'Expected exactly one Mihomo source arch | ||
| 21 | 21 | archive="${archives[0]}" |
| 22 | 22 | version="${archive##*/Cage-}" |
| 23 | 23 | version="${version%-macos-arm64.dmg}" |
| 24 | 新增:guest_source="$directory/cage-macos-guest-$version-source.tar.gz" | |
| 25 | 新增:[[ -f "$guest_source" ]] || { echo 'Expected the matching macOS guest corresponding source archive.' >&2; exit 1; } | |
| 24 | 26 | # The release may also contain Windows installers and their corresponding |
| 25 | 27 | # sources. Validate this platform's downloaded files against the original list. |
| 26 | 28 | checksum_input="$(mktemp)" |
| 27 | 29 | trap 'rm -f "$checksum_input"' EXIT |
| 28 | 删除:awk -v archive="${archive##*/}" -v source="${sources[0]##*/}" ' | |
| 30 | 新增:awk -v archive="${archive##*/}" -v source="${sources[0]##*/}" -v guest="${guest_source##*/}" ' | |
| 29 | 31 | NF == 2 && ($2 == archive || $2 == "*" archive) { archives++; print } |
| 30 | 32 | NF == 2 && ($2 == source || $2 == "*" source) { sources++; print } |
| 31 | 删除: END { if (archives != 1 || sources != 1) exit 1 } | |
| 33 | 新增: NF == 2 && ($2 == guest || $2 == "*" guest) { guests++; print } | |
| 34 | 新增: END { if (archives != 1 || sources != 1 || guests != 1) exit 1 } | |
| 32 | 35 | ' "$directory/SHA256SUMS" > "$checksum_input" |
| 33 | 36 | (cd "$directory" && shasum -a 256 --check "$checksum_input") |
| 34 | 37 | rm -f "$checksum_input" |
| @@ -46,4 +49,8 @@ codesign --verify --deep --strict --verbose=2 \ | ||
| 46 | 49 | -R='anchor apple generic and identifier "io.github.lee-xeo.claude-cage" and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists' "$bundle" |
| 47 | 50 | validate_ticket "$bundle" |
| 48 | 51 | spctl --assess --type execute --verbose=2 "$bundle" |
| 49 | 删除:echo "Verified Developer ID, notarization, Gatekeeper, and version: Cage $version" | |
| 52 | 新增:cmp "$guest_source" "$bundle/Contents/Resources/guest-os/sources/${guest_source##*/}" | |
| 53 | 新增:script_dir="$(cd "$(dirname "$0")" && pwd)" | |
| 54 | 新增:node "$script_dir/guest-os/collect-macos-sshfs-sources.mjs" verify "$guest_source" \ | |
| 55 | 新增: "$bundle/Contents/Resources/guest-os/project/cage-sshfs" "$version" | |
| 56 | 新增:echo "Verified Developer ID, notarization, Gatekeeper, version and corresponding source: Cage $version" | |
| @@ -170,14 +170,14 @@ test('same-version unsigned Windows uses the version release and preserves the s | ||
| 170 | 170 | assert.ok(!releaseMetadata(release, sums(fixture())).windowsPreview); |
| 171 | 171 | }); |
| 172 | 172 | |
| 173 | 删除:test('macOS verification checks both owned archives without requiring other-platform source files', () => { | |
| 173 | 新增:test('macOS verification checks all owned archives without requiring other-platform source files', () => { | |
| 174 | 174 | const directory = mkdtempSync(join(tmpdir(), 'cage-release-check-')); |
| 175 | 175 | const script = new URL('../../scripts/verify-macos-release.sh', import.meta.url); |
| 176 | 176 | const nativeReached = join(directory, 'native-check-reached'); |
| 177 | 177 | // Stop at the first macOS-specific validation. Hash verification above it |
| 178 | 178 | // remains the actual shipped shell entry, including missing/duplicate checks. |
| 179 | 179 | writeFileSync(join(directory, 'codesign'), '#!/bin/sh\nprintf reached > "$CAGE_TEST_NATIVE_MARKER"\nexit 42\n', { mode: 0o700 }); |
| 180 | 删除: const owned = ['Cage-0.2.0-macos-arm64.dmg', 'mihomo-v1.19.33-source.tar.gz']; | |
| 180 | 新增: const owned = ['Cage-0.2.0-macos-arm64.dmg', 'mihomo-v1.19.33-source.tar.gz', 'cage-macos-guest-0.2.0-source.tar.gz']; | |
| 181 | 181 | for (const name of owned) writeFileSync(join(directory, name), name); |
| 182 | 182 | const valid = owned.map(name => `${createHash('sha256').update(name).digest('hex')} ${name}\n`).join(''); |
| 183 | 183 | const extra = `${hash} qemu-windows-full-source.zip\n${hash} Cage-0.2.0-windows-amd64-setup.exe\n`; |
| @@ -189,7 +189,8 @@ test('macOS verification checks both owned archives without requiring other-plat | ||
| 189 | 189 | try { |
| 190 | 190 | assert.equal(run(valid + extra).status, 42, 'unrelated release assets blocked macOS checksum verification'); |
| 191 | 191 | assert.ok(existsSync(nativeReached)); |
| 192 | 删除: for (const invalid of [extra, valid + valid, valid.replace(/^[a-f0-9]{64}/, '0'.repeat(64))]) { | |
| 192 | 新增: const missingGuest = valid.split('\n').filter(line => !line.includes(owned[2])).join('\n'); | |
| 193 | 新增: for (const invalid of [extra, valid + valid, missingGuest, valid.replace(/^[a-f0-9]{64}/, '0'.repeat(64))]) { | |
| 193 | 194 | assert.notEqual(run(invalid).status, 42); |
| 194 | 195 | assert.ok(!existsSync(nativeReached), 'invalid macOS checksum reached native signature verification'); |
| 195 | 196 | } |

