fix(ci): read full ASAR pickle header length in installer smoke gate
This commit is contained in:
parent
78c91714ef
commit
405ae1687a
2 changed files with 69 additions and 11 deletions
|
|
@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Plugin system for custom pipelines
|
- Plugin system for custom pipelines
|
||||||
|
|
||||||
|
|
||||||
|
## [1.17.1] - 2026-11-14
|
||||||
|
|
||||||
|
> Supersedes unpublished `1.17.0` with the full-length ASAR Pickle header smoke verification fix and ships the full `1.17.0` multi-surface release.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Read the full declared JSON byte length (up to 32 MiB) instead of a fixed 64 KiB prefix in `verify-desktop-installer-smoke.mjs` when validating `resources/app.asar`.
|
||||||
|
|
||||||
## [1.17.0] - 2026-11-14
|
## [1.17.0] - 2026-11-14
|
||||||
|
|
||||||
> Multi-surface quality, 12-locale parity, speaker diarization, tablet responsive layout, and stability hardening across Desktop, Mobile, Web, Admin, and Cloud services.
|
> Multi-surface quality, 12-locale parity, speaker diarization, tablet responsive layout, and stability hardening across Desktop, Mobile, Web, Admin, and Cloud services.
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,19 @@
|
||||||
// 5. (--verify-signature 또는 latest.yml.sig 존재 시) Ed25519 공개키 서명 검증
|
// 5. (--verify-signature 또는 latest.yml.sig 존재 시) Ed25519 공개키 서명 검증
|
||||||
|
|
||||||
import { createHash, createPublicKey, generateKeyPairSync, sign, verify } from 'node:crypto'
|
import { createHash, createPublicKey, generateKeyPairSync, sign, verify } from 'node:crypto'
|
||||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
import {
|
||||||
|
closeSync,
|
||||||
|
existsSync,
|
||||||
|
mkdirSync,
|
||||||
|
mkdtempSync,
|
||||||
|
openSync,
|
||||||
|
readFileSync,
|
||||||
|
readSync,
|
||||||
|
readdirSync,
|
||||||
|
rmSync,
|
||||||
|
statSync,
|
||||||
|
writeFileSync
|
||||||
|
} from 'node:fs'
|
||||||
import { tmpdir } from 'node:os'
|
import { tmpdir } from 'node:os'
|
||||||
import { dirname, join } from 'node:path'
|
import { dirname, join } from 'node:path'
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
|
|
@ -25,6 +37,7 @@ const CANONICAL_UPDATE_FEED =
|
||||||
'https://git.chanpaca.net/api/packages/yunchan/generic/d3ro-voice/latest'
|
'https://git.chanpaca.net/api/packages/yunchan/generic/d3ro-voice/latest'
|
||||||
const MAX_UPLOAD_BYTES = 100 * 1024 * 1024
|
const MAX_UPLOAD_BYTES = 100 * 1024 * 1024
|
||||||
const MIN_INSTALLER_BYTES = 4096
|
const MIN_INSTALLER_BYTES = 4096
|
||||||
|
const MAX_ASAR_HEADER_BYTES = 32 * 1024 * 1024
|
||||||
|
|
||||||
function readPeMachine(buffer) {
|
function readPeMachine(buffer) {
|
||||||
if (buffer.length < 0x44) return null
|
if (buffer.length < 0x44) return null
|
||||||
|
|
@ -42,18 +55,39 @@ function readPeMachine(buffer) {
|
||||||
return buffer.readUInt16LE(peOffset + 4)
|
return buffer.readUInt16LE(peOffset + 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasValidAsarHeader(buffer) {
|
function readExact(fd, buffer, length, position) {
|
||||||
if (buffer.length < 20) return false
|
let offset = 0
|
||||||
const picklePayloadSize = buffer.readUInt32LE(0)
|
while (offset < length) {
|
||||||
if (picklePayloadSize !== 4) return false
|
const bytesRead = readSync(fd, buffer, offset, length - offset, position + offset)
|
||||||
const jsonByteLength = buffer.readUInt32LE(12)
|
if (bytesRead <= 0) return false
|
||||||
if (jsonByteLength < 2 || 16 + jsonByteLength > buffer.length) return false
|
offset += bytesRead
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasValidAsarFileHeader(asarPath) {
|
||||||
|
let fd
|
||||||
try {
|
try {
|
||||||
const headerText = buffer.subarray(16, 16 + jsonByteLength).toString('utf8').replace(/\0+$/g, '')
|
const fileSize = statSync(asarPath).size
|
||||||
|
if (fileSize < 20) return false
|
||||||
|
fd = openSync(asarPath, 'r')
|
||||||
|
const preamble = Buffer.allocUnsafe(16)
|
||||||
|
if (!readExact(fd, preamble, 16, 0)) return false
|
||||||
|
const picklePayloadSize = preamble.readUInt32LE(0)
|
||||||
|
if (picklePayloadSize !== 4) return false
|
||||||
|
const jsonByteLength = preamble.readUInt32LE(12)
|
||||||
|
if (jsonByteLength < 2 || jsonByteLength > MAX_ASAR_HEADER_BYTES || 16 + jsonByteLength > fileSize) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const headerBuf = Buffer.allocUnsafe(jsonByteLength)
|
||||||
|
if (!readExact(fd, headerBuf, jsonByteLength, 16)) return false
|
||||||
|
const headerText = headerBuf.toString('utf8').replace(/\0+$/g, '')
|
||||||
const parsed = JSON.parse(headerText)
|
const parsed = JSON.parse(headerText)
|
||||||
return Boolean(parsed && typeof parsed === 'object' && parsed.files && typeof parsed.files === 'object')
|
return Boolean(parsed && typeof parsed === 'object' && parsed.files && typeof parsed.files === 'object')
|
||||||
} catch {
|
} catch {
|
||||||
return false
|
return false
|
||||||
|
} finally {
|
||||||
|
if (fd !== undefined) closeSync(fd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,8 +193,7 @@ export function verifyInstallerReleaseDir({
|
||||||
if (!existsSync(asarPath)) {
|
if (!existsSync(asarPath)) {
|
||||||
errors.push('app_asar_missing')
|
errors.push('app_asar_missing')
|
||||||
} else {
|
} else {
|
||||||
const asarPrefix = readFileSync(asarPath).subarray(0, 65536)
|
fail(hasValidAsarFileHeader(asarPath), 'app_asar_header_invalid')
|
||||||
fail(hasValidAsarHeader(asarPrefix), 'app_asar_header_invalid')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,6 +284,24 @@ function runSelfTest() {
|
||||||
})
|
})
|
||||||
if (!okResult.ok) throw new Error('self_test_valid_case_failed')
|
if (!okResult.ok) throw new Error('self_test_valid_case_failed')
|
||||||
|
|
||||||
|
// Regression: real Electron app.asar headers exceed 64 KiB (often several MiB).
|
||||||
|
const largeHeaderDir = createValidFixture('valid-large-asar')
|
||||||
|
const manyFiles = {}
|
||||||
|
for (let i = 0; i < 3000; i += 1) {
|
||||||
|
manyFiles[`node_modules/pkg-${i}/dist/index.js`] = { size: 128, offset: String(i * 128) }
|
||||||
|
}
|
||||||
|
writeFileSync(
|
||||||
|
join(largeHeaderDir, 'win-unpacked', 'resources', 'app.asar'),
|
||||||
|
buildSyntheticAsar({ files: manyFiles })
|
||||||
|
)
|
||||||
|
const largeResult = verifyInstallerReleaseDir({
|
||||||
|
releaseDir: largeHeaderDir,
|
||||||
|
expectedVersion: version,
|
||||||
|
publicKeyPem,
|
||||||
|
requireSignature: true
|
||||||
|
})
|
||||||
|
if (!largeResult.ok) throw new Error('self_test_large_asar_failed')
|
||||||
|
|
||||||
const expectCaseError = (name, tamper, expectedCode) => {
|
const expectCaseError = (name, tamper, expectedCode) => {
|
||||||
const dir = createValidFixture(name)
|
const dir = createValidFixture(name)
|
||||||
tamper(dir)
|
tamper(dir)
|
||||||
|
|
@ -322,7 +373,7 @@ function runSelfTest() {
|
||||||
'manifest_signature_invalid'
|
'manifest_signature_invalid'
|
||||||
)
|
)
|
||||||
|
|
||||||
process.stdout.write('[release:installer:smoke] self-test GREEN (1 valid + 8 negative cases)\n')
|
process.stdout.write('[release:installer:smoke] self-test GREEN (2 valid + 8 negative cases)\n')
|
||||||
} finally {
|
} finally {
|
||||||
rmSync(sandbox, { recursive: true, force: true })
|
rmSync(sandbox, { recursive: true, force: true })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue