mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(producer): check scheme-prefixed media sources against the project folder (#7851)
The outside-project media check skipped any src starting with data:, blob:, about: or http(s): in any letter case, while the readers resolve everything but exact http:// and https:// URLs as a local path. A src such as data:x/../../outside/clip.mp4 passed the check and the readers opened the file it named. The check and the media type preflight now use the readers' remote test, isHttpUrl, and check every other src with a shared containment helper, isInsideAssetRoots. Frame extraction, the audio mix, and the HDR and video sound probes also refuse a local source outside the project, compiled and download folders on their own when outside files are not allowed.
This commit is contained in:
@@ -441,6 +441,7 @@ export {
|
||||
type PublicHttpsTextOptions,
|
||||
} from "./utils/urlDownloader.js";
|
||||
export { isBlockedNetworkHost } from "./utils/networkPolicy.js";
|
||||
export { isInsideAssetRoots } from "./utils/assetRoots.js";
|
||||
export { onRenderRefusal } from "./services/publicNetwork/captureProxy.js";
|
||||
export type { RefusedHostClass } from "./services/publicNetwork/publicNetwork.js";
|
||||
export {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
type AudioMetadata,
|
||||
} from "../utils/ffprobe.js";
|
||||
import { isNotMediaPayload } from "../utils/notMediaPayload.js";
|
||||
import { isInsideAssetRoots } from "../utils/assetRoots.js";
|
||||
import { urlInputArgs } from "../utils/urlInput.js";
|
||||
import { clampAudioGain, clipGain } from "@hyperframes/core/audio-gain";
|
||||
import { clampFadesToDuration, readElementFades } from "@hyperframes/core/audio-fade";
|
||||
@@ -1432,6 +1433,8 @@ export async function processCompositionAudio(
|
||||
urlByAbsentLocalPath?: ReadonlyMap<string, string>;
|
||||
audioSidecarUrlByLocalPath?: ReadonlyMap<string, string>;
|
||||
keepEncoderInputAt?: string;
|
||||
/** Folders a local source must be in; one outside them is never opened. Unset allows any folder. */
|
||||
assetRoots?: readonly string[];
|
||||
},
|
||||
compiledDir?: string,
|
||||
): Promise<MixResult> {
|
||||
@@ -1496,6 +1499,18 @@ export async function processCompositionAudio(
|
||||
audioSidecarUrl = config?.audioSidecarUrlByLocalPath?.get(srcPath);
|
||||
srcPath = remoteUrl;
|
||||
readInPlace = true;
|
||||
} else if (config?.assetRoots && !isInsideAssetRoots(srcPath, config.assetRoots)) {
|
||||
failures.push({
|
||||
stage: "source",
|
||||
reason: "source_not_found",
|
||||
owner: "user",
|
||||
retryable: false,
|
||||
elementId: element.id,
|
||||
detail: boundedDetail(
|
||||
`Audio element ${element.id} source is outside the project folder`,
|
||||
),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { parseHTML } from "linkedom";
|
||||
import { HF_COLOR_GRADING_ATTR } from "@hyperframes/core";
|
||||
import { isPathInside } from "@hyperframes/parsers/asset-paths";
|
||||
import { resolveProjectRelativeSrc } from "@hyperframes/parsers/asset-resolution";
|
||||
import { isInsideAssetRoots } from "../utils/assetRoots.js";
|
||||
import { alphaDecoderFor } from "@hyperframes/parsers/media-alpha";
|
||||
import {
|
||||
MEDIA_RENDER_ID_ATTR,
|
||||
@@ -311,6 +312,8 @@ export interface ExtractionOptions {
|
||||
/** Directories the caller rewrites on every render (downloaded media); their sources are cached by content. */
|
||||
contentKeyedDirs?: readonly string[];
|
||||
urlByAbsentLocalPath?: ReadonlyMap<string, string>;
|
||||
/** Folders a local source must be in; one outside them is never opened. Unset allows any folder. */
|
||||
assetRoots?: readonly string[];
|
||||
shownBox?: { width: number; height: number };
|
||||
shownBoxes?: ReadonlyMap<string, { width: number; height: number }>;
|
||||
}
|
||||
@@ -2242,6 +2245,16 @@ export async function extractAllVideoFrames(
|
||||
resolvedVideos.push({ video, videoPath: remoteUrl });
|
||||
continue;
|
||||
}
|
||||
const roots = options.assetRoots;
|
||||
if (!isHttpUrl(videoPath) && roots && !isInsideAssetRoots(videoPath, roots)) {
|
||||
errors.push({
|
||||
videoId: video.id,
|
||||
kind: "source_missing",
|
||||
retryable: false,
|
||||
error: `Video source is outside the project folder: ${video.src}`,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isHttpUrl(videoPath)) {
|
||||
const downloadDir = join(options.outputDir, DOWNLOAD_SUBDIR);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import { isSafePath } from "@hyperframes/core/safe-path";
|
||||
import { isWithinProjectRoot } from "@hyperframes/parsers/asset-resolution";
|
||||
|
||||
export function isInsideAssetRoots(path: string, roots: readonly string[]): boolean {
|
||||
if (roots.some((root) => isSafePath(root, path))) return true;
|
||||
// A name the file system refuses, such as a long data: URL, opens nothing, so its spelling decides.
|
||||
return !existsSync(path) && roots.some((root) => isWithinProjectRoot(root, path));
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { NOT_MEDIA_PAYLOAD, NotMediaPayloadError } from "@hyperframes/engine";
|
||||
import {
|
||||
ASSET_MEDIA_TYPE_MISMATCH,
|
||||
AssetMediaTypeMismatchError,
|
||||
dropMediaOutsideProject,
|
||||
preflightCompositionAssetMediaTypes,
|
||||
} from "./assetMediaType.js";
|
||||
import { synthesizeMediaFixture } from "./mediaTypeTestFixtures.js";
|
||||
@@ -254,6 +255,13 @@ describe("preflightCompositionAssetMediaTypes", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["data:x/../streamed-preview.html", "BLOB:a/../streamed-preview.html"])(
|
||||
"sniffs a project file named behind a URL scheme: %s",
|
||||
async (videoSrc) => {
|
||||
await expect(run({ videoSrc })).rejects.toBeInstanceOf(NotMediaPayloadError);
|
||||
},
|
||||
);
|
||||
|
||||
it("leaves an SVG image source alone", async () => {
|
||||
// ffprobe reads SVG through its svg_pipe demuxer, so an XML body is a
|
||||
// legitimate <img> payload and must not be swept up by the sniff.
|
||||
@@ -274,3 +282,43 @@ describe("preflightCompositionAssetMediaTypes", () => {
|
||||
await expect(run({ videoSrc: "mutable-media" }, signal)).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("dropMediaOutsideProject", () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "hf-media-outside-"));
|
||||
const projectDir = join(root, "project");
|
||||
const workDir = join(root, "work");
|
||||
afterAll(() => rmSync(root, { recursive: true, force: true }));
|
||||
|
||||
const keptVideos = (srcs: Record<string, string>) => {
|
||||
mkdirSync(projectDir, { recursive: true });
|
||||
mkdirSync(join(root, "outside"), { recursive: true });
|
||||
writeFileSync(join(root, "outside", "secret.txt"), "secret");
|
||||
const video = ([id, src]: [string, string]) => ({
|
||||
...{ id, src, start: 0, end: 1, mediaStart: 0 },
|
||||
...{ loop: false, hasAudio: false },
|
||||
});
|
||||
const composition = { videos: Object.entries(srcs).map(video), audios: [], images: [] };
|
||||
const log = { error() {}, info() {}, debug() {}, warn() {} };
|
||||
dropMediaOutsideProject({ projectDir, workDir, composition, log });
|
||||
return composition.videos.map((v) => v.id);
|
||||
};
|
||||
|
||||
it("drops a URL scheme followed by parent folders, in any letter case", () => {
|
||||
const schemes = ["data:", "DATA:", "blob:", "Blob:", "about:", "https:", "HTTP:"];
|
||||
const srcs = Object.fromEntries(
|
||||
schemes.map((scheme, i) => [`v${i}`, `${scheme}x/../../outside/secret.txt`]),
|
||||
);
|
||||
expect(keptVideos(srcs)).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps genuine inline, blob and remote media", () => {
|
||||
const srcs = {
|
||||
data: "data:video/mp4;base64,AAAAIGZ0eXBpc29t",
|
||||
long: `data:video/mp4;base64,${"A".repeat(5000)}/${"B".repeat(300)}`,
|
||||
blob: "blob:https://studio.example/0f6c9a52-6f1e-4d1e-9a51-2b1f3c4d5e6f",
|
||||
remote: "https://media.example.com/clip.mp4",
|
||||
local: "clip.mp4",
|
||||
};
|
||||
expect(keptVideos(srcs)).toEqual(Object.keys(srcs));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { dirname, join } from "node:path";
|
||||
import {
|
||||
fingerprintElementId,
|
||||
isHttpUrl,
|
||||
isInsideAssetRoots,
|
||||
isNotMediaPayload,
|
||||
playlistLeavesItsFolder,
|
||||
NotMediaPayloadError,
|
||||
@@ -13,7 +15,7 @@ import {
|
||||
type VideoElement,
|
||||
} from "@hyperframes/engine";
|
||||
import { withMediaProbeSlot } from "../utils/mediaProbeConcurrency.js";
|
||||
import { escapesAssetRoot, leftOutOfRender, outsideAssetRefusal } from "../utils/paths.js";
|
||||
import { leftOutOfRender, outsideAssetRefusal } from "../utils/paths.js";
|
||||
import type { ProducerLogger } from "../logger.js";
|
||||
|
||||
export const ASSET_MEDIA_TYPE_MISMATCH = "ASSET_MEDIA_TYPE_MISMATCH" as const;
|
||||
@@ -91,8 +93,8 @@ interface MediaReference {
|
||||
expected: AssetElementMediaType;
|
||||
}
|
||||
|
||||
function isRemoteOrInlineSource(src: string): boolean {
|
||||
return /^(?:https?:|data:|blob:|about:)/i.test(src.trim());
|
||||
export function mediaAssetRoots(projectDir: string, compiledDir: string): string[] {
|
||||
return [projectDir, compiledDir, join(dirname(compiledDir), "downloads")];
|
||||
}
|
||||
|
||||
/** Treats local media outside the project, compiled and download dirs as missing: no probe or extraction opens it. */
|
||||
@@ -105,11 +107,11 @@ export function dropMediaOutsideProject(input: {
|
||||
}): void {
|
||||
const { projectDir, workDir, composition, log } = input;
|
||||
const compiledDir = join(workDir, "compiled");
|
||||
const roots = [projectDir, compiledDir, join(workDir, "downloads")];
|
||||
const roots = mediaAssetRoots(projectDir, compiledDir);
|
||||
const staysInside = ({ id, src }: { id: string; src: string }) => {
|
||||
if (!src || isRemoteOrInlineSource(src)) return true;
|
||||
if (!src || isHttpUrl(src)) return true;
|
||||
const path = resolveProjectRelativeSrc(src, projectDir, compiledDir);
|
||||
if (roots.some((root) => !escapesAssetRoot(path, root))) return true;
|
||||
if (isInsideAssetRoots(path, roots)) return true;
|
||||
if (input.allowOutsideProjectAssets) {
|
||||
const refusal = outsideAssetRefusal(projectDir, path);
|
||||
if (refusal) log.warn(`[Render] ${leftOutOfRender(`Media "${id}"`, src, refusal)}`);
|
||||
@@ -166,7 +168,7 @@ export async function preflightCompositionAssetMediaTypes(input: {
|
||||
|
||||
const byPath = new Map<string, MediaReference[]>();
|
||||
for (const reference of references) {
|
||||
if (!reference.src || isRemoteOrInlineSource(reference.src)) continue;
|
||||
if (!reference.src || isHttpUrl(reference.src)) continue;
|
||||
const resolvedPath = resolveProjectRelativeSrc(
|
||||
reference.src,
|
||||
input.projectDir,
|
||||
|
||||
@@ -1469,6 +1469,7 @@ function mixPlanAudio(c: PlanComposition, compiledDir: string) {
|
||||
compiledDir,
|
||||
urlByAbsentLocalPath: c.urlByAbsentLocalPath,
|
||||
audioSidecarUrlByLocalPath: c.audioSidecarUrlByLocalPath,
|
||||
allowOutsideProjectAssets: c.job.config.allowOutsideProjectAssets,
|
||||
totalFrames: c.totalFrames,
|
||||
fps: c.job.config.fps,
|
||||
ffmpegProcessTimeout: c.cfg.ffmpegProcessTimeout,
|
||||
@@ -1878,6 +1879,7 @@ export async function buildPlanAudio(
|
||||
await appendVideoAudioFromProbe({
|
||||
...c,
|
||||
downloadDir: audioWorkDir(c.workDir),
|
||||
allowOutsideProjectAssets: c.job.config.allowOutsideProjectAssets,
|
||||
signal: c.abortSignal,
|
||||
});
|
||||
logPlanStage(c.log, "extract", stageStarted);
|
||||
|
||||
@@ -17,7 +17,12 @@ import { join, relative, resolve } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { resolveConfig } from "@hyperframes/engine";
|
||||
import { runCompileStage } from "./render/stages/compileStage.js";
|
||||
import { runExtractVideosStage } from "./render/stages/extractVideosStage.js";
|
||||
import {
|
||||
appendVideoAudioFromProbe,
|
||||
runExtractVideosStage,
|
||||
} from "./render/stages/extractVideosStage.js";
|
||||
import { runAudioStage } from "./render/stages/audioStage.js";
|
||||
import { collectRenderMedia } from "./renderMediaCollector.js";
|
||||
import { createRenderJob } from "./renderOrchestrator.js";
|
||||
import { createFileServer } from "./fileServer.js";
|
||||
import { plan } from "./distributed/plan.js";
|
||||
@@ -99,7 +104,10 @@ function outsideProject(media: boolean) {
|
||||
video("dotdot", "../outside/clip.mp4"),
|
||||
video("encoded", "..%2Foutside%2Fclip.mp4"),
|
||||
video("remote", "https://media.example.com/clip.mp4"),
|
||||
video("data-scheme", "data:x/../../outside/clip.mp4"),
|
||||
video("blob-scheme", "BLOB:a/../../outside/clip.mp4"),
|
||||
`<audio id="tone" src="../outside/clip.mp4" data-start="0" data-duration="1"></audio>`,
|
||||
`<audio id="tone-scheme" src="Data:x/../../outside/clip.mp4" data-start="0" data-duration="1"></audio>`,
|
||||
].join("");
|
||||
writeFileSync(
|
||||
join(projectDir, "index.html"),
|
||||
@@ -227,9 +235,10 @@ describe.skipIf(!HAS_FFMPEG)("render servers keep markup inside the project", ()
|
||||
).toEqual([]);
|
||||
expect(existsSync(join(compiledDir, "hf-ext"))).toBe(false);
|
||||
expect(result.composition.videos.map((video) => video.id)).toEqual(["remote"]);
|
||||
expect(result.composition.audios.filter((audio) => audio.id === "tone")).toEqual([]);
|
||||
expect(result.composition.audios.filter((audio) => audio.id.startsWith("tone"))).toEqual([]);
|
||||
expect(result.composition.images).toEqual([]);
|
||||
for (const id of ["absolute", "fileurl", "dotdot", "encoded", "tone"]) {
|
||||
const dropped = ["absolute", "fileurl", "dotdot", "encoded", "data-scheme", "blob-scheme"];
|
||||
for (const id of [...dropped, "tone", "tone-scheme"]) {
|
||||
expect(warnings.some((line) => line.includes(`"${id}" source is missing`))).toBe(true);
|
||||
}
|
||||
expect(extracted.extractionResult?.extracted.map((frames) => frames.videoId)).toEqual([
|
||||
@@ -355,3 +364,75 @@ describe.skipIf(!HAS_FFMPEG)("render servers keep markup inside the project", ()
|
||||
expect(result.compiled.html).toContain("OUTSIDE-SCENE");
|
||||
});
|
||||
});
|
||||
|
||||
// These sources skip the earlier filters on purpose: each reader must refuse them on its own.
|
||||
describe.skipIf(!HAS_FFMPEG)("render readers open nothing outside the project", () => {
|
||||
const escaping = (file: string) => [
|
||||
`data:x/../../outside/${file}`,
|
||||
`BLOB:a/../../outside/${file}`,
|
||||
];
|
||||
const videos = escaping("clip.mp4")
|
||||
.map(
|
||||
(src, i) =>
|
||||
`<video id="v${i}" src="${src}" data-start="0" data-duration="1" data-has-audio="true"></video>`,
|
||||
)
|
||||
.join("");
|
||||
|
||||
function reachedReaders(media: string) {
|
||||
const { root, projectDir, outsideDir } = outsideProject(false);
|
||||
const workDir = join(root, "work");
|
||||
const compiledDir = join(workDir, "compiled");
|
||||
mkdirSync(compiledDir, { recursive: true });
|
||||
const collected = collectRenderMedia(
|
||||
`<div data-composition-id="root" data-width="320" data-height="240" data-duration="1">${media}</div>`,
|
||||
);
|
||||
const composition = { ...collected, duration: 1, width: 320, height: 240 };
|
||||
tool.calls.length = 0;
|
||||
const openedOutside = () => tool.calls.filter((call) => call.includes(outsideDir));
|
||||
return { projectDir, workDir, compiledDir, composition, openedOutside };
|
||||
}
|
||||
|
||||
it.each(["force-sdr", "auto"] as const)(
|
||||
"video frame extraction and HDR probes (hdrMode %s)",
|
||||
async (hdrMode) => {
|
||||
const images = escaping("secret.png")
|
||||
.map((src, i) => `<img id="i${i}" src="${src}" data-start="0" data-duration="1">`)
|
||||
.join("");
|
||||
const { projectDir, compiledDir, composition, openedOutside } = reachedReaders(
|
||||
videos + images,
|
||||
);
|
||||
expect(composition.videos).toHaveLength(2);
|
||||
expect(composition.images).toHaveLength(2);
|
||||
const job = createRenderJob({ fps: { num: 30, den: 1 }, quality: "draft", hdrMode });
|
||||
const log = { error() {}, info() {}, debug() {}, warn() {} };
|
||||
await runExtractVideosStage({
|
||||
...{ projectDir, compiledDir, job, cfg: resolveConfig(), log, composition },
|
||||
...{ abortSignal: undefined, assertNotAborted: () => {} },
|
||||
}).catch(() => undefined);
|
||||
expect(openedOutside()).toEqual([]);
|
||||
},
|
||||
);
|
||||
|
||||
it("audio probes of video sound", async () => {
|
||||
const { projectDir, compiledDir, composition, openedOutside } = reachedReaders(videos);
|
||||
composition.audios.length = 0;
|
||||
await appendVideoAudioFromProbe({ projectDir, compiledDir, composition });
|
||||
expect(openedOutside()).toEqual([]);
|
||||
expect(composition.audios).toEqual([]);
|
||||
});
|
||||
|
||||
it("audio mix", async () => {
|
||||
const audios = escaping("clip.mp4")
|
||||
.map((src, i) => `<audio id="a${i}" src="${src}" data-start="0" data-duration="1"></audio>`)
|
||||
.join("");
|
||||
const { projectDir, workDir, compiledDir, composition, openedOutside } = reachedReaders(audios);
|
||||
expect(composition.audios).toHaveLength(2);
|
||||
const result = await runAudioStage({
|
||||
...{ projectDir, workDir, compiledDir, audios: composition.audios },
|
||||
...{ totalFrames: 30, fps: { num: 30, den: 1 }, ffmpegProcessTimeout: 30_000, audioGain: 1 },
|
||||
...{ abortSignal: undefined, assertNotAborted: () => {} },
|
||||
});
|
||||
expect(openedOutside()).toEqual([]);
|
||||
expect(result.hasAudio).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -214,6 +214,7 @@ describe("runAudioStage", () => {
|
||||
ffmpegProcessTimeout: 3_600_000,
|
||||
audioGain: 1,
|
||||
keepEncoderInputAt: expect.stringMatching(/audio-source\.wav$/),
|
||||
assetRoots: expect.any(Array),
|
||||
},
|
||||
expect.any(String),
|
||||
);
|
||||
@@ -268,6 +269,7 @@ describe("runAudioStage", () => {
|
||||
audioGain: 1,
|
||||
masterFxChain: chain,
|
||||
keepEncoderInputAt: expect.stringMatching(/audio-source\.wav$/),
|
||||
assetRoots: expect.any(Array),
|
||||
},
|
||||
expect.any(String),
|
||||
);
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
type MixResult,
|
||||
} from "@hyperframes/engine";
|
||||
import { audioWorkDir, type CompositionMetadata } from "../shared.js";
|
||||
import { mediaAssetRoots } from "../../assetMediaType.js";
|
||||
import type { ProducerLogger } from "../../../logger.js";
|
||||
import { encoderFailureError } from "../encoderInterruption.js";
|
||||
import { limitDeliveryPeaks } from "../audioDeliveryLimit.js";
|
||||
@@ -52,6 +53,7 @@ export interface AudioStageInput {
|
||||
masterFxChain?: string;
|
||||
urlByAbsentLocalPath?: ReadonlyMap<string, string>;
|
||||
audioSidecarUrlByLocalPath?: ReadonlyMap<string, string>;
|
||||
allowOutsideProjectAssets?: boolean;
|
||||
abortSignal: AbortSignal | undefined;
|
||||
assertNotAborted: () => void;
|
||||
/** Where a per-track failure's detail goes. Optional so tests need not pass one. */
|
||||
@@ -213,6 +215,9 @@ async function mixAudioForDelivery(
|
||||
urlByAbsentLocalPath,
|
||||
audioSidecarUrlByLocalPath,
|
||||
keepEncoderInputAt: pcmSourcePath,
|
||||
assetRoots: input.allowOutsideProjectAssets
|
||||
? undefined
|
||||
: mediaAssetRoots(projectDir, compiledDir),
|
||||
},
|
||||
compiledDir,
|
||||
);
|
||||
|
||||
@@ -51,6 +51,7 @@ import {
|
||||
resolveFinalFrameExtractionWindow,
|
||||
resolveVideoExtractionWindow,
|
||||
isHttpUrl,
|
||||
isInsideAssetRoots,
|
||||
assertPublicHttpsUrl,
|
||||
downloadToTemp,
|
||||
resolveRestrictPageNetwork,
|
||||
@@ -78,6 +79,7 @@ import { resolveRenderFpsConfig } from "../../fileServer.js";
|
||||
import type { ProducerLogger } from "../../../logger.js";
|
||||
import { encoderFailureError } from "../encoderInterruption.js";
|
||||
import { rendersSdrOnly } from "../hdrMode.js";
|
||||
import { mediaAssetRoots } from "../../assetMediaType.js";
|
||||
import {
|
||||
compareExtractionFailureGroups,
|
||||
extractionFailureGroupIdentityKey,
|
||||
@@ -438,6 +440,9 @@ export async function runExtractVideosStage(
|
||||
} = input;
|
||||
|
||||
const stage2Start = Date.now();
|
||||
const assetRoots = job.config.allowOutsideProjectAssets
|
||||
? undefined
|
||||
: mediaAssetRoots(projectDir, compiledDir);
|
||||
const extractionPolicy = resolveVideoExtractionPolicy();
|
||||
composition.videos = composition.videos.filter(
|
||||
(video) => !isVideoPastTimelineEnd(video, composition.duration),
|
||||
@@ -470,7 +475,7 @@ export async function runExtractVideosStage(
|
||||
// origin-root URL — pre-checking would hand back `/assets/%E5%9B%BE1.png`
|
||||
// undecoded and re-open PRINFRA-349 for root-relative srcs.
|
||||
const videoPath = resolveProjectRelativeSrc(v.src, projectDir, compiledDir);
|
||||
if (!existsSync(videoPath)) return null;
|
||||
if (!opensLocally(videoPath, assetRoots)) return null;
|
||||
try {
|
||||
// Retries are separately opt-in from the failure gate. With the
|
||||
// default zero budget this remains the exact legacy single probe.
|
||||
@@ -522,7 +527,7 @@ export async function runExtractVideosStage(
|
||||
// never enters nativeHdrImageIds and the composition silently renders
|
||||
// through the SDR fallback with wrong color (PRINFRA-349 symptom c).
|
||||
const imgPath = resolveProjectRelativeSrc(img.src, projectDir, compiledDir);
|
||||
if (!existsSync(imgPath)) return null;
|
||||
if (!opensLocally(imgPath, assetRoots)) return null;
|
||||
const colorSpace = await probeColorSpaceSafely(imgPath, log);
|
||||
if (isHdrColorSpace(colorSpace)) {
|
||||
nativeHdrImageIds.add(img.id);
|
||||
@@ -542,6 +547,7 @@ export async function runExtractVideosStage(
|
||||
composition,
|
||||
urlByAbsentLocalPath,
|
||||
downloadDir: audioDownloadDir,
|
||||
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
|
||||
signal: abortSignal,
|
||||
log,
|
||||
});
|
||||
@@ -575,6 +581,7 @@ export async function runExtractVideosStage(
|
||||
shownBoxes,
|
||||
contentKeyedDirs: [join(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
||||
urlByAbsentLocalPath,
|
||||
assetRoots,
|
||||
onProgress: ({ planned = 0, done = 0 }) => {
|
||||
framesPlanned += planned;
|
||||
framesDone += done;
|
||||
@@ -674,14 +681,22 @@ interface VideoAudioProbeInput {
|
||||
urlByAbsentLocalPath?: ReadonlyMap<string, string>;
|
||||
/** Where a composition URL is downloaded before probing on a render service: the mixer's work folder, so the mix reuses it. */
|
||||
downloadDir?: string;
|
||||
allowOutsideProjectAssets?: boolean;
|
||||
signal?: AbortSignal;
|
||||
log?: ProducerLogger;
|
||||
}
|
||||
|
||||
function opensLocally(path: string, assetRoots: readonly string[] | undefined): boolean {
|
||||
return existsSync(path) && (!assetRoots || isInsideAssetRoots(path, assetRoots));
|
||||
}
|
||||
|
||||
function localProbeSource(src: string, input: VideoAudioProbeInput): string | null {
|
||||
const path = resolveProjectRelativeSrc(src, input.projectDir, input.compiledDir);
|
||||
const readFrom = input.urlByAbsentLocalPath?.get(path) ?? path;
|
||||
return isHttpUrl(readFrom) || existsSync(readFrom) ? readFrom : null;
|
||||
const roots = input.allowOutsideProjectAssets
|
||||
? undefined
|
||||
: mediaAssetRoots(input.projectDir, input.compiledDir);
|
||||
return isHttpUrl(readFrom) || opensLocally(readFrom, roots) ? readFrom : null;
|
||||
}
|
||||
|
||||
/** On a render service a composition URL is fetched under the download address rules and probed from that copy. */
|
||||
|
||||
@@ -3749,6 +3749,7 @@ async function executeRenderPipeline(input: {
|
||||
audioGain: cfg.audioGain,
|
||||
audios: composition.audios,
|
||||
masterFxChain: composition.masterFxChain,
|
||||
allowOutsideProjectAssets: job.config.allowOutsideProjectAssets,
|
||||
abortSignal: executionSignal,
|
||||
assertNotAborted,
|
||||
log,
|
||||
|
||||
Reference in New Issue
Block a user