fix(engine): harden ffprobe parsing and command arguments#2740
fix(engine): harden ffprobe parsing and command arguments#2740santhiprakash wants to merge 1 commit into
Conversation
939901e to
e740f1c
Compare
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed packages/engine/src/utils/ffprobe.ts end-to-end at HEAD (e740f1c) plus the new tests. No prior reviews/comments on the PR.
Strengths
parseFrameRate(fix #1, ~L239) is correct and thoroughly table-tested —Number.isFiniteon both operands +den !== 0, with"30/","30/0","0/0","abc/def", and bare"60"all pinned.0is the right fallback: downstreamavgFps || rFpsand the still-image path already toleratefps: 0, whereasNaNpoisoned every frame-count calc.- cICP ordering (fix #3, L184/L208) is correct — the color space is stashed in a local and only emitted once IHDR supplies valid dims. Handles cICP-before-IHDR, normal cICP-after-IHDR, and cICP-with-no-IHDR (→
null). All three covered by the new test.
Blocker
- Fix #2 is incomplete. The PR body says "Every
runFfprobeinvocation now inserts--before the user-suppliedfilePath," but the AAC packet-count probe misses it —ffprobe.ts:388passesfilePathbare (right after-print_format json). Three of the four call sites got--(L274, L366, L457); this fourth did not. So the same audio file at a--prefixed path is separator-protected on the main audio probe (L366) but not on the AAC sub-probe just below it — the exact arg-injection class this PR sets out to close, left open on one path. The"uses -- for audio and keyframe probes too"test can't catch it because the audio fixture ispcm_s16le, so theif (audioCodec === "aac")branch never executes (it asserts 2--, not 3).
Fix: add"--"beforefilePathat L388, and add anaac-codec case to that test so the count becomes 3.
Important — merge-readiness, not code
- CI has not actually run. Every real job — CI, regression, preview-regression, Player perf, CodeQL, Windows render verification — is in
action_required(0s, awaiting maintainer approval to run); the only completed check isWIP(pass). So the body's claim that the 3 LFS-fixture tests "pass in CI with the LFS object" is currently unverified — nothing green confirms it, and this is why the PR showsBLOCKED. A maintainer needs to approve the workflow runs and confirm the vitest CI job (with thehdr-photo-pq.pngLFS object) is green before merge.
Verdict: REQUEST CHANGES
Reasoning: Fixes #1 and #3 are correct and well-tested, but the headline command-arg hardening (#2) misses the AAC packet-count call site — so the "every invocation" claim is false and the injection path stays open there — and CI hasn't executed, so the test-pass claim is unconfirmed.
— Jerrai
| const probePromise = (async (): Promise<AudioMetadata> => { | ||
| const stdout = await runFfprobe( | ||
| ["-v", "quiet", "-print_format", "json", "-show_format", "-show_streams", filePath], | ||
| ["-v", "quiet", "-print_format", "json", "-show_format", "-show_streams", "--", filePath], |
There was a problem hiding this comment.
Fix is incomplete: the AAC packet-count sub-probe a few lines down (ffprobe.ts:388, inside if (audioCodec === "aac" && sampleRate > 0)) still passes filePath bare — no --. The same audio file at a --prefixed path is separator-protected on this probe but not on that one, which contradicts the PR body's "every runFfprobe invocation" claim. The "uses -- for audio and keyframe probes too" test can't catch it because its fixture is pcm_s16le (the aac branch never runs). Add "--" before filePath at L388, plus an aac case that bumps the assertion to 3 --.
e740f1c to
b4a2a4a
Compare
- parseFrameRate now rejects malformed ratios (e.g. "30/", "30/0") instead of NaN. - Add "--" before file paths so names starting with "-" are not parsed as options. - cICP PNG chunk no longer returns before IHDR supplies width and height. - Add regression tests for option injection, frame rates, and cICP ordering.
b4a2a4a to
6575caf
Compare
|
Good catch — I missed the |
What
Hardens
packages/engine/src/utils/ffprobe.tsagainst three edge cases:"30/","30/0","abc/def") were returningNaNfromparseFrameRate.-were passed as bare arguments to ffprobe, which can be misinterpreted as option flags.cICPcolor-space handler returned immediately, so acICPchunk seen beforeIHDRcould emitwidth: 0, height: 0.Why
These bugs caused downstream metadata (
fps,colorSpace) to becomeNaN/null or, in the path case, allowed accidental option injection when user-provided paths begin with a dash.How
parseFrameRatenow checksNumber.isFiniteon both numerator and denominator and requiresden !== 0; invalid ratios fall back to0instead ofNaN.runFfprobeinvocation now inserts--before the user-suppliedfilePath.extractPngMetadataFromBufferstores anycICPcolor space in a local variable and only emits it afterIHDRhas supplied valid width/height.Test plan
Ran
bunx vitest run src/utils/ffprobe.test.tsandbunx oxlint/bunx oxfmt --checkon the changed files. Three existing fixture-dependent tests fail locally becausehdr-photo-pq.pngis stored via Git LFS and is not present in this working tree; they pass in CI with the LFS object.