feat: honor MARKITDOWN_SAFE_DIRS env var for configurable safe directories#39
Open
kdjkdjkdj wants to merge 1 commit into
Open
feat: honor MARKITDOWN_SAFE_DIRS env var for configurable safe directories#39kdjkdjkdj wants to merge 1 commit into
kdjkdjkdj wants to merge 1 commit into
Conversation
…dn#38) The hardcoded safe-directory list (Path.cwd, ~/Documents, ~/Downloads, ~/Desktop, ~/tmp, tempdir, tests/fixtures) is too restrictive for real-world use: OneDrive / SharePoint / Dropbox sync roots, NAS mounts, and project directories on non-system drives are all outside it, and there is no way to add them. Read MARKITDOWN_SAFE_DIRS (os.pathsep separated, so ":" on Unix and ";" on Windows) and append each existing path to the safe-dir list. Non-existent entries are logged at WARNING so typos don't silently disappear. Paths are resolved via Path.resolve() so the existing prefix-based security check continues to work against ".." inputs. Refs: trsdn#38 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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.
Closes #38.
Adds support for the
MARKITDOWN_SAFE_DIRSenv variable, anos.pathsep-separated list of absolute paths appended to the safe-directory list. Rationale and security notes in #38.Behavior
:on Unix,;on Windows (viaos.pathsep).WARNING, skipped.Path.resolve()so the existing prefix-based safety check continues to handle..inputs correctly.Parallel to #37
This branch is cut from
main(not from the #37 branch) so the PRs are reviewable independently. The only textual overlap with #37 is insideget_safe_working_directories(); once one of the two lands, the other rebases trivially.