Skip to content

Commit 255cf92

Browse files
vanceingallsclaude
andcommitted
fix(skills,producer): terminate ffprobe options in shipped skill scripts
The contract test only walked packages/*/src and only .ts, so it could not see the shipped agent tools under skills/**, which are .mjs/.cjs. 19 call sites there and in package tests were still missing `--` immediately before the input while the suite reported the bug class closed — a dash-prefixed filename is parsed as an option and fails the same way. Sweeps packages/, skills/ and scripts/ now, including .mjs/.cjs and test files (dither.test.mjs was one of the broken sites). Excludes only the contract test itself, which documents the contract with example argvs including a deliberately misordered one. Two guards were fixed while widening: the terminator must never be inserted after `-i`, which consumes the next token (a blind pass hit an ffmpeg input and a base64 -i), and comment prose describing a spawn is not a spawn. Also routes every audioPadTrim probe failure through one sanitizer at the boundary. runFfprobeJson scrubbed its own stderr, but defaultProbeVideoFrameInfo threw `no video stream in ${videoPath}` raw into the public PadTrimAudioResult.error, and an injected probe can throw anything. The redaction unit tests all passed with the caller wiring deleted; the new public-path regressions fail without it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent e79ab3a commit 255cf92

22 files changed

Lines changed: 155 additions & 24 deletions

File tree

‎packages/producer/src/services/distributed/assemble.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ function probeStream(
150150
"-count_packets",
151151
"-of",
152152
"json",
153+
"--",
153154
outputPath,
154155
],
155156
{ stdio: "pipe" },
@@ -418,6 +419,7 @@ describe("assemble()", () => {
418419
"stream=r_frame_rate,avg_frame_rate,duration",
419420
"-of",
420421
"json",
422+
"--",
421423
outputPath,
422424
],
423425
{ stdio: "pipe" },

‎packages/producer/src/services/render/audioPadTrim.integration.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ describe.skipIf(!hasFfmpeg)("audio pad real-media packet contract", () => {
6767
"packet=duration_time",
6868
"-of",
6969
"json",
70+
"--",
7071
output,
7172
],
7273
{ encoding: "utf8" },

‎packages/producer/src/services/render/audioPadTrim.test.ts‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,71 @@ describe("padOrTrimAudioToVideoFrameCount", () => {
270270
expect(result.targetDurationSeconds).toBe(6);
271271
});
272272
});
273+
274+
// ── Public-path path redaction ────────────────────────────────────────────
275+
//
276+
// The redaction helpers have their own unit tests, but those pass whether or
277+
// not this module actually CALLS them: deleting the wiring in
278+
// padOrTrimAudioToVideoFrameCount left every one of them green. These drive
279+
// the public entry point and assert on the public `PadTrimAudioResult.error`,
280+
// which is what reaches logs, telemetry, and the caller.
281+
describe("PadTrimAudioResult.error never carries the input path", () => {
282+
const cases: Array<{ name: string; videoPath: string; secret: string }> = [
283+
{
284+
name: "a dash-prefixed relative path",
285+
videoPath: "./assets/-customer-secret-intro.mp4",
286+
secret: "customer-secret-intro",
287+
},
288+
{
289+
name: "a non-allowlisted absolute root",
290+
videoPath: "/data/acme-secret/video.mp4",
291+
secret: "acme-secret",
292+
},
293+
{
294+
name: "a bare relative path",
295+
videoPath: "customer/acme-secret/video.mp4",
296+
secret: "acme-secret",
297+
},
298+
];
299+
300+
for (const { name, videoPath, secret } of cases) {
301+
it(`redacts ${name} raised by the video probe`, async () => {
302+
const result = await padOrTrimAudioToVideoFrameCount({
303+
videoPath,
304+
audioPath: "/tmp/audio.aac",
305+
outputPath: "/tmp/out.aac",
306+
// Reproduces the real thrower: defaultProbeVideoFrameInfo raises
307+
// `ffprobe found no video stream in ${videoPath}` with the raw path.
308+
probeVideoFrameInfo: () =>
309+
Promise.reject(new Error(`ffprobe found no video stream in ${videoPath}`)),
310+
probeAudioInfo: () => Promise.resolve({ durationSeconds: 1 }),
311+
runFfmpeg: () => Promise.resolve({ success: true }),
312+
});
313+
314+
expect(result.success).toBe(false);
315+
expect(result.error).toBeDefined();
316+
expect(result.error ?? "").not.toContain(secret);
317+
expect(result.error ?? "").not.toContain(videoPath);
318+
// Still diagnosable — the failure mode survives redaction.
319+
expect(result.error ?? "").toContain("failed to probe video");
320+
});
321+
}
322+
323+
it("redacts raw ffprobe stderr surfaced through the audio probe", async () => {
324+
const result = await padOrTrimAudioToVideoFrameCount({
325+
videoPath: "/tmp/v.mp4",
326+
audioPath: "/data/acme-secret/audio.aac",
327+
outputPath: "/tmp/out.aac",
328+
probeVideoFrameInfo: () => Promise.resolve({ frameCount: 30, fpsNum: 30, fpsDen: 1 }),
329+
probeAudioInfo: () =>
330+
Promise.reject(
331+
new Error("/data/acme-secret/audio.aac: Invalid data found when processing input"),
332+
),
333+
runFfmpeg: () => Promise.resolve({ success: true }),
334+
});
335+
336+
expect(result.success).toBe(false);
337+
expect(result.error ?? "").not.toContain("acme-secret");
338+
expect(result.error ?? "").toContain("failed to probe audio");
339+
});
340+
});

‎packages/producer/src/services/render/audioPadTrim.ts‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,25 @@ function formatSeconds(sec: number): string {
215215
return sec.toFixed(6);
216216
}
217217

218+
/**
219+
* Every probe failure message, sanitized once, at the one place they all pass
220+
* through on their way into the public `PadTrimAudioResult.error`.
221+
*
222+
* `runFfprobeJson` already scrubs the stderr it raises, but it is not the only
223+
* thrower: `defaultProbeVideoFrameInfo` raises
224+
* `ffprobe found no video stream in ${videoPath}` with the raw path, and a
225+
* caller-supplied `probeVideoFrameInfo` / `probeAudioInfo` can raise anything
226+
* at all. Sanitizing per-thrower is a list that will drift; sanitizing at the
227+
* boundary cannot be bypassed by adding a new throw upstream.
228+
*
229+
* Known paths first (this function has them in hand, so no pattern has to
230+
* recognise them), then the generic shape-based scrub for anything the message
231+
* picked up elsewhere.
232+
*/
233+
function sanitizeProbeFailure(message: string, paths: readonly string[]): string {
234+
return redactTelemetryString(redactKnownPaths(message, paths));
235+
}
236+
218237
/**
219238
* Pad or trim `audio.aac` so its exact duration matches `frameCount / fps`
220239
* for the assembled video.
@@ -235,20 +254,27 @@ export async function padOrTrimAudioToVideoFrameCount(
235254
probeAudio(input.audioPath, input.signal),
236255
]);
237256

257+
const probePaths = [input.videoPath, input.audioPath, input.outputPath];
238258
if (videoResult.status === "rejected") {
239259
return failResult(
240260
input.outputPath,
241261
0,
242262
audioResult.status === "fulfilled" ? audioResult.value.durationSeconds : 0,
243-
`audioPadTrim: failed to probe video: ${(videoResult.reason as Error).message}`,
263+
`audioPadTrim: failed to probe video: ${sanitizeProbeFailure(
264+
(videoResult.reason as Error).message,
265+
probePaths,
266+
)}`,
244267
);
245268
}
246269
if (audioResult.status === "rejected") {
247270
return failResult(
248271
input.outputPath,
249272
0,
250273
0,
251-
`audioPadTrim: failed to probe audio: ${(audioResult.reason as Error).message}`,
274+
`audioPadTrim: failed to probe audio: ${sanitizeProbeFailure(
275+
(audioResult.reason as Error).message,
276+
probePaths,
277+
)}`,
252278
);
253279
}
254280

‎packages/producer/src/utils/ffprobeArgvContract.test.ts‎

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ import { join, relative } from "node:path";
2020
* than needing to be remembered.
2121
*/
2222
const REPO_ROOT = join(import.meta.dirname, "..", "..", "..", "..");
23-
const PACKAGES = join(REPO_ROOT, "packages");
23+
24+
/**
25+
* Roots to sweep.
26+
*
27+
* `skills/` is here because leaving it out was not a scoping choice, it was a
28+
* hole: the shipped agent tools under `skills/**` spawn ffprobe directly, and
29+
* 17 of those call sites were missing the terminator while this suite reported
30+
* the bug class closed. They are distributed to users, not fixtures.
31+
*/
32+
const SWEEP_ROOTS = ["packages", "skills", "scripts"];
33+
34+
/** `.mjs`/`.cjs` are first-class here — the skill scripts are not TypeScript. */
35+
const SOURCE_EXT = /\.(?:ts|mjs|cjs|js)$/;
2436

