Repository navigation
fix(@angular/build): use isSubDirectory in normalizeAssetPatterns and ignore nested .gitkeep - #34420
Conversation
… ignore nested .gitkeep - Replace `.startsWith(...)` prefix checks in `normalizeAssetPatterns` with `isSubDirectory(...)` so sibling directories sharing a prefix with `sourceRoot`, `projectRoot`, or `workspaceRoot` (such as `src-assets` when `sourceRoot` is `src`) are resolved against the proper parent directory instead of producing a `..` output path error. - Update `DEFAULT_ASSET_IGNORE` in `resolve-assets.ts` from `'.gitkeep'` to `'**/.gitkeep'` so nested `.gitkeep` files are also ignored, matching `'**/.DS_Store'` and `'**/Thumbs.db'`. - Validate that resolved asset `destination` paths in `resolveAssets` do not escape the output root via `..`.
…rns and ignore nested .gitkeep
There was a problem hiding this comment.
Code Review
This pull request enhances asset path normalization and resolution by utilizing isSubDirectory checks and introducing a resolveDestination helper to prevent assets from escaping the output directory. It also updates the default asset ignore patterns to ignore .gitkeep files globally and adds comprehensive unit tests. Feedback was provided regarding a potential path traversal vulnerability on Windows if the destination path becomes absolute, suggesting an additional check for absolute paths to prevent escaping the output directory.
…rns and ignore nested .gitkeep
…rns and ignore nested .gitkeep
…rns and ignore nested .gitkeep
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Summary
.startsWith(...)checks innormalizeAssetPatternswithisSubDirectory(...)to prevent sibling directory prefix collisions (e.g.src-assetswhensourceRootissrc).'.gitkeep'to'**/.gitkeep'inDEFAULT_ASSET_IGNORE(resolve-assets.ts) so.gitkeepfiles in nested subdirectories are also ignored.resolveAssetsthat resolveddestinationpaths do not escape the output root via..(e.g. whenglobcontains..).