fix: prevent directory.man referencing outside the package root#104
Merged
fix: prevent directory.man referencing outside the package root#104
directory.man referencing outside the package root#104Conversation
directory.man referencing outside the package root
wraithgar
approved these changes
May 24, 2024
Contributor
|
Tests would normally be required but this use case is covered in #100 which we'll be landing next. |
wraithgar
pushed a commit
that referenced
this pull request
May 24, 2024
## What / Why Aligns normalization logic with `directories.bin` See also: https://github.com/npm/normalize-package-data/blob/main/lib/fixer.js#L105 ```js fixManField: function (data) { if (!data.man) { return } if (typeof data.man === 'string') { data.man = [data.man] } }, ``` ## References * continues npm/read-package-json#177 * relates #104 CC @wraithgar
wraithgar
pushed a commit
that referenced
this pull request
May 24, 2024
Aligns normalization logic with `directories.bin` See also: https://github.com/npm/normalize-package-data/blob/main/lib/fixer.js#L105 ```js fixManField: function (data) { if (!data.man) { return } if (typeof data.man === 'string') { data.man = [data.man] } }, ``` * continues npm/read-package-json#177 * relates #104 CC @wraithgar
wraithgar
pushed a commit
that referenced
this pull request
May 24, 2024
wraithgar
pushed a commit
that referenced
this pull request
May 24, 2024
Aligns normalization logic with `directories.bin` See also: https://github.com/npm/normalize-package-data/blob/main/lib/fixer.js#L105 ```js fixManField: function (data) { if (!data.man) { return } if (typeof data.man === 'string') { data.man = [data.man] } }, ``` * continues npm/read-package-json#177 * relates #104 CC @wraithgar
Merged
wraithgar
pushed a commit
that referenced
this pull request
May 28, 2024
## What / Why
* Aligns path normalization logic when processing `bin` and `man` refs.
* Fixes out of scope path traversals for `bin`
```js
function unixifyPath (ref) {
return ref.replace(/\\|:/g, '/')
}
function securePath (ref) {
const secured = path.join('.', path.join('/', unixifyPath(ref)))
return secured.startsWith('.') ? '' : secured
}
function secureAndUnixifyPath (ref) {
return unixifyPath(securePath(ref))
}
```
## References
continues
[#100](#100 (comment)),
#104
wraithgar
pushed a commit
that referenced
this pull request
May 29, 2024
🤖 I have created a release *beep* *boop* --- ## [5.1.1](v5.1.0...v5.1.1) (2024-05-28) ### Bug Fixes * [`54756d2`](54756d2) [#105](#105) apply `securePath` to package bin (#105) (@antongolub) * [`46c563b`](46c563b) add `normalizePackageMan` helper (#100) (@antongolub) * [`a974274`](a974274) prevent `directory.man` referencing outside the package root (#104) (@antongolub) * [`191b521`](191b521) [#102](#102) invalid scripts warning fixed for undefined scripts (#102) (@milaninfy) ### Chores * [`45a2937`](45a2937) [#98](#98) bump @npmcli/template-oss to 4.22.0 (@lukekarrys) * [`90863c1`](90863c1) [#98](#98) postinstall for dependabot template-oss PR (@lukekarrys) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
What / Why
The current
directories.manhandler allows to reach assets outside the package scope.References
normalizePackageManhelper #100