Prevent path traversal in --coverage-dir argument#78
Merged
bartveneman merged 2 commits intomainfrom Mar 12, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #78 +/- ##
==========================================
+ Coverage 96.49% 96.52% +0.03%
==========================================
Files 14 14
Lines 1026 1035 +9
Branches 118 120 +2
==========================================
+ Hits 990 999 +9
Misses 34 34
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 174 bytes (0.66%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: cli.js-esmAssets Changed:
Files in
|
Resolve the provided path to an absolute path and verify it stays within process.cwd(), rejecting any value that would escape the current working directory via ../ sequences. https://claude.ai/code/session_01SoGLdxJCSsRPACjf6uLuyR
bb08b50 to
e727bb3
Compare
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
Add path traversal protection to the
--coverage-dirCLI argument to ensure coverage directories cannot escape the current working directory.Key Changes
CoverageDirSchemato resolve relative paths and validate they stay within the current working directory--coverage-dirvalues are now resolved to absolute paths usingresolve()../../etc,../sibling)Implementation Details
The validation uses
process.cwd()as the security boundary. Paths are accepted only if they:This prevents directory traversal attacks while still allowing relative paths like
coverageor./path/to/coveragethat resolve within the project.https://claude.ai/code/session_01SoGLdxJCSsRPACjf6uLuyR
closes #75