fix: tighten local read allowlist and gracefully skip whisper-runtime build without CMake

isAllowedLocalReadPath previously returned true for any existing path because of an existsSync fast-path, which made the read-local-file IPC handler and the local media URL policy effectively allow reading arbitrary files on disk. Drop the existsSync bypass so only paths under app-managed directories or paths that have been explicitly approved (via dialogs, exports, recording sessions, etc.) are accepted. Adjust the local media path policy tests to cover the new behaviour.

Also make build-whisper-runtime fall back to bundled artifacts when CMake is missing (mirroring build-windows-capture) so npm ci does not fail on machines without a C++ toolchain.
This commit is contained in:
Recordly Reviewer
2026-05-04 14:21:49 -04:00
parent 42c6cf458e
commit dce19d5209
3 changed files with 44 additions and 8 deletions
+23 -3
View File
@@ -361,15 +361,35 @@ async function stageRuntimeArtifacts(target, candidateDir, runtimeEntries) {
}
async function main() {
const targets = getTargetConfigs();
const cmake = findCmake();
if (!cmake) {
throw new Error(
"[build-whisper-runtime] CMake is required to build the bundled Whisper runtime.",
// Mirror build-windows-capture: if every target already has a staged
// runtime, postinstall is a no-op. This keeps `npm ci` working for
// contributors who do not have CMake installed and only need to run the
// app or tests against the bundled binaries.
const skipChecks = await Promise.all(targets.map((target) => shouldSkipBuild(target)));
if (skipChecks.every(Boolean)) {
console.log(
"[build-whisper-runtime] CMake not found; using bundled whisper runtime artifacts.",
);
return;
}
const missing = targets
.filter((_target, index) => !skipChecks[index])
.map((target) => target.archTag)
.join(", ");
console.warn(
`[build-whisper-runtime] CMake not found and no bundled runtime is staged for: ${missing}. ` +
"Auto-caption features that rely on whisper.cpp will be unavailable until you install CMake " +
"and rerun `npm run build:whisper-runtime`.",
);
return;
}
const sourceDir = await ensureSourceTree();
const targets = getTargetConfigs();
console.log(
`[build-whisper-runtime] Target architectures for ${process.platform}: ${targets.map((target) => target.archTag).join(", ")}`,