@pnpm/fs.packlist 1100.0.7 → 1100.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/lib/index.js +12 -12
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @pnpm/fs.packlist
|
|
2
2
|
|
|
3
|
+
## 1100.0.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies:
|
|
8
|
+
- @pnpm/workspace.project-manifest-reader@1100.1.4
|
|
9
|
+
|
|
10
|
+
## 1100.0.8
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Prevent bundled dependencies from traversing escaping directory symlinks or packaging files outside the package root [pnpm/tasks#83](https://github.com/pnpm/tasks/issues/83) [pnpm/tasks#93](https://github.com/pnpm/tasks/issues/93).
|
|
15
|
+
|
|
16
|
+
- Updated dependencies:
|
|
17
|
+
- @pnpm/error@1100.2.2
|
|
18
|
+
- @pnpm/workspace.project-manifest-reader@1100.1.3
|
|
19
|
+
|
|
3
20
|
## 1100.0.7
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/lib/index.js
CHANGED
|
@@ -98,7 +98,7 @@ export async function packlistWithSources(pkgDir, opts) {
|
|
|
98
98
|
: undefined;
|
|
99
99
|
const files = (await walkPackage(tree, packlistOpts))
|
|
100
100
|
.map((file) => file.replace(/^\.[/\\]/, ''))
|
|
101
|
-
.filter((file) => isInternalFileOrSymlink(resolvedPkgDir, file));
|
|
101
|
+
.filter((file) => isInternalFileOrSymlink(resolvedPkgDir, file, boundary));
|
|
102
102
|
return mapToPackedPaths(resolvedPkgDir, files, packedDirs);
|
|
103
103
|
}
|
|
104
104
|
async function hasNpmIgnoreFile(pkgDir) {
|
|
@@ -122,16 +122,16 @@ async function walkPackage(tree, packlistOpts) {
|
|
|
122
122
|
function isEscapingRelativePath(rel) {
|
|
123
123
|
return rel === '..' || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel);
|
|
124
124
|
}
|
|
125
|
-
function isInternalFileOrSymlink(pkgDir, relFile) {
|
|
125
|
+
function isInternalFileOrSymlink(pkgDir, relFile, boundary = pkgDir) {
|
|
126
126
|
const absPath = path.join(pkgDir, relFile);
|
|
127
127
|
const lstat = lstatIfExists(absPath, ['ENOENT']);
|
|
128
128
|
if (lstat == null) {
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
131
|
if (!lstat.isSymbolicLink()) {
|
|
132
|
-
return
|
|
132
|
+
return !realTargetEscapes(boundary, absPath, false);
|
|
133
133
|
}
|
|
134
|
-
return isInternalSymlink(pkgDir, relFile, absPath);
|
|
134
|
+
return isInternalSymlink(pkgDir, relFile, absPath, boundary);
|
|
135
135
|
}
|
|
136
136
|
function lstatIfExists(filePath, missingCodes) {
|
|
137
137
|
try {
|
|
@@ -143,7 +143,7 @@ function lstatIfExists(filePath, missingCodes) {
|
|
|
143
143
|
throw err;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
function isInternalSymlink(pkgDir, relFile, absPath) {
|
|
146
|
+
function isInternalSymlink(pkgDir, relFile, absPath, boundary = pkgDir) {
|
|
147
147
|
let linkTarget = fs.readlinkSync(absPath);
|
|
148
148
|
if (path.isAbsolute(linkTarget)) {
|
|
149
149
|
linkTarget = path.relative(path.dirname(absPath), linkTarget);
|
|
@@ -156,7 +156,7 @@ function isInternalSymlink(pkgDir, relFile, absPath) {
|
|
|
156
156
|
if (isEscapingRelativePath(relToPkg)) {
|
|
157
157
|
return false;
|
|
158
158
|
}
|
|
159
|
-
return !realTargetEscapes(
|
|
159
|
+
return !realTargetEscapes(boundary, absPath, true);
|
|
160
160
|
}
|
|
161
161
|
function archivedLinkEscapes(relFile, linkTarget) {
|
|
162
162
|
const relPosix = process.platform === 'win32' ? relFile.replace(/\\/g, '/') : relFile;
|
|
@@ -167,17 +167,17 @@ function archivedLinkEscapes(relFile, linkTarget) {
|
|
|
167
167
|
const normalizedArchive = path.posix.normalize(path.posix.join(path.posix.dirname(relPosix), posixTarget));
|
|
168
168
|
return normalizedArchive === '..' || normalizedArchive.startsWith('../');
|
|
169
169
|
}
|
|
170
|
-
function realTargetEscapes(
|
|
170
|
+
function realTargetEscapes(boundary, absPath, isSymlink = true) {
|
|
171
|
+
const realBoundary = realpathOrUndefined(boundary) ?? boundary;
|
|
171
172
|
try {
|
|
172
173
|
const realTarget = fs.realpathSync(absPath);
|
|
173
|
-
|
|
174
|
-
return isEscapingRelativePath(path.relative(realPkgDir, realTarget));
|
|
174
|
+
return isEscapingRelativePath(path.relative(realBoundary, realTarget));
|
|
175
175
|
}
|
|
176
176
|
catch (err) {
|
|
177
177
|
if (!isError(err) || !('code' in err) || err.code !== 'ENOENT') {
|
|
178
178
|
throw err;
|
|
179
179
|
}
|
|
180
|
-
return
|
|
180
|
+
return !isSymlink;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
function mapToPackedPaths(pkgDir, files, packedDirs) {
|
|
@@ -208,7 +208,7 @@ function mapToPackedPaths(pkgDir, files, packedDirs) {
|
|
|
208
208
|
* separately by packedLocation().
|
|
209
209
|
*/
|
|
210
210
|
function buildRootTree(pkgDir, pkg, boundary) {
|
|
211
|
-
const bundledDeps = getRootBundledDeps(pkg);
|
|
211
|
+
const bundledDeps = getRootBundledDeps(pkg).filter(isSafeBundleName);
|
|
212
212
|
// npm-packlist's gatherBundles() iterates package.bundleDependencies directly,
|
|
213
213
|
// so the field must be an array. Normalize true/undefined to an explicit list.
|
|
214
214
|
const normalizedPkg = normalizePackage(pkg);
|
|
@@ -340,7 +340,7 @@ function getRootBundledDeps(pkg) {
|
|
|
340
340
|
function getNestedBundledDeps(pkg) {
|
|
341
341
|
const dependencies = (pkg.dependencies ?? {});
|
|
342
342
|
const optionalDependencies = (pkg.optionalDependencies ?? {});
|
|
343
|
-
return [...Object.keys(dependencies), ...Object.keys(optionalDependencies)];
|
|
343
|
+
return [...Object.keys(dependencies), ...Object.keys(optionalDependencies)].filter(isSafeBundleName);
|
|
344
344
|
}
|
|
345
345
|
function resolveDependency(depName, fromDir, boundary) {
|
|
346
346
|
if (!isSafeBundleName(depName))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/fs.packlist",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.9",
|
|
4
4
|
"description": "Get a list of the files to add from a directory into an npm package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"!*.map"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@pnpm/error": "1100.2.
|
|
31
|
-
"@pnpm/workspace.project-manifest-reader": "1100.1.
|
|
30
|
+
"@pnpm/error": "1100.2.2",
|
|
31
|
+
"@pnpm/workspace.project-manifest-reader": "1100.1.4",
|
|
32
32
|
"is-subdir": "^2.0.1",
|
|
33
33
|
"npm-packlist": "10.0.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@pnpm/fs.packlist": "1100.0.
|
|
36
|
+
"@pnpm/fs.packlist": "1100.0.9"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=22.13"
|