Skip to content

Commit 45d4000

Browse files
committed
1 parent 22c9153 commit 45d4000

File tree

9 files changed

+141
-22
lines changed

9 files changed

+141
-22
lines changed

node_modules/tar/dist/commonjs/index.min.js

Lines changed: 4 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.umask = void 0;
4+
// separate file so I stop getting nagged in vim about deprecated API.
5+
const umask = () => process.umask();
6+
exports.umask = umask;
7+
//# sourceMappingURL=process-umask.js.map

node_modules/tar/dist/commonjs/unpack.js

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const parse_js_1 = require("./parse.js");
5454
const strip_absolute_path_js_1 = require("./strip-absolute-path.js");
5555
const wc = __importStar(require("./winchars.js"));
5656
const path_reservations_js_1 = require("./path-reservations.js");
57+
const symlink_error_js_1 = require("./symlink-error.js");
58+
const process_umask_js_1 = require("./process-umask.js");
5759
const ONENTRY = Symbol('onEntry');
5860
const CHECKFS = Symbol('checkFs');
5961
const CHECKFS2 = Symbol('checkFs2');
@@ -64,6 +66,7 @@ const DIRECTORY = Symbol('directory');
6466
const LINK = Symbol('link');
6567
const SYMLINK = Symbol('symlink');
6668
const HARDLINK = Symbol('hardlink');
69+
const ENSURE_NO_SYMLINK = Symbol('ensureNoSymlink');
6770
const UNSUPPORTED = Symbol('unsupported');
6871
const CHECKPATH = Symbol('checkPath');
6972
const STRIPABSOLUTEPATH = Symbol('stripAbsolutePath');
@@ -226,7 +229,7 @@ class Unpack extends parse_js_1.Parser {
226229
this.processUmask =
227230
!this.chmod ? 0
228231
: typeof opt.processUmask === 'number' ? opt.processUmask
229-
: process.umask();
232+
: (0, process_umask_js_1.umask)();
230233
this.umask =
231234
typeof opt.umask === 'number' ? opt.umask : this.processUmask;
232235
// default mode for dirs created as parents
@@ -301,6 +304,7 @@ class Unpack extends parse_js_1.Parser {
301304
}
302305
return true;
303306
}
307+
// no IO, just string checking for absolute indicators
304308
[CHECKPATH](entry) {
305309
const p = (0, normalize_windows_path_js_1.normalizeWindowsPath)(entry.path);
306310
const parts = p.split('/');
@@ -561,11 +565,33 @@ class Unpack extends parse_js_1.Parser {
561565
entry.resume();
562566
}
563567
[SYMLINK](entry, done) {
564-
this[LINK](entry, String(entry.linkpath), 'symlink', done);
568+
const parts = (0, normalize_windows_path_js_1.normalizeWindowsPath)(node_path_1.default.relative(this.cwd, node_path_1.default.resolve(node_path_1.default.dirname(String(entry.absolute)), String(entry.linkpath)))).split('/');
569+
this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, String(entry.linkpath), 'symlink', done), er => {
570+
this[ONERROR](er, entry);
571+
done();
572+
});
565573
}
566574
[HARDLINK](entry, done) {
567575
const linkpath = (0, normalize_windows_path_js_1.normalizeWindowsPath)(node_path_1.default.resolve(this.cwd, String(entry.linkpath)));
568-
this[LINK](entry, linkpath, 'link', done);
576+
const parts = (0, normalize_windows_path_js_1.normalizeWindowsPath)(String(entry.linkpath)).split('/');
577+
this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, linkpath, 'link', done), er => {
578+
this[ONERROR](er, entry);
579+
done();
580+
});
581+
}
582+
[ENSURE_NO_SYMLINK](entry, cwd, parts, done, onError) {
583+
const p = parts.shift();
584+
if (this.preservePaths || p === undefined)
585+
return done();
586+
const t = node_path_1.default.resolve(cwd, p);
587+
node_fs_1.default.lstat(t, (er, st) => {
588+
if (er)
589+
return done();
590+
if (st?.isSymbolicLink()) {
591+
return onError(new symlink_error_js_1.SymlinkError(t, node_path_1.default.resolve(t, parts.join('/'))));
592+
}
593+
this[ENSURE_NO_SYMLINK](entry, t, parts, done, onError);
594+
});
569595
}
570596
[PEND]() {
571597
this[PENDING]++;
@@ -699,7 +725,6 @@ class Unpack extends parse_js_1.Parser {
699725
}
700726
}
701727
[LINK](entry, linkpath, link, done) {
702-
// XXX: get the type ('symlink' or 'junction') for windows
703728
node_fs_1.default[link](linkpath, String(entry.absolute), er => {
704729
if (er) {
705730
this[ONERROR](er, entry);
@@ -901,10 +926,25 @@ class UnpackSync extends Unpack {
901926
return er;
902927
}
903928
}
929+
[ENSURE_NO_SYMLINK](_entry, cwd, parts, done, onError) {
930+
if (this.preservePaths || !parts.length)
931+
return done();
932+
let t = cwd;
933+
for (const p of parts) {
934+
t = node_path_1.default.resolve(t, p);
935+
const [er, st] = callSync(() => node_fs_1.default.lstatSync(t));
936+
if (er)
937+
return done();
938+
if (st.isSymbolicLink()) {
939+
return onError(new symlink_error_js_1.SymlinkError(t, node_path_1.default.resolve(cwd, parts.join('/'))));
940+
}
941+
}
942+
done();
943+
}
904944
[LINK](entry, linkpath, link, done) {
905-
const ls = `${link}Sync`;
945+
const linkSync = `${link}Sync`;
906946
try {
907-
node_fs_1.default[ls](linkpath, String(entry.absolute));
947+
node_fs_1.default[linkSync](linkpath, String(entry.absolute));
908948
done();
909949
entry.resume();
910950
}

node_modules/tar/dist/esm/index.min.js

Lines changed: 4 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// separate file so I stop getting nagged in vim about deprecated API.
2+
export const umask = () => process.umask();
3+
//# sourceMappingURL=process-umask.js.map

node_modules/tar/dist/esm/unpack.js

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { Parser } from './parse.js';
1515
import { stripAbsolutePath } from './strip-absolute-path.js';
1616
import * as wc from './winchars.js';
1717
import { PathReservations } from './path-reservations.js';
18+
import { SymlinkError } from './symlink-error.js';
19+
import { umask } from './process-umask.js';
1820
const ONENTRY = Symbol('onEntry');
1921
const CHECKFS = Symbol('checkFs');
2022
const CHECKFS2 = Symbol('checkFs2');
@@ -25,6 +27,7 @@ const DIRECTORY = Symbol('directory');
2527
const LINK = Symbol('link');
2628
const SYMLINK = Symbol('symlink');
2729
const HARDLINK = Symbol('hardlink');
30+
const ENSURE_NO_SYMLINK = Symbol('ensureNoSymlink');
2831
const UNSUPPORTED = Symbol('unsupported');
2932
const CHECKPATH = Symbol('checkPath');
3033
const STRIPABSOLUTEPATH = Symbol('stripAbsolutePath');
@@ -187,7 +190,7 @@ export class Unpack extends Parser {
187190
this.processUmask =
188191
!this.chmod ? 0
189192
: typeof opt.processUmask === 'number' ? opt.processUmask
190-
: process.umask();
193+
: umask();
191194
this.umask =
192195
typeof opt.umask === 'number' ? opt.umask : this.processUmask;
193196
// default mode for dirs created as parents
@@ -262,6 +265,7 @@ export class Unpack extends Parser {
262265
}
263266
return true;
264267
}
268+
// no IO, just string checking for absolute indicators
265269
[CHECKPATH](entry) {
266270
const p = normalizeWindowsPath(entry.path);
267271
const parts = p.split('/');
@@ -522,11 +526,33 @@ export class Unpack extends Parser {
522526
entry.resume();
523527
}
524528
[SYMLINK](entry, done) {
525-
this[LINK](entry, String(entry.linkpath), 'symlink', done);
529+
const parts = normalizeWindowsPath(path.relative(this.cwd, path.resolve(path.dirname(String(entry.absolute)), String(entry.linkpath)))).split('/');
530+
this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, String(entry.linkpath), 'symlink', done), er => {
531+
this[ONERROR](er, entry);
532+
done();
533+
});
526534
}
527535
[HARDLINK](entry, done) {
528536
const linkpath = normalizeWindowsPath(path.resolve(this.cwd, String(entry.linkpath)));
529-
this[LINK](entry, linkpath, 'link', done);
537+
const parts = normalizeWindowsPath(String(entry.linkpath)).split('/');
538+
this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, linkpath, 'link', done), er => {
539+
this[ONERROR](er, entry);
540+
done();
541+
});
542+
}
543+
[ENSURE_NO_SYMLINK](entry, cwd, parts, done, onError) {
544+
const p = parts.shift();
545+
if (this.preservePaths || p === undefined)
546+
return done();
547+
const t = path.resolve(cwd, p);
548+
fs.lstat(t, (er, st) => {
549+
if (er)
550+
return done();
551+
if (st?.isSymbolicLink()) {
552+
return onError(new SymlinkError(t, path.resolve(t, parts.join('/'))));
553+
}
554+
this[ENSURE_NO_SYMLINK](entry, t, parts, done, onError);
555+
});
530556
}
531557
[PEND]() {
532558
this[PENDING]++;
@@ -660,7 +686,6 @@ export class Unpack extends Parser {
660686
}
661687
}
662688
[LINK](entry, linkpath, link, done) {
663-
// XXX: get the type ('symlink' or 'junction') for windows
664689
fs[link](linkpath, String(entry.absolute), er => {
665690
if (er) {
666691
this[ONERROR](er, entry);
@@ -861,10 +886,25 @@ export class UnpackSync extends Unpack {
861886
return er;
862887
}
863888
}
889+
[ENSURE_NO_SYMLINK](_entry, cwd, parts, done, onError) {
890+
if (this.preservePaths || !parts.length)
891+
return done();
892+
let t = cwd;
893+
for (const p of parts) {
894+
t = path.resolve(t, p);
895+
const [er, st] = callSync(() => fs.lstatSync(t));
896+
if (er)
897+
return done();
898+
if (st.isSymbolicLink()) {
899+
return onError(new SymlinkError(t, path.resolve(cwd, parts.join('/'))));
900+
}
901+
}
902+
done();
903+
}
864904
[LINK](entry, linkpath, link, done) {
865-
const ls = `${link}Sync`;
905+
const linkSync = `${link}Sync`;
866906
try {
867-
fs[ls](linkpath, String(entry.absolute));
907+
fs[linkSync](linkpath, String(entry.absolute));
868908
done();
869909
entry.resume();
870910
}

node_modules/tar/package.json

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Isaac Z. Schlueter",
33
"name": "tar",
44
"description": "tar for node",
5-
"version": "7.5.7",
5+
"version": "7.5.9",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/isaacs/node-tar.git"
@@ -13,7 +13,7 @@
1313
"test": "tap",
1414
"pretest": "npm run prepare",
1515
"presnap": "npm run prepare",
16-
"prepare": "tshy",
16+
"prepare": "tshy && bash scripts/build.sh",
1717
"preversion": "npm test",
1818
"postversion": "npm publish",
1919
"prepublishOnly": "git push origin --follow-tags",
@@ -31,6 +31,7 @@
3131
"@types/node": "^25.0.9",
3232
"chmodr": "^2.0.2",
3333
"end-of-stream": "^1.4.3",
34+
"esbuild": "^0.27.3",
3435
"events-to-array": "^2.0.3",
3536
"mutate-fs": "^2.1.1",
3637
"nock": "^13.5.4",
@@ -50,7 +51,17 @@
5051
"tshy": {
5152
"exports": {
5253
"./package.json": "./package.json",
53-
".": "./src/index.ts",
54+
".": {
55+
"import": {
56+
"types": "./dist/esm/index.d.ts",
57+
"default": "./dist/esm/index.min.js"
58+
},
59+
"require": {
60+
"types": "./dist/commonjs/index.d.ts",
61+
"default": "./dist/commonjs/index.min.js"
62+
}
63+
},
64+
"./raw": "./src/index.ts",
5465
"./c": "./src/create.ts",
5566
"./create": "./src/create.ts",
5667
"./replace": "./src/create.ts",
@@ -74,6 +85,16 @@
7485
"exports": {
7586
"./package.json": "./package.json",
7687
".": {
88+
"import": {
89+
"types": "./dist/esm/index.d.ts",
90+
"default": "./dist/esm/index.min.js"
91+
},
92+
"require": {
93+
"types": "./dist/commonjs/index.d.ts",
94+
"default": "./dist/commonjs/index.min.js"
95+
}
96+
},
97+
"./raw": {
7798
"import": {
7899
"types": "./dist/esm/index.d.ts",
79100
"default": "./dist/esm/index.js"
@@ -265,7 +286,7 @@
265286
}
266287
},
267288
"type": "module",
268-
"main": "./dist/commonjs/index.js",
289+
"main": "./dist/commonjs/index.min.js",
269290
"types": "./dist/commonjs/index.d.ts",
270-
"module": "./dist/esm/index.js"
291+
"module": "./dist/esm/index.min.js"
271292
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"spdx-expression-parse": "^4.0.0",
145145
"ssri": "^13.0.1",
146146
"supports-color": "^10.2.2",
147-
"tar": "^7.5.7",
147+
"tar": "^7.5.9",
148148
"text-table": "~0.2.0",
149149
"tiny-relative-date": "^2.0.2",
150150
"treeverse": "^3.0.0",
@@ -13327,9 +13327,9 @@
1332713327
}
1332813328
},
1332913329
"node_modules/tar": {
13330-
"version": "7.5.7",
13331-
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.7.tgz",
13332-
"integrity": "sha512-fov56fJiRuThVFXD6o6/Q354S7pnWMJIVlDBYijsTNx6jKSE4pvrDTs6lUnmGvNyfJwFQQwWy3owKz1ucIhveQ==",
13330+
"version": "7.5.9",
13331+
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.9.tgz",
13332+
"integrity": "sha512-BTLcK0xsDh2+PUe9F6c2TlRp4zOOBMTkoQHQIWSIzI0R7KG46uEwq4OPk2W7bZcprBMsuaeFsqwYr7pjh6CuHg==",
1333313333
"inBundle": true,
1333413334
"license": "BlueOak-1.0.0",
1333513335
"dependencies": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"spdx-expression-parse": "^4.0.0",
112112
"ssri": "^13.0.1",
113113
"supports-color": "^10.2.2",
114-
"tar": "^7.5.7",
114+
"tar": "^7.5.9",
115115
"text-table": "~0.2.0",
116116
"tiny-relative-date": "^2.0.2",
117117
"treeverse": "^3.0.0",

0 commit comments

Comments
 (0)