2537
/**
2638
* The caller set as of the sweep that introduced this contract.
@@ -62,15 +74,25 @@ function mentionsProbe(src: string): boolean {
6274
// an opaquely-named variable (`spawn(command, argv)`) is invisible here.
6375
// Those still get caught by argv matching whenever their flags are literal —
6476
// widen this if one ever slips through both.
77+
// Comments and doc prose describing a spawn are not a spawn:
78+
// `tts.test.mjs` explains `ffprobeDuration's spawnSync("ffprobe", ...) call`
79+
// in a comment and was reported as an unclassified caller.
80+
const code = src.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "");
6581
return /(?:spawn|spawnSync|execFile\w*|exec)\s*\(\s*[^,)]*(?:ffprobe|ffProbe|probeBin|probePath)/i.test(
66-
src,
82+
code,
6783
);
6884
}
6985

7086
const SKIP_DIRS = new Set(["node_modules", "dist"]);
7187

7288
function isSourceFile(entry: string): boolean {
73-
return entry.endsWith(".ts") && !entry.includes(".test.");
89+
if (!SOURCE_EXT.test(entry) || entry.endsWith(".d.ts")) return false;
90+
// This file documents the contract with example argvs, including a
91+
// deliberately misordered one. Scanning itself reports its own prose.
92+
if (entry === "ffprobeArgvContract.test.ts") return false;
93+
// Test files are swept too. A test that probes a rendered output is itself a
94+
// caller, and `dither.test.mjs` was one of the 17 broken sites.
95+
return true;
7496
}
7597

7698
function discoverCallers(): { found: string[]; unclassified: string[] } {
@@ -94,12 +116,12 @@ function discoverCallers(): { found: string[]; unclassified: string[] } {
94116
else if (isSourceFile(entry)) classify(abs);
95117
}
96118
};
97-
for (const pkg of readdirSync(PACKAGES)) {
98-
const src = join(PACKAGES, pkg, "src");
119+
for (const root of SWEEP_ROOTS) {
120+
const abs = join(REPO_ROOT, root);
99121
try {
100-
if (statSync(src).isDirectory()) walk(src);
122+
if (statSync(abs).isDirectory()) walk(abs);
101123
} catch {
102-
/* package without src */
124+
/* root absent in a partial checkout */
103125
}
104126
}
105127
return { found: found.sort(), unclassified: unclassified.sort() };

