Repository navigation
fix(cli): grade-compare opens a grades file's LUT paths only inside the project - #8724
Conversation
vanceingalls
left a comment
There was a problem hiding this comment.
Checked at e1a0ca1. lutSourcePath refuses a rooted path (UNC, //host, \?, drive, absolute) or a ../ climb from the text alone before any file call, then requires a realpath-inside-project check (separator-aware) and statSync().isFile() for grades-file paths. --luts keeps resolveFromBase, and the media-use candidates filter uses the same recordPathInProject rule. The named tests cover each escape case, the link and the FIFO, and the refusal is a plain Error with a clear message. Two non-blocking notes: existsSync runs on the in-project path before links are resolved, so a project symlink pointing at a UNC path is still touched once, and there is a small check-to-read window with no comment saying so. All checks are green.
What
hyperframes grade-compare --grades <file>now opens a LUT path from the grades file only when it names a regular file inside the project. A rooted path (\\host\share\…,//host/share/…,\\?\…, another drive, an absolute path) or one that climbs out (../…) is refused from its text alone, before any file call. A path that leaves the project through a link, or names something other than a regular file (a FIFO, a device), is refused too. LUT paths typed with--lutsbehave as before.media-use resolve --candidatesnow lists a project record's path only when it is inside the project, so a manifest path pointing elsewhere is not handed on togrades.json.Why
A grades file is project data: it travels with the project folder, and the documented flow builds it from the project's
.media/manifest.jsonl.prepareGradeCompareTempProjectresolved its LUT paths withresolveFromBase, which keeps any absolute value, then calledexistsSync,readFileSyncandcopyFileSyncon the result. On Windows, merely checking whether\\host\share\x.cubeexists signs in to that host. On any OS, a FIFO path blocks the read for good.Related work
None.
How
lutSourcePathinpackages/cli/src/commands/grade-compare.tsreuses the in-project rulemedia-use resolvealready applies to manifest records (packages/cli/src/media-use/lib/record-path.mjs). It callsrecordPathInProjectfirst, which judges the text alone, theninsideProjectonce links are resolved, plusstatSync(...).isFile(). The command passeslutPathsTypedWithLutsFlagonly for--luts, so typed paths keepresolveFromBase.listCandidatesinpackages/cli/src/media-use/lib/candidates.mjsshows a project record'spathonly whenrecordPathInProjectaccepts it, andnullotherwise.record-path.d.mtsdeclares the two helpers for TypeScript, like the other media-use.d.mtsfiles.No visible change
Command-line behaviour only; a grades file with in-project LUT paths renders as before.
Test plan
fails without the fix:
packages/cli/src/commands/grade-compare.lutPaths.test.tswrapsnode:fsin pass-through spies.refuses %s before any file call on itcovers UNC,//host/share,\\?\, another drive and../. The file also hasrefuses an absolute path outside the project, though the file is a valid .cube,refuses a link in the project that leads out of itandrefuses a FIFO in the project without reading it. With main'sgrade-compare.ts, 7 of these fail, and the FIFO case blocks the run until it is killed. With the fix, 10 of 10 pass, includingstill stages a LUT inside the projectandkeeps a typed --luts path as given.lists a project record's path only when it is inside the projectinpackages/cli/src/media-use/lib/candidates.test.mjsfails with main'scandidates.mjs(1 of 9) and passes with the fix (9 of 9).grade-compare.test.ts(26),record-path.test.mjs(19) andresolve.test.mjspass, as do clitscand fallow.