Skip to content

Cross file-system path handling - #8227

Merged
labkey-matthewb merged 5 commits into
developfrom
fb_docker_tar
Oct 29, 2026
Merged

labkey-matthewb merged 5 commits into
developfrom
fb_docker_tar

Conversation

@labkey-matthewb

@labkey-matthewb labkey-matthewb commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Rationale

Fix associated issue with cross filesystem character handling.
Some scope creep refactor, cleanup, and test in FileSystem.

Related Pull Requests

Changes

  • Each path part must map to exactly one file name on the local file system; a part the OS would split or treat as a root (e.g. \ or a drive prefix on Windows) is rejected instead of silently re-split.
  • Invalid path references are reported consistently and API actions return 404 for them.
  • Files copied back from a Docker R container are confined to the report's working directory.
  • Helpers that wrap a File or nio path as a FileLike split the relative path into parts rather than passing it as one name.
  • New tests for path resolution, file wrapping, and error status mapping.

@labkey-jeckels labkey-jeckels left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with a couple of suggestions that seem important before merging.

{
throw new FileUtil.InvalidPathReferenceException(part, x.getReason());
}
if (name.getRoot() != null || name.getNameCount() != 1 || ".".equals(part) || "..".equals(part))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good strengthening but three callers that probably need matching updates:

  • DiscvrLabKeyModules SequenceAnalysisController.java:1076 and :2234: resolveFile(new Path(form.getPath()))
  • snprcEHRModules FeeScheduleController.java:176: allowedRoot.resolveFile(new Path(relativeURI.getPath())), the same pattern this PR fixed in FileSystemLike.getVerifiedFileLike

Could those switch to Path.parse(...) in companion PRs?

assertEquals("b.txt", a.resolveFile(new Path("b.txt")).getName());

// a Path part is a single file name, never a path
for (String name : new String[] {"../x", "a/../../x", "a/b", "/x"})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve(fs) runs from vfs() as well as nio(), but only FileSystemLocal validates each part.

FileSystemVFS.resolveFile resolves "a/b" and "../x" through commons-vfs and can only throw IllegalArgumentException/UnexpectedException.

Could the single-file-name check move into shared code (e.g. AbstractFileLike.resolvePath) so FileSystemVFS and FileSystemBlobStore enforce it too? That also lets FileSystemVFS.resolveFile throw InvalidPathReferenceException too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check on this. I focussed on FileSystemLocal because the root issue is local windows fs supporting an alternate path separator in nio.Path. Not sure this applies anywhere else.

@labkey-matthewb
labkey-matthewb merged commit fb7e4c1 into develop Oct 29, 2026
6 of 9 checks passed
@labkey-matthewb
labkey-matthewb deleted the fb_docker_tar branch October 29, 2026 21:52
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.

2 participants