‎packages/producer/tests/distributed/_smoke/webm-concat-copy.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ describe("webm VP9 concat-copy smoke", () => {
213213
"stream=codec_name,width,height,pix_fmt,r_frame_rate",
214214
"-of",
215215
"default=noprint_wrappers=1",
216+
"--",
216217
outputPath,
217218
]);
218219
if (result.exitCode !== 0) {
@@ -268,6 +269,7 @@ describe("webm VP9 concat-copy smoke", () => {
268269
"stream=nb_read_frames",
269270
"-of",
270271
"default=noprint_wrappers=1:nokey=1",
272+
"--",
271273
outputPath,
272274
]);
273275
if (result.exitCode !== 0) {
@@ -423,6 +425,7 @@ describe("webm VP9 concat-copy smoke (yuva420p alpha)", () => {
423425
"-select_streams",
424426
"v:0",
425427
"-show_streams",
428+
"--",
426429
alphaOutputPath,
427430
]);
428431
expect(probeResult.exitCode).toBe(0);

‎skills-manifest.json‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"source": "heygen-com/hyperframes",
33
"skills": {
44
"embedded-captions": {
5-
"hash": "ed4dc7b850b92ff5",
5+
"hash": "8e8bd824567c3e17",
66
"files": 140
77
},
88
"faceless-explainer": {
9-
"hash": "261a9740ec1378b0",
9+
"hash": "c70b904aa68cf7e5",
1010
"files": 24
1111
},
1212
"figma": {
13-
"hash": "517e4dc53c13ea05",
13+
"hash": "4f524b4962bd8d7c",
1414
"files": 2
1515
},
1616
"general-video": {
@@ -46,23 +46,23 @@
4646
"files": 10
4747
},
4848
"media-use": {
49-
"hash": "6c40be3e8bd6eacc",
49+
"hash": "6fedfe5fe57a9885",
5050
"files": 152
5151
},
5252
"motion-graphics": {
53-
"hash": "50db172cad89b1c7",
53+
"hash": "1434e22bb0259bbb",
5454
"files": 23
5555
},
5656
"music-to-video": {
5757
"hash": "55a2b5fdcd6f892c",
5858
"files": 132
5959
},
6060
"pr-to-video": {
61-
"hash": "41171bbed1c5d8f4",
61+
"hash": "7769801640dca521",
6262
"files": 30
6363
},
6464
"product-launch-video": {
65-
"hash": "01fc75da8492f749",
65+
"hash": "81953f054fcb9d91",
6666
"files": 28
6767
},
6868
"remotion-to-hyperframes": {

‎skills/embedded-captions/scripts/make-cinematic.cjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ function main() {
185185
"format=duration",
186186
"-of",
187187
"default=nokey=1:noprint_wrappers=1",
188+
"--",
188189
fp,
189190
],
190191
{ encoding: "utf8" },

‎skills/embedded-captions/scripts/make-composition.cjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function sourceDurationSec(project) {
5050
"format=duration",
5151
"-of",
5252
"default=nokey=1:noprint_wrappers=1",
53+
"--",
5354
p,
5455
],
5556
{ encoding: "utf8" },

‎skills/embedded-captions/scripts/matte.cjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function probeRates(src) {
8383
"stream=r_frame_rate,avg_frame_rate",
8484
"-of",
8585
"default=nk=1:nw=1",
86+
"--",
8687
src,
8788
])
8889
.toString()

0 commit comments

Comments
 (0)