Repository navigation
fix(importer): keep imports inside the download folder and refuse symlink sources - #4083
Merged
Merged
Conversation
…link sources Hardening: the client file list was checked for a symlink only on the last path component, so a directory symlink inside a download could name a book outside it. Files that resolve outside the download root are now skipped, and the copy opens its source with O_NOFOLLOW and requires a regular file (Lstat-based on Windows). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
vavallee
added a commit
that referenced
this pull request
Nov 20, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
vavallee
added a commit
that referenced
this pull request
Nov 20, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com> Signed-off-by: Vincent <vavallee@protonmail.com>
vavallee
force-pushed
the
fix/importer-symlink-dir
branch
from
November 20, 2026 00:38
c4f7344 to
b408fb7
Compare
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
vavallee
force-pushed
the
fix/importer-symlink-dir
branch
from
November 20, 2026 00:38
b408fb7 to
f16ebc6
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…es not move (#4083) Open the copy source inline with a build-tagged no-follow flag instead of through a helper in a new file. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: vavallee <vavallee@protonmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardening for the import path. The download client's file list was checked for a symlink only on the last path component, so a directory symlink inside a download (torrent, or an extracted archive) could name a book-extension file outside it.
copyFileModeCtxopens the source withO_NOFOLLOWand requires a regular file on the open handle. Windows has noO_NOFOLLOW, so a build-tagged helper Lstats first (GOOS=windows go vetpasses).copyFileModeCtx, so a symlinked library file is no longer copied through by that fallback.Test plan
source_confine_test.go: a symlinked directory to an outside tempdir holding an.epubis refused; a nested real directory, internal links and a linked root still import; copy refuses a symlink or directory source.TestDiscoverBookFiles_DirectorySymlinkOutsideDownloadRefusedandTestCopyFile_RefusesSymlinkSourcefail on main's code, pass with the change.go test -p 2 ./internal/importerand golangci-lint on importer and api pass.🤖 Generated with Claude Code