docs: say what the path and input checks do - #93
Merged
Merged
Conversation
SECURITY.md said that the save directory cannot be absolute or contain `..`, and that file name patterns cannot contain shell metacharacters. Both are reported as configuration warnings, not refused. What keeps the saved image inside the workspace is the check against the workspace's real path: it refuses a save directory that leads outside, and lets one whose `..` stays inside resolve to the folder it names. The sections now say so, the code sample follows the check as it is written, and the file name sanitizing is described as it is: control characters and the characters a Windows file name cannot hold are removed, and on Windows a reserved name is prefixed. The comment in sanitizeConfiguration said fileName.pattern keeps only safe characters, a filter the code does not apply; it now says what happens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Makes SECURITY.md describe the path and input checks as the code does them.
Why
SECURITY.md said that the save directory "cannot be absolute or contain
.." and that file name patterns "cannot contain shell metacharacters". Neither is refused:validateSaveDirectoryandvalidateFileNamePatternfeed the configuration warnings in the ClipShot log. The protection is real but elsewhere, and the page should point at it rather than at the warnings.src/image/file-writer.tscallsvalidatePathInsideWorkspaceon the target file before writing it (writeAtomic) and on a folder before creating it (ensureDir).validatePathInsideWorkspaceresolves the workspace root and the existing part of the target throughrealpath, then refuses a path whose relation to the root starts with..or is absolute.path.join(workspaceRoot, saveDirectory, fileName)(src/image/path-generator.ts), so a..that stays inside the workspace resolves to the folder it names.sanitizeFileName(src/security/sanitizer.ts) removes control characters and< > : " / \ | ? *from each generated name, and on Windows prefixes a reserved name; it leaves other shell metacharacters, which only the warning reports.Change
validatePathInsideWorkspace.sanitizeConfigurationno longer claims a filter onfileName.patternthat the code does not apply.Verification
npm run lint,npm run compile, the configuration tests.🤖 Generated with Claude Code