Skip to content

Commit 9ccff72

Browse files
committed
deps: tar@6.2.1
1 parent 7201a00 commit 9ccff72

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

node_modules/tar/lib/unpack.js

+22-5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const crypto = require('crypto')
4848
const getFlag = require('./get-write-flag.js')
4949
const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform
5050
const isWindows = platform === 'win32'
51+
const DEFAULT_MAX_DEPTH = 1024
5152

5253
// Unlinks on Windows are not atomic.
5354
//
@@ -181,6 +182,12 @@ class Unpack extends Parser {
181182
this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ?
182183
process.getgid() : null
183184

185+
// prevent excessively deep nesting of subfolders
186+
// set to `Infinity` to remove this restriction
187+
this.maxDepth = typeof opt.maxDepth === 'number'
188+
? opt.maxDepth
189+
: DEFAULT_MAX_DEPTH
190+
184191
// mostly just for testing, but useful in some cases.
185192
// Forcibly trigger a chown on every entry, no matter what
186193
this.forceChown = opt.forceChown === true
@@ -238,13 +245,13 @@ class Unpack extends Parser {
238245
}
239246

240247
[CHECKPATH] (entry) {
248+
const p = normPath(entry.path)
249+
const parts = p.split('/')
250+
241251
if (this.strip) {
242-
const parts = normPath(entry.path).split('/')
243252
if (parts.length < this.strip) {
244253
return false
245254
}
246-
entry.path = parts.slice(this.strip).join('/')
247-
248255
if (entry.type === 'Link') {
249256
const linkparts = normPath(entry.linkpath).split('/')
250257
if (linkparts.length >= this.strip) {
@@ -253,11 +260,21 @@ class Unpack extends Parser {
253260
return false
254261
}
255262
}
263+
parts.splice(0, this.strip)
264+
entry.path = parts.join('/')
265+
}
266+
267+
if (isFinite(this.maxDepth) && parts.length > this.maxDepth) {
268+
this.warn('TAR_ENTRY_ERROR', 'path excessively deep', {
269+
entry,
270+
path: p,
271+
depth: parts.length,
272+
maxDepth: this.maxDepth,
273+
})
274+
return false
256275
}
257276

258277
if (!this.preservePaths) {
259-
const p = normPath(entry.path)
260-
const parts = p.split('/')
261278
if (parts.includes('..') || isWindows && /^[a-z]:\.\.$/i.test(parts[0])) {
262279
this.warn('TAR_ENTRY_ERROR', `path contains '..'`, {
263280
entry,

node_modules/tar/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "GitHub Inc.",
33
"name": "tar",
44
"description": "tar for node",
5-
"version": "6.2.0",
5+
"version": "6.2.1",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/isaacs/node-tar.git"

package-lock.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
"spdx-expression-parse": "^3.0.1",
152152
"ssri": "^10.0.5",
153153
"supports-color": "^9.4.0",
154-
"tar": "^6.2.0",
154+
"tar": "^6.2.1",
155155
"text-table": "~0.2.0",
156156
"tiny-relative-date": "^1.3.0",
157157
"treeverse": "^3.0.0",
@@ -14808,9 +14808,9 @@
1480814808
}
1480914809
},
1481014810
"node_modules/tar": {
14811-
"version": "6.2.0",
14812-
"resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz",
14813-
"integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==",
14811+
"version": "6.2.1",
14812+
"resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz",
14813+
"integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==",
1481414814
"inBundle": true,
1481514815
"dependencies": {
1481614816
"chownr": "^2.0.0",
@@ -16153,7 +16153,7 @@
1615316153
"minimatch": "^9.0.4",
1615416154
"npm-package-arg": "^11.0.1",
1615516155
"pacote": "^17.0.4",
16156-
"tar": "^6.2.0"
16156+
"tar": "^6.2.1"
1615716157
},
1615816158
"devDependencies": {
1615916159
"@npmcli/eslint-config": "^4.0.0",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"spdx-expression-parse": "^3.0.1",
115115
"ssri": "^10.0.5",
116116
"supports-color": "^9.4.0",
117-
"tar": "^6.2.0",
117+
"tar": "^6.2.1",
118118
"text-table": "~0.2.0",
119119
"tiny-relative-date": "^1.3.0",
120120
"treeverse": "^3.0.0",

workspaces/libnpmdiff/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"minimatch": "^9.0.4",
5555
"npm-package-arg": "^11.0.1",
5656
"pacote": "^17.0.4",
57-
"tar": "^6.2.0"
57+
"tar": "^6.2.1"
5858
},
5959
"templateOSS": {
6060
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",

0 commit comments

Comments
 (0)