You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

tar

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tar - npm Package Compare versions

Comparing version
7.5.4
to
7.5.5
+32
-11
dist/commonjs/unpack.js

@@ -256,18 +256,39 @@ "use strict";

[STRIPABSOLUTEPATH](entry, field) {
const path = entry[field];
if (!path || this.preservePaths)
const p = entry[field];
if (!p || this.preservePaths)
return true;
const parts = path.split('/');
const parts = p.split('/');
if (parts.includes('..') ||
/* c8 ignore next */
(isWindows && /^[a-z]:\.\.$/i.test(parts[0] ?? ''))) {
this.warn('TAR_ENTRY_ERROR', `${field} contains '..'`, {
entry,
[field]: path,
});
// not ok!
return false;
// For linkpath, check if the resolved path escapes cwd rather than
// just rejecting any path with '..' - relative symlinks like
// '../sibling/file' are valid if they resolve within the cwd.
// For paths, they just simply may not ever use .. at all.
if (field === 'path') {
this.warn('TAR_ENTRY_ERROR', `${field} contains '..'`, {
entry,
[field]: p,
});
// not ok!
return false;
}
else {
// Resolve linkpath relative to the entry's directory.
// `path.posix` is safe to use because we're operating on
// tar paths, not a filesystem.
const entryDir = node_path_1.default.posix.dirname(entry.path);
const resolved = node_path_1.default.posix.normalize(node_path_1.default.posix.join(entryDir, p));
// If the resolved path escapes (starts with ..), reject it
if (resolved.startsWith('../') || resolved === '..') {
this.warn('TAR_ENTRY_ERROR', `${field} escapes extraction directory`, {
entry,
[field]: p,
});
return false;
}
}
}
// strip off the root
const [root, stripped] = (0, strip_absolute_path_js_1.stripAbsolutePath)(path);
const [root, stripped] = (0, strip_absolute_path_js_1.stripAbsolutePath)(p);
if (root) {

@@ -278,3 +299,3 @@ // ok, but triggers warning about stripping root

entry,
[field]: path,
[field]: p,
});

@@ -281,0 +302,0 @@ }

@@ -217,18 +217,39 @@ // the PEND/UNPEND stuff tracks whether we're ready to emit end/close yet.

[STRIPABSOLUTEPATH](entry, field) {
const path = entry[field];
if (!path || this.preservePaths)
const p = entry[field];
if (!p || this.preservePaths)
return true;
const parts = path.split('/');
const parts = p.split('/');
if (parts.includes('..') ||
/* c8 ignore next */
(isWindows && /^[a-z]:\.\.$/i.test(parts[0] ?? ''))) {
this.warn('TAR_ENTRY_ERROR', `${field} contains '..'`, {
entry,
[field]: path,
});
// not ok!
return false;
// For linkpath, check if the resolved path escapes cwd rather than
// just rejecting any path with '..' - relative symlinks like
// '../sibling/file' are valid if they resolve within the cwd.
// For paths, they just simply may not ever use .. at all.
if (field === 'path') {
this.warn('TAR_ENTRY_ERROR', `${field} contains '..'`, {
entry,
[field]: p,
});
// not ok!
return false;
}
else {
// Resolve linkpath relative to the entry's directory.
// `path.posix` is safe to use because we're operating on
// tar paths, not a filesystem.
const entryDir = path.posix.dirname(entry.path);
const resolved = path.posix.normalize(path.posix.join(entryDir, p));
// If the resolved path escapes (starts with ..), reject it
if (resolved.startsWith('../') || resolved === '..') {
this.warn('TAR_ENTRY_ERROR', `${field} escapes extraction directory`, {
entry,
[field]: p,
});
return false;
}
}
}
// strip off the root
const [root, stripped] = stripAbsolutePath(path);
const [root, stripped] = stripAbsolutePath(p);
if (root) {

@@ -239,3 +260,3 @@ // ok, but triggers warning about stripping root

entry,
[field]: path,
[field]: p,
});

@@ -242,0 +263,0 @@ }

@@ -5,3 +5,3 @@ {

"description": "tar for node",
"version": "7.5.4",
"version": "7.5.5",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet