fix(core): prevent workspace deletion in cleanOutput method (Fixes #57)#60
Merged
Conversation
added 2 commits
September 11, 2025 16:17
Prevent cleanOutput from deleting workspace root when given empty or
dangerous paths. This fixes a critical security vulnerability where
empty relOutputPath would cause deletion of the entire workspace.
- Add validation for empty, whitespace-only, root ('/') and current ('.') paths
- Throw descriptive error for unsafe paths
- Resolves security issue in base-generator
Refs #57
Replace dangerous tests that expected unsafe paths to work with comprehensive tests that verify security validation throws errors: - Replace empty path test with error expectation test - Add tests for whitespace-only, root, and current directory paths - Replace root directory test with valid nested path test - Ensure rmSync is not called when validation fails These tests verify the security fix prevents workspace deletion. Refs #57
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
Fixes a critical security vulnerability in the
BaseGenerator.cleanOutput()method that could cause catastrophic data loss.The Problem
cleanOutput()method would delete the entire workspace root directory when given an emptyrelOutputPathjoin(ctx.root, '')returns justctx.root, causingrmSyncto delete everything in the workspaceThe Solution
'')' ')'/')'.')'Cannot clean empty or root output path for safety reasons'Changes Made
Test Coverage
Risk Assessment
Closes #57
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com