Skip to content

fix(cli): project links are read, not followed, before a LUT path is judged inside the project - #8783

Open
miguel-heygen wants to merge 1 commit into
mainfrom
fix/project-links-read-only
Open

miguel-heygen wants to merge 1 commit into
mainfrom
fix/project-links-read-only

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

When a grades file names a LUT path that is a link inside the project, grade-compare and the media-use scripts now read the link's own text to decide where it leads, and refuse it if it leads out of the project, without ever opening the place it points to.

Why

The inside-the-project check asked whether the path existed and where it really was. Both calls follow the link to its target first, so a link to a file on another machine was opened before the check said no. On Windows, opening a network share path signs in to that machine. The check now reads links instead of following them, so nothing outside the project is touched while it decides.

Related work

Follows #8724, which made grade-compare open a grades file's LUT paths only inside the project. A review note on that PR asked for this.

How

  • insideProject in media-use/lib/record-path.mjs walks the path one part at a time with lstat, and at a link reads it with readlink and continues from what it names, up to 40 links, so a loop of links ends in a refusal.
  • grade-compare runs that check before it asks whether the LUT file exists, so a path that leads out is refused before anything opens it.

No visible change

grade-compare output is the same; only a link leading out of the project is now refused without being opened.

Test plan

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

fails without the fix: with main's record-path.mjs and grade-compare.ts, in packages/cli/src/media-use/lib/record-path.test.mjs a link in the project to a share is refused with only its own text read, a link in the project to another file in it is followed and a loop of links is refused fail, and in packages/cli/src/commands/grade-compare.lutPaths.test.ts refuses a link in the project that leads out of it, reading only the link fails. With the fix, 3 runs in a row: record-path and resolve 23, grade-compare 36. The CLI type check and fallow are clean.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant