snyk 1.1192.0 → 1.1194.0
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/dist/cli/95.index.js +3082 -283
- package/dist/cli/95.index.js.map +1 -1
- package/dist/cli/9b9a51334b4c8ed9874aa93bfe64d166.node +0 -0
- package/dist/cli/eb317cf9255f67c17789c294700ceae7.node +0 -0
- package/dist/cli/thirdPartyNotice.json +24 -15
- package/package.json +1 -1
- package/src/generated/sha256sums.txt +10 -10
- package/src/generated/version +1 -1
- package/wrapper_dist/generated/sha256sums.txt +10 -10
- package/wrapper_dist/generated/version +1 -1
- package/dist/cli/a8f8676967c7b025b7bbc9bf05eac2de.node +0 -0
- package/dist/cli/e229c1b0266a376aca04e7a37697b1b4.node +0 -0
package/dist/cli/95.index.js
CHANGED
|
@@ -12530,13 +12530,9 @@ async function initAndPollReportGeneric(initReportFunc, getReportFunc, options)
|
|
|
12530
12530
|
async function reportBundle(options) {
|
|
12531
12531
|
var _a, _b;
|
|
12532
12532
|
const projectName = (_b = (_a = options.report) === null || _a === void 0 ? void 0 : _a.projectName) === null || _b === void 0 ? void 0 : _b.trim();
|
|
12533
|
-
const projectNameMaxLength = 64;
|
|
12534
12533
|
if (!projectName || projectName.length === 0) {
|
|
12535
12534
|
throw new Error('"project-name" must be provided for "report"');
|
|
12536
12535
|
}
|
|
12537
|
-
if (projectName.length > projectNameMaxLength) {
|
|
12538
|
-
throw new Error(`"project-name" must not exceed ${projectNameMaxLength} characters`);
|
|
12539
|
-
}
|
|
12540
12536
|
if (/[^A-Za-z0-9-_/]/g.test(projectName)) {
|
|
12541
12537
|
throw new Error(`"project-name" must not contain spaces or special characters except [/-_]`);
|
|
12542
12538
|
}
|
|
@@ -18675,6 +18671,7 @@ function validateGraph(graph, rootNodeId, pkgs, pkgNodes) {
|
|
|
18675
18671
|
}
|
|
18676
18672
|
exports.validateGraph = validateGraph;
|
|
18677
18673
|
function validatePackageURL(pkg) {
|
|
18674
|
+
var _a;
|
|
18678
18675
|
if (!pkg.purl) {
|
|
18679
18676
|
return;
|
|
18680
18677
|
}
|
|
@@ -18686,6 +18683,29 @@ function validatePackageURL(pkg) {
|
|
|
18686
18683
|
case 'maven':
|
|
18687
18684
|
assert(pkg.name === purlPkg.namespace + ':' + purlPkg.name, `name and packageURL name do not match`);
|
|
18688
18685
|
break;
|
|
18686
|
+
case 'composer':
|
|
18687
|
+
case 'golang':
|
|
18688
|
+
case 'npm':
|
|
18689
|
+
case 'swift':
|
|
18690
|
+
assert(pkg.name ===
|
|
18691
|
+
(purlPkg.namespace
|
|
18692
|
+
? `${purlPkg.namespace}/${purlPkg.name}`
|
|
18693
|
+
: purlPkg.name), `name and packageURL name do not match`);
|
|
18694
|
+
break;
|
|
18695
|
+
// The PURL spec for Linux distros does not include the source in the name.
|
|
18696
|
+
// This is why we relax the assertion here and match only on the package name:
|
|
18697
|
+
// <source name>/<package name> - we omit the source name
|
|
18698
|
+
// For now, make this exception only for deb to cover a support case.
|
|
18699
|
+
case 'deb': {
|
|
18700
|
+
const pkgName = pkg.name.split('/').pop();
|
|
18701
|
+
assert(pkgName === purlPkg.name, 'name and packageURL name do not match');
|
|
18702
|
+
if (((_a = purlPkg.qualifiers) === null || _a === void 0 ? void 0 : _a['upstream']) && pkg.name.includes('/')) {
|
|
18703
|
+
const pkgSrc = pkg.name.split('/')[0];
|
|
18704
|
+
const pkgUpstream = purlPkg.qualifiers['upstream'].split('@')[0];
|
|
18705
|
+
assert(pkgSrc === pkgUpstream, 'source and packageURL source do not match');
|
|
18706
|
+
}
|
|
18707
|
+
break;
|
|
18708
|
+
}
|
|
18689
18709
|
default:
|
|
18690
18710
|
assert(pkg.name === purlPkg.name, `name and packageURL name do not match`);
|
|
18691
18711
|
}
|
|
@@ -94308,9 +94328,9 @@ var querystring = __webpack_require__(63477),
|
|
|
94308
94328
|
debug = __webpack_require__(15158)('modem'),
|
|
94309
94329
|
utils = __webpack_require__(76174),
|
|
94310
94330
|
util = __webpack_require__(73837),
|
|
94311
|
-
url = __webpack_require__(57310),
|
|
94312
94331
|
splitca = __webpack_require__(22714),
|
|
94313
|
-
isWin = __webpack_require__(22037).type() === 'Windows_NT'
|
|
94332
|
+
isWin = __webpack_require__(22037).type() === 'Windows_NT',
|
|
94333
|
+
stream = __webpack_require__(12781);
|
|
94314
94334
|
|
|
94315
94335
|
var defaultOpts = function () {
|
|
94316
94336
|
var host;
|
|
@@ -94376,7 +94396,7 @@ var Modem = function (options) {
|
|
|
94376
94396
|
|
|
94377
94397
|
this.host = opts.host;
|
|
94378
94398
|
|
|
94379
|
-
if(!this.host) {
|
|
94399
|
+
if (!this.host) {
|
|
94380
94400
|
this.socketPath = opts.socketPath;
|
|
94381
94401
|
}
|
|
94382
94402
|
|
|
@@ -94394,7 +94414,7 @@ var Modem = function (options) {
|
|
|
94394
94414
|
this.headers = opts.headers || {};
|
|
94395
94415
|
this.sshOptions = Object.assign({}, options ? options.sshOptions : {}, optDefaults.sshOptions);
|
|
94396
94416
|
//retrocompabitlity
|
|
94397
|
-
if(this.sshOptions.agentForward === undefined) {
|
|
94417
|
+
if (this.sshOptions.agentForward === undefined) {
|
|
94398
94418
|
this.sshOptions.agentForward = opts.agentForward;
|
|
94399
94419
|
}
|
|
94400
94420
|
|
|
@@ -94465,7 +94485,7 @@ Modem.prototype.dial = function (options, callback) {
|
|
|
94465
94485
|
|
|
94466
94486
|
if (options.authconfig) {
|
|
94467
94487
|
optionsf.headers['X-Registry-Auth'] = options.authconfig.key || options.authconfig.base64 ||
|
|
94468
|
-
Buffer.from(JSON.stringify(options.authconfig)).toString('base64');
|
|
94488
|
+
Buffer.from(JSON.stringify(options.authconfig)).toString('base64').replace(/\+/g, "-").replace(/\//g, "_");
|
|
94469
94489
|
}
|
|
94470
94490
|
|
|
94471
94491
|
if (options.registryconfig) {
|
|
@@ -94525,6 +94545,7 @@ Modem.prototype.dial = function (options, callback) {
|
|
|
94525
94545
|
Modem.prototype.buildRequest = function (options, context, data, callback) {
|
|
94526
94546
|
var self = this;
|
|
94527
94547
|
var connectionTimeoutTimer;
|
|
94548
|
+
var finished = false;
|
|
94528
94549
|
|
|
94529
94550
|
var opts = self.protocol === 'ssh' ? Object.assign(options, {
|
|
94530
94551
|
agent: ssh(Object.assign({}, self.sshOptions, {
|
|
@@ -94563,7 +94584,10 @@ Modem.prototype.buildRequest = function (options, context, data, callback) {
|
|
|
94563
94584
|
if (context.hijack === true) {
|
|
94564
94585
|
clearTimeout(connectionTimeoutTimer);
|
|
94565
94586
|
req.on('upgrade', function (res, sock, head) {
|
|
94566
|
-
|
|
94587
|
+
if (finished === false) {
|
|
94588
|
+
finished = true;
|
|
94589
|
+
return callback(null, sock);
|
|
94590
|
+
}
|
|
94567
94591
|
});
|
|
94568
94592
|
}
|
|
94569
94593
|
|
|
@@ -94578,8 +94602,17 @@ Modem.prototype.buildRequest = function (options, context, data, callback) {
|
|
|
94578
94602
|
req.on('response', function (res) {
|
|
94579
94603
|
clearTimeout(connectionTimeoutTimer);
|
|
94580
94604
|
if (context.isStream === true) {
|
|
94581
|
-
|
|
94605
|
+
if (finished === false) {
|
|
94606
|
+
finished = true;
|
|
94607
|
+
self.buildPayload(null, context.isStream, context.statusCodes, context.openStdin, req, res, null, callback);
|
|
94608
|
+
}
|
|
94582
94609
|
} else {
|
|
94610
|
+
// The native 'request' method only handles aborting during the request lifecycle not the response lifecycle.
|
|
94611
|
+
// We need to make the response stream abortable so that it's destroyed with an error on abort and then
|
|
94612
|
+
// it triggers the request 'error' event
|
|
94613
|
+
if (options.signal != null) {
|
|
94614
|
+
stream.addAbortSignal(options.signal, res)
|
|
94615
|
+
}
|
|
94583
94616
|
var chunks = [];
|
|
94584
94617
|
res.on('data', function (chunk) {
|
|
94585
94618
|
chunks.push(chunk);
|
|
@@ -94592,14 +94625,20 @@ Modem.prototype.buildRequest = function (options, context, data, callback) {
|
|
|
94592
94625
|
debug('Received: %s', result);
|
|
94593
94626
|
|
|
94594
94627
|
var json = utils.parseJSON(result) || buffer;
|
|
94595
|
-
|
|
94628
|
+
if (finished === false) {
|
|
94629
|
+
finished = true;
|
|
94630
|
+
self.buildPayload(null, context.isStream, context.statusCodes, false, req, res, json, callback);
|
|
94631
|
+
}
|
|
94596
94632
|
});
|
|
94597
94633
|
}
|
|
94598
94634
|
});
|
|
94599
94635
|
|
|
94600
94636
|
req.on('error', function (error) {
|
|
94601
94637
|
clearTimeout(connectionTimeoutTimer);
|
|
94602
|
-
|
|
94638
|
+
if (finished === false) {
|
|
94639
|
+
finished = true;
|
|
94640
|
+
self.buildPayload(error, context.isStream, context.statusCodes, false, {}, {}, null, callback);
|
|
94641
|
+
}
|
|
94603
94642
|
});
|
|
94604
94643
|
|
|
94605
94644
|
if (typeof data === 'string' || Buffer.isBuffer(data)) {
|
|
@@ -94656,7 +94695,7 @@ Modem.prototype.buildPayload = function (err, isStream, statusCodes, openStdin,
|
|
|
94656
94695
|
}
|
|
94657
94696
|
};
|
|
94658
94697
|
|
|
94659
|
-
Modem.prototype.demuxStream = function (
|
|
94698
|
+
Modem.prototype.demuxStream = function (streama, stdout, stderr) {
|
|
94660
94699
|
var nextDataType = null;
|
|
94661
94700
|
var nextDataLength = null;
|
|
94662
94701
|
var buffer = Buffer.from('');
|
|
@@ -94695,18 +94734,18 @@ Modem.prototype.demuxStream = function (stream, stdout, stderr) {
|
|
|
94695
94734
|
return out;
|
|
94696
94735
|
}
|
|
94697
94736
|
|
|
94698
|
-
|
|
94737
|
+
streama.on('data', processData);
|
|
94699
94738
|
};
|
|
94700
94739
|
|
|
94701
|
-
Modem.prototype.followProgress = function (
|
|
94740
|
+
Modem.prototype.followProgress = function (streama, onFinished, onProgress) {
|
|
94702
94741
|
var buf = '';
|
|
94703
94742
|
var output = [];
|
|
94704
94743
|
var finished = false;
|
|
94705
94744
|
|
|
94706
|
-
|
|
94707
|
-
|
|
94708
|
-
|
|
94709
|
-
|
|
94745
|
+
streama.on('data', onStreamEvent);
|
|
94746
|
+
streama.on('error', onStreamError);
|
|
94747
|
+
streama.on('end', onStreamEnd);
|
|
94748
|
+
streama.on('close', onStreamEnd);
|
|
94710
94749
|
|
|
94711
94750
|
function onStreamEvent(data) {
|
|
94712
94751
|
buf += data.toString();
|
|
@@ -94738,15 +94777,15 @@ Modem.prototype.followProgress = function (stream, onFinished, onProgress) {
|
|
|
94738
94777
|
|
|
94739
94778
|
function onStreamError(err) {
|
|
94740
94779
|
finished = true;
|
|
94741
|
-
|
|
94742
|
-
|
|
94743
|
-
|
|
94744
|
-
|
|
94780
|
+
streama.removeListener('data', onStreamEvent);
|
|
94781
|
+
streama.removeListener('error', onStreamError);
|
|
94782
|
+
streama.removeListener('end', onStreamEnd);
|
|
94783
|
+
streama.removeListener('close', onStreamEnd);
|
|
94745
94784
|
onFinished(err, output);
|
|
94746
94785
|
}
|
|
94747
94786
|
|
|
94748
94787
|
function onStreamEnd() {
|
|
94749
|
-
if(!finished) onFinished(null, output);
|
|
94788
|
+
if (!finished) onFinished(null, output);
|
|
94750
94789
|
finished = true;
|
|
94751
94790
|
}
|
|
94752
94791
|
};
|
|
@@ -94754,14 +94793,13 @@ Modem.prototype.followProgress = function (stream, onFinished, onProgress) {
|
|
|
94754
94793
|
Modem.prototype.buildQuerystring = function (opts) {
|
|
94755
94794
|
var clone = {};
|
|
94756
94795
|
|
|
94757
|
-
// serialize map values as JSON strings, else querystring truncates.
|
|
94796
|
+
// serialize map and array values as JSON strings, else querystring truncates.
|
|
94797
|
+
// 't' and 'extrahosts' can be arrays but need special treatment so that they're
|
|
94798
|
+
// passed as multiple qs parameters instead of JSON values.
|
|
94758
94799
|
Object.keys(opts).map(function (key, i) {
|
|
94759
94800
|
if (opts[key]
|
|
94760
94801
|
&& typeof opts[key] === 'object'
|
|
94761
|
-
&& !
|
|
94762
|
-
// Ref: https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild
|
|
94763
|
-
// > cachefrom (string) JSON array of images used for build cache resolution.
|
|
94764
|
-
|| key === 'cachefrom'
|
|
94802
|
+
&& !['t', 'extrahosts'].includes(key)
|
|
94765
94803
|
) {
|
|
94766
94804
|
clone[key] = JSON.stringify(opts[key]);
|
|
94767
94805
|
} else {
|
|
@@ -170258,7 +170296,7 @@ module.exports = arrify;
|
|
|
170258
170296
|
/* module decorator */ module = __webpack_require__.nmd(module);
|
|
170259
170297
|
|
|
170260
170298
|
try {
|
|
170261
|
-
process.dlopen(module, __dirname + __webpack_require__(71017).sep + __webpack_require__.p + "
|
|
170299
|
+
process.dlopen(module, __dirname + __webpack_require__(71017).sep + __webpack_require__.p + "eb317cf9255f67c17789c294700ceae7.node");
|
|
170262
170300
|
} catch (error) {
|
|
170263
170301
|
throw new Error('node-loader:\n' + error);
|
|
170264
170302
|
}
|
|
@@ -170272,7 +170310,7 @@ try {
|
|
|
170272
170310
|
/* module decorator */ module = __webpack_require__.nmd(module);
|
|
170273
170311
|
|
|
170274
170312
|
try {
|
|
170275
|
-
process.dlopen(module, __dirname + __webpack_require__(71017).sep + __webpack_require__.p + "
|
|
170313
|
+
process.dlopen(module, __dirname + __webpack_require__(71017).sep + __webpack_require__.p + "9b9a51334b4c8ed9874aa93bfe64d166.node");
|
|
170276
170314
|
} catch (error) {
|
|
170277
170315
|
throw new Error('node-loader:\n' + error);
|
|
170278
170316
|
}
|
|
@@ -171338,7 +171376,7 @@ class PackageURL {
|
|
|
171338
171376
|
}
|
|
171339
171377
|
|
|
171340
171378
|
toString() {
|
|
171341
|
-
var purl = ['pkg:', this.type, '/'];
|
|
171379
|
+
var purl = ['pkg:', encodeURIComponent(this.type), '/'];
|
|
171342
171380
|
|
|
171343
171381
|
if (this.type === 'pypi') {
|
|
171344
171382
|
this._handlePyPi();
|
|
@@ -171353,11 +171391,11 @@ class PackageURL {
|
|
|
171353
171391
|
purl.push('/');
|
|
171354
171392
|
}
|
|
171355
171393
|
|
|
171356
|
-
purl.push(encodeURIComponent(this.name).replace(
|
|
171394
|
+
purl.push(encodeURIComponent(this.name).replace(/%3A/g, ':'));
|
|
171357
171395
|
|
|
171358
171396
|
if (this.version) {
|
|
171359
171397
|
purl.push('@');
|
|
171360
|
-
purl.push(encodeURIComponent(this.version).replace(
|
|
171398
|
+
purl.push(encodeURIComponent(this.version).replace(/%3A/g, ':'));
|
|
171361
171399
|
}
|
|
171362
171400
|
|
|
171363
171401
|
if (this.qualifiers) {
|
|
@@ -171366,7 +171404,11 @@ class PackageURL {
|
|
|
171366
171404
|
let qualifiers = this.qualifiers;
|
|
171367
171405
|
let qualifierString = [];
|
|
171368
171406
|
Object.keys(qualifiers).sort().forEach(key => {
|
|
171369
|
-
qualifierString.push(
|
|
171407
|
+
qualifierString.push(
|
|
171408
|
+
encodeURIComponent(key).replace(/%3A/g, ':')
|
|
171409
|
+
+ '='
|
|
171410
|
+
+ encodeURIComponent(qualifiers[key]).replace(/%2F/g, '/')
|
|
171411
|
+
);
|
|
171370
171412
|
});
|
|
171371
171413
|
|
|
171372
171414
|
purl.push(qualifierString.join('&'));
|
|
@@ -171374,14 +171416,16 @@ class PackageURL {
|
|
|
171374
171416
|
|
|
171375
171417
|
if (this.subpath) {
|
|
171376
171418
|
purl.push('#');
|
|
171377
|
-
purl.push(
|
|
171419
|
+
purl.push(encodeURIComponent(this.subpath)
|
|
171420
|
+
.replace(/%3A/g, ':')
|
|
171421
|
+
.replace(/%2F/g, '/'));
|
|
171378
171422
|
}
|
|
171379
171423
|
|
|
171380
171424
|
return purl.join('');
|
|
171381
171425
|
}
|
|
171382
171426
|
|
|
171383
171427
|
static fromString(purl) {
|
|
171384
|
-
if (!purl ||
|
|
171428
|
+
if (!purl || typeof purl !== 'string' || !purl.trim()) {
|
|
171385
171429
|
throw new Error('A purl string argument is required.');
|
|
171386
171430
|
}
|
|
171387
171431
|
|
|
@@ -171398,6 +171442,7 @@ class PackageURL {
|
|
|
171398
171442
|
if (!type || !remainder) {
|
|
171399
171443
|
throw new Error('purl is missing the required "type" component.');
|
|
171400
171444
|
}
|
|
171445
|
+
type = decodeURIComponent(type)
|
|
171401
171446
|
|
|
171402
171447
|
let url = new URL(purl);
|
|
171403
171448
|
|
|
@@ -171412,9 +171457,9 @@ class PackageURL {
|
|
|
171412
171457
|
if (subpath.indexOf('#') === 0) {
|
|
171413
171458
|
subpath = subpath.substring(1);
|
|
171414
171459
|
}
|
|
171415
|
-
|
|
171416
|
-
|
|
171417
|
-
|
|
171460
|
+
subpath = subpath.length === 0
|
|
171461
|
+
? null
|
|
171462
|
+
: decodeURIComponent(subpath)
|
|
171418
171463
|
|
|
171419
171464
|
if (url.username !== '' || url.password !== '') {
|
|
171420
171465
|
throw new Error('Invalid purl: cannot contain a "user:pass@host:port"');
|
|
@@ -182328,7 +182373,7 @@ function cleanupCallback(imageFolderPath, imageName) {
|
|
|
182328
182373
|
}
|
|
182329
182374
|
fs.rmdir(imageFolderPath, (err) => {
|
|
182330
182375
|
if (err !== null) {
|
|
182331
|
-
debug(`Can't remove folder ${imageFolderPath}, got error ${err}`);
|
|
182376
|
+
debug(`Can't remove folder ${imageFolderPath}, got error ${err.message}`);
|
|
182332
182377
|
}
|
|
182333
182378
|
});
|
|
182334
182379
|
};
|
|
@@ -182344,44 +182389,49 @@ async function pullWithDockerBinary(docker, targetImage, saveLocation, username,
|
|
|
182344
182389
|
return (pullAndSaveSuccessful = true);
|
|
182345
182390
|
}
|
|
182346
182391
|
catch (err) {
|
|
182347
|
-
debug(`couldn't pull ${targetImage} using docker binary: ${err}`);
|
|
182348
|
-
|
|
182349
|
-
err.stderr.includes("unknown operating system or architecture")) {
|
|
182350
|
-
throw new Error("Unknown operating system or architecture");
|
|
182351
|
-
}
|
|
182352
|
-
if (err.stderr &&
|
|
182353
|
-
err.stderr.includes("operating system is not supported")) {
|
|
182354
|
-
throw new Error(`Operating system is not supported`);
|
|
182355
|
-
}
|
|
182356
|
-
const unknownManifestConditions = [
|
|
182357
|
-
"no matching manifest for",
|
|
182358
|
-
"manifest unknown",
|
|
182359
|
-
];
|
|
182360
|
-
if (err.stderr &&
|
|
182361
|
-
unknownManifestConditions.some((value) => err.stderr.includes(value))) {
|
|
182362
|
-
if (platform) {
|
|
182363
|
-
throw new Error(`The image does not exist for ${platform}`);
|
|
182364
|
-
}
|
|
182365
|
-
throw new Error(`The image does not exist for the current platform`);
|
|
182366
|
-
}
|
|
182367
|
-
if (err.stderr && err.stderr.includes("invalid reference format")) {
|
|
182368
|
-
throw new Error(`invalid image format`);
|
|
182369
|
-
}
|
|
182370
|
-
if (err.stderr.includes("unknown flag: --platform")) {
|
|
182371
|
-
throw new Error('"--platform" is only supported on a Docker daemon with version later than 17.09');
|
|
182372
|
-
}
|
|
182373
|
-
if (err.stderr &&
|
|
182374
|
-
err.stderr ===
|
|
182375
|
-
'"--platform" is only supported on a Docker daemon with experimental features enabled') {
|
|
182376
|
-
throw new Error(err.stderr);
|
|
182377
|
-
}
|
|
182392
|
+
debug(`couldn't pull ${targetImage} using docker binary: ${err.message}`);
|
|
182393
|
+
handleDockerPullError(err.stderr, platform);
|
|
182378
182394
|
return pullAndSaveSuccessful;
|
|
182379
182395
|
}
|
|
182380
182396
|
}
|
|
182397
|
+
function handleDockerPullError(err, platform) {
|
|
182398
|
+
if (err && err.includes("unknown operating system or architecture")) {
|
|
182399
|
+
throw new Error("Unknown operating system or architecture");
|
|
182400
|
+
}
|
|
182401
|
+
if (err.includes("operating system is not supported")) {
|
|
182402
|
+
throw new Error(`Operating system is not supported`);
|
|
182403
|
+
}
|
|
182404
|
+
const unknownManifestConditions = [
|
|
182405
|
+
"no matching manifest for",
|
|
182406
|
+
"manifest unknown",
|
|
182407
|
+
];
|
|
182408
|
+
if (unknownManifestConditions.some((value) => err.includes(value))) {
|
|
182409
|
+
if (platform) {
|
|
182410
|
+
throw new Error(`The image does not exist for ${platform}`);
|
|
182411
|
+
}
|
|
182412
|
+
throw new Error(`The image does not exist for the current platform`);
|
|
182413
|
+
}
|
|
182414
|
+
if (err.includes("invalid reference format")) {
|
|
182415
|
+
throw new Error(`invalid image format`);
|
|
182416
|
+
}
|
|
182417
|
+
if (err.includes("unknown flag: --platform")) {
|
|
182418
|
+
throw new Error('"--platform" is only supported on a Docker daemon with version later than 17.09');
|
|
182419
|
+
}
|
|
182420
|
+
if (err ===
|
|
182421
|
+
'"--platform" is only supported on a Docker daemon with experimental features enabled') {
|
|
182422
|
+
throw new Error(err);
|
|
182423
|
+
}
|
|
182424
|
+
}
|
|
182381
182425
|
async function pullFromContainerRegistry(docker, targetImage, imageSavePath, username, password) {
|
|
182382
182426
|
const { hostname, imageName, tag } = extractImageDetails(targetImage);
|
|
182383
182427
|
debug(`Attempting to pull: registry: ${hostname}, image: ${imageName}, tag: ${tag}`);
|
|
182384
|
-
|
|
182428
|
+
try {
|
|
182429
|
+
return await docker.pull(hostname, imageName, tag, imageSavePath, username, password);
|
|
182430
|
+
}
|
|
182431
|
+
catch (err) {
|
|
182432
|
+
handleDockerPullError(err.message);
|
|
182433
|
+
throw err;
|
|
182434
|
+
}
|
|
182385
182435
|
}
|
|
182386
182436
|
async function pullImage(docker, targetImage, saveLocation, imageSavePath, username, password, platform) {
|
|
182387
182437
|
if (await docker_1.Docker.binaryExists()) {
|
|
@@ -182509,7 +182559,7 @@ function isLocalImageSameArchitecture(platformOption, inspectResultArchitecture)
|
|
|
182509
182559
|
platformArchitecture = platformOption.split("/")[1];
|
|
182510
182560
|
}
|
|
182511
182561
|
catch (error) {
|
|
182512
|
-
debug(`Error parsing platform flag: '${error}'`);
|
|
182562
|
+
debug(`Error parsing platform flag: '${error.message}'`);
|
|
182513
182563
|
return false;
|
|
182514
182564
|
}
|
|
182515
182565
|
return platformArchitecture === inspectResultArchitecture;
|
|
@@ -182713,7 +182763,7 @@ async function detect(extractedLayers, dockerfileAnalysis) {
|
|
|
182713
182763
|
osRelease = await handler(osReleaseFile);
|
|
182714
182764
|
}
|
|
182715
182765
|
catch (err) {
|
|
182716
|
-
debug(`Malformed OS release file: ${err}`);
|
|
182766
|
+
debug(`Malformed OS release file: ${err.message}`);
|
|
182717
182767
|
}
|
|
182718
182768
|
if (osRelease) {
|
|
182719
182769
|
break;
|
|
@@ -182823,7 +182873,8 @@ function parseLine(text, curPkg, pkgs) {
|
|
|
182823
182873
|
"use strict";
|
|
182824
182874
|
|
|
182825
182875
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
182826
|
-
exports.analyzeDistroless = exports.analyze = void 0;
|
|
182876
|
+
exports.purl = exports.analyzeDistroless = exports.analyze = void 0;
|
|
182877
|
+
const packageurl_js_1 = __webpack_require__(38382);
|
|
182827
182878
|
const types_1 = __webpack_require__(36293);
|
|
182828
182879
|
function analyze(targetImage, aptFiles) {
|
|
182829
182880
|
const pkgs = parseDpkgFile(aptFiles.dpkgFile);
|
|
@@ -182855,9 +182906,29 @@ function parseDpkgFile(text) {
|
|
|
182855
182906
|
let curPkg = null;
|
|
182856
182907
|
for (const line of text.split("\n")) {
|
|
182857
182908
|
curPkg = parseDpkgLine(line, curPkg, pkgs);
|
|
182909
|
+
if (curPkg) {
|
|
182910
|
+
curPkg.Purl = purl(curPkg);
|
|
182911
|
+
}
|
|
182858
182912
|
}
|
|
182859
182913
|
return pkgs;
|
|
182860
182914
|
}
|
|
182915
|
+
function purl(curPkg) {
|
|
182916
|
+
if (!curPkg.Name || !curPkg.Version) {
|
|
182917
|
+
return undefined;
|
|
182918
|
+
}
|
|
182919
|
+
const qualifiers = {};
|
|
182920
|
+
if (curPkg.Source && curPkg.SourceVersion) {
|
|
182921
|
+
qualifiers.upstream = `${curPkg.Source}@${curPkg.SourceVersion}`;
|
|
182922
|
+
}
|
|
182923
|
+
else if (curPkg.Source) {
|
|
182924
|
+
qualifiers.upstream = curPkg.Source;
|
|
182925
|
+
}
|
|
182926
|
+
return new packageurl_js_1.PackageURL("deb", "", curPkg.Name, curPkg.Version,
|
|
182927
|
+
// make sure that we pass in undefined if there are no qualifiers, because
|
|
182928
|
+
// the packageurl-js library doesn't handle that properly...
|
|
182929
|
+
Object.keys(qualifiers).length !== 0 ? qualifiers : undefined, undefined).toString();
|
|
182930
|
+
}
|
|
182931
|
+
exports.purl = purl;
|
|
182861
182932
|
function parseDpkgLine(text, curPkg, pkgs) {
|
|
182862
182933
|
const [key, value] = text.split(": ");
|
|
182863
182934
|
switch (key) {
|
|
@@ -182866,6 +182937,7 @@ function parseDpkgLine(text, curPkg, pkgs) {
|
|
|
182866
182937
|
Name: value,
|
|
182867
182938
|
Version: "",
|
|
182868
182939
|
Source: undefined,
|
|
182940
|
+
SourceVersion: undefined,
|
|
182869
182941
|
Provides: [],
|
|
182870
182942
|
Deps: {},
|
|
182871
182943
|
AutoInstalled: undefined,
|
|
@@ -182876,7 +182948,22 @@ function parseDpkgLine(text, curPkg, pkgs) {
|
|
|
182876
182948
|
curPkg.Version = value;
|
|
182877
182949
|
break;
|
|
182878
182950
|
case "Source":
|
|
182879
|
-
|
|
182951
|
+
/**
|
|
182952
|
+
* The value may look something like this:
|
|
182953
|
+
* libgcc6 (1.3.0-b1)
|
|
182954
|
+
* <name> (<version>)
|
|
182955
|
+
*
|
|
182956
|
+
* For example, Syft matches these values with a regex:
|
|
182957
|
+
* https://github.com/anchore/syft/blob/1764e1c3f6bd66781f8350d957a1f95e4d9ad3de/syft/pkg/cataloger/deb/parse_dpkg_db.go#L169-L173
|
|
182958
|
+
*/
|
|
182959
|
+
const parts = value.split(" ");
|
|
182960
|
+
curPkg.Source = parts[0];
|
|
182961
|
+
if (parts.length > 1) {
|
|
182962
|
+
curPkg.SourceVersion = parts[1]
|
|
182963
|
+
.trim()
|
|
182964
|
+
.replace("(", "")
|
|
182965
|
+
.replace(")", "");
|
|
182966
|
+
}
|
|
182880
182967
|
break;
|
|
182881
182968
|
case "Provides":
|
|
182882
182969
|
for (let name of value.split(",")) {
|
|
@@ -183080,7 +183167,7 @@ async function analyze(targetImage, dockerfileAnalysis, imageType, imagePath, gl
|
|
|
183080
183167
|
osRelease = await osReleaseDetector.detectStatically(extractedLayers, dockerfileAnalysis);
|
|
183081
183168
|
}
|
|
183082
183169
|
catch (err) {
|
|
183083
|
-
debug(`Could not detect OS release: ${err}`);
|
|
183170
|
+
debug(`Could not detect OS release: ${err.message}`);
|
|
183084
183171
|
throw new Error("Failed to detect OS release");
|
|
183085
183172
|
}
|
|
183086
183173
|
const redHatRepositories = (0, static_10.getRedHatRepositoriesFromExtractedLayers)(extractedLayers);
|
|
@@ -183095,7 +183182,7 @@ async function analyze(targetImage, dockerfileAnalysis, imageType, imagePath, gl
|
|
|
183095
183182
|
]);
|
|
183096
183183
|
}
|
|
183097
183184
|
catch (err) {
|
|
183098
|
-
debug(`Could not detect installed OS packages: ${err}`);
|
|
183185
|
+
debug(`Could not detect installed OS packages: ${err.message}`);
|
|
183099
183186
|
throw new Error("Failed to detect installed OS packages");
|
|
183100
183187
|
}
|
|
183101
183188
|
const binaries = (0, static_3.getBinariesHashes)(extractedLayers);
|
|
@@ -183280,6 +183367,7 @@ function buildTree(targetImage, packageFormat, depInfosList, targetOS) {
|
|
|
183280
183367
|
const pkg = {
|
|
183281
183368
|
name: depFullName(depInfo),
|
|
183282
183369
|
version: depInfo.Version,
|
|
183370
|
+
sourceVersion: depInfo.SourceVersion,
|
|
183283
183371
|
};
|
|
183284
183372
|
metaSubtree.dependencies[pkg.name] = pkg;
|
|
183285
183373
|
}
|
|
@@ -184118,7 +184206,7 @@ async function extractArchive(dockerArchiveFilesystemPath, extractActions) {
|
|
|
184118
184206
|
layers[normalizedName] = await (0, layer_1.extractImageLayer)(stream, extractActions);
|
|
184119
184207
|
}
|
|
184120
184208
|
catch (error) {
|
|
184121
|
-
debug(`Error extracting layer content from: '${error}'`);
|
|
184209
|
+
debug(`Error extracting layer content from: '${error.message}'`);
|
|
184122
184210
|
reject(new Error("Error reading tar archive"));
|
|
184123
184211
|
}
|
|
184124
184212
|
}
|
|
@@ -184138,7 +184226,7 @@ async function extractArchive(dockerArchiveFilesystemPath, extractActions) {
|
|
|
184138
184226
|
resolve(getLayersContentAndArchiveManifest(manifest, imageConfig, layers));
|
|
184139
184227
|
}
|
|
184140
184228
|
catch (error) {
|
|
184141
|
-
debug(`Error getting layers and manifest content from docker archive: ${error}`);
|
|
184229
|
+
debug(`Error getting layers and manifest content from docker archive: ${error.message}`);
|
|
184142
184230
|
reject(new __1.InvalidArchiveError("Invalid Docker archive"));
|
|
184143
184231
|
}
|
|
184144
184232
|
});
|
|
@@ -184555,7 +184643,7 @@ async function extractImageLayer(layerTarStream, extractActions) {
|
|
|
184555
184643
|
}
|
|
184556
184644
|
catch (error) {
|
|
184557
184645
|
// An ExtractAction has thrown an uncaught exception, likely a bug in the code!
|
|
184558
|
-
debug(`Exception thrown while applying callbacks during image layer extraction: ${error}`);
|
|
184646
|
+
debug(`Exception thrown while applying callbacks during image layer extraction: ${error.message}`);
|
|
184559
184647
|
reject(error);
|
|
184560
184648
|
}
|
|
184561
184649
|
}
|
|
@@ -184681,7 +184769,7 @@ async function extractArchive(ociArchiveFilesystemPath, extractActions) {
|
|
|
184681
184769
|
resolve(getLayersContentAndArchiveManifest(mainIndexFile, manifests, indexFiles, imageConfig, layers));
|
|
184682
184770
|
}
|
|
184683
184771
|
catch (error) {
|
|
184684
|
-
debug(`Error getting layers and manifest content from oci archive: '${error}'`);
|
|
184772
|
+
debug(`Error getting layers and manifest content from oci archive: '${error.message}'`);
|
|
184685
184773
|
reject(new __1.InvalidArchiveError("Invalid OCI archive"));
|
|
184686
184774
|
}
|
|
184687
184775
|
});
|
|
@@ -185337,7 +185425,7 @@ async function goModulesToScannedProjects(filePathToContent) {
|
|
|
185337
185425
|
});
|
|
185338
185426
|
}
|
|
185339
185427
|
catch (err) {
|
|
185340
|
-
debug(`Go binary scan for file ${filePath} failed: ${err}`);
|
|
185428
|
+
debug(`Go binary scan for file ${filePath} failed: ${err.message}`);
|
|
185341
185429
|
}
|
|
185342
185430
|
}
|
|
185343
185431
|
return scanResults;
|
|
@@ -186161,7 +186249,7 @@ async function getRpmDbFileContent(extractedLayers) {
|
|
|
186161
186249
|
return parserResponse.response;
|
|
186162
186250
|
}
|
|
186163
186251
|
catch (error) {
|
|
186164
|
-
debug(`An error occurred while analysing RPM packages: ${error}`);
|
|
186252
|
+
debug(`An error occurred while analysing RPM packages: ${error.message}`);
|
|
186165
186253
|
return [];
|
|
186166
186254
|
}
|
|
186167
186255
|
}
|
|
@@ -186179,7 +186267,7 @@ async function getRpmSqliteDbFileContent(extractedLayers) {
|
|
|
186179
186267
|
return results.response;
|
|
186180
186268
|
}
|
|
186181
186269
|
catch (error) {
|
|
186182
|
-
debug(`An error occurred while analysing RPM packages: ${error}`);
|
|
186270
|
+
debug(`An error occurred while analysing RPM packages: ${error.message}`);
|
|
186183
186271
|
return [];
|
|
186184
186272
|
}
|
|
186185
186273
|
}
|
|
@@ -186628,6 +186716,7 @@ const fs = __webpack_require__(57147);
|
|
|
186628
186716
|
const path = __webpack_require__(71017);
|
|
186629
186717
|
const image_inspector_1 = __webpack_require__(95710);
|
|
186630
186718
|
const dockerfile_1 = __webpack_require__(79652);
|
|
186719
|
+
const image_1 = __webpack_require__(92748);
|
|
186631
186720
|
const image_save_path_1 = __webpack_require__(89313);
|
|
186632
186721
|
const image_type_1 = __webpack_require__(38932);
|
|
186633
186722
|
const option_utils_1 = __webpack_require__(48587);
|
|
@@ -186678,7 +186767,7 @@ async function scan(options) {
|
|
|
186678
186767
|
}
|
|
186679
186768
|
exports.scan = scan;
|
|
186680
186769
|
async function localArchiveAnalysis(targetImage, imageType, dockerfileAnalysis, options) {
|
|
186681
|
-
var _a, _b;
|
|
186770
|
+
var _a, _b, _c, _d, _e, _f;
|
|
186682
186771
|
const globToFind = {
|
|
186683
186772
|
include: ((_a = options.globsToFind) === null || _a === void 0 ? void 0 : _a.include) || [],
|
|
186684
186773
|
exclude: ((_b = options.globsToFind) === null || _b === void 0 ? void 0 : _b.exclude) || [],
|
|
@@ -186693,7 +186782,15 @@ async function localArchiveAnalysis(targetImage, imageType, dockerfileAnalysis,
|
|
|
186693
186782
|
const imageIdentifier = options.imageNameAndTag ||
|
|
186694
186783
|
// The target image becomes the base of the path, e.g. "archive.tar" for "/var/tmp/archive.tar"
|
|
186695
186784
|
path.basename(archivePath);
|
|
186696
|
-
|
|
186785
|
+
let imageName;
|
|
186786
|
+
if ((((_c = options.digests) === null || _c === void 0 ? void 0 : _c.manifest) || ((_d = options.digests) === null || _d === void 0 ? void 0 : _d.index)) &&
|
|
186787
|
+
options.imageNameAndTag) {
|
|
186788
|
+
imageName = new image_1.ImageName(options.imageNameAndTag, {
|
|
186789
|
+
manifest: (_e = options.digests) === null || _e === void 0 ? void 0 : _e.manifest,
|
|
186790
|
+
index: (_f = options.digests) === null || _f === void 0 ? void 0 : _f.index,
|
|
186791
|
+
});
|
|
186792
|
+
}
|
|
186793
|
+
return await staticModule.analyzeStatically(imageIdentifier, dockerfileAnalysis, imageType, archivePath, globToFind, options, imageName);
|
|
186697
186794
|
}
|
|
186698
186795
|
async function imageIdentifierAnalysis(targetImage, imageType, dockerfileAnalysis, options) {
|
|
186699
186796
|
var _a, _b;
|
|
@@ -186850,7 +186947,7 @@ exports.streamToJson = streamToJson;
|
|
|
186850
186947
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
186851
186948
|
exports.execute = void 0;
|
|
186852
186949
|
const childProcess = __webpack_require__(32081);
|
|
186853
|
-
const shescape_1 = __webpack_require__(
|
|
186950
|
+
const shescape_1 = __webpack_require__(66710);
|
|
186854
186951
|
function execute(command, args, options) {
|
|
186855
186952
|
const spawnOptions = { shell: true, env: process.env };
|
|
186856
186953
|
if (options && options.cwd) {
|
|
@@ -187934,6 +188031,7 @@ class Comparator {
|
|
|
187934
188031
|
}
|
|
187935
188032
|
}
|
|
187936
188033
|
|
|
188034
|
+
comp = comp.trim().split(/\s+/).join(' ')
|
|
187937
188035
|
debug('comparator', comp, options)
|
|
187938
188036
|
this.options = options
|
|
187939
188037
|
this.loose = !!options.loose
|
|
@@ -187996,13 +188094,6 @@ class Comparator {
|
|
|
187996
188094
|
throw new TypeError('a Comparator is required')
|
|
187997
188095
|
}
|
|
187998
188096
|
|
|
187999
|
-
if (!options || typeof options !== 'object') {
|
|
188000
|
-
options = {
|
|
188001
|
-
loose: !!options,
|
|
188002
|
-
includePrerelease: false,
|
|
188003
|
-
}
|
|
188004
|
-
}
|
|
188005
|
-
|
|
188006
188097
|
if (this.operator === '') {
|
|
188007
188098
|
if (this.value === '') {
|
|
188008
188099
|
return true
|
|
@@ -188015,39 +188106,50 @@ class Comparator {
|
|
|
188015
188106
|
return new Range(this.value, options).test(comp.semver)
|
|
188016
188107
|
}
|
|
188017
188108
|
|
|
188018
|
-
|
|
188019
|
-
(this.operator === '>=' || this.operator === '>') &&
|
|
188020
|
-
(comp.operator === '>=' || comp.operator === '>')
|
|
188021
|
-
const sameDirectionDecreasing =
|
|
188022
|
-
(this.operator === '<=' || this.operator === '<') &&
|
|
188023
|
-
(comp.operator === '<=' || comp.operator === '<')
|
|
188024
|
-
const sameSemVer = this.semver.version === comp.semver.version
|
|
188025
|
-
const differentDirectionsInclusive =
|
|
188026
|
-
(this.operator === '>=' || this.operator === '<=') &&
|
|
188027
|
-
(comp.operator === '>=' || comp.operator === '<=')
|
|
188028
|
-
const oppositeDirectionsLessThan =
|
|
188029
|
-
cmp(this.semver, '<', comp.semver, options) &&
|
|
188030
|
-
(this.operator === '>=' || this.operator === '>') &&
|
|
188031
|
-
(comp.operator === '<=' || comp.operator === '<')
|
|
188032
|
-
const oppositeDirectionsGreaterThan =
|
|
188033
|
-
cmp(this.semver, '>', comp.semver, options) &&
|
|
188034
|
-
(this.operator === '<=' || this.operator === '<') &&
|
|
188035
|
-
(comp.operator === '>=' || comp.operator === '>')
|
|
188109
|
+
options = parseOptions(options)
|
|
188036
188110
|
|
|
188037
|
-
|
|
188038
|
-
|
|
188039
|
-
|
|
188040
|
-
|
|
188041
|
-
|
|
188042
|
-
|
|
188043
|
-
|
|
188111
|
+
// Special cases where nothing can possibly be lower
|
|
188112
|
+
if (options.includePrerelease &&
|
|
188113
|
+
(this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
|
|
188114
|
+
return false
|
|
188115
|
+
}
|
|
188116
|
+
if (!options.includePrerelease &&
|
|
188117
|
+
(this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
|
|
188118
|
+
return false
|
|
188119
|
+
}
|
|
188120
|
+
|
|
188121
|
+
// Same direction increasing (> or >=)
|
|
188122
|
+
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
|
|
188123
|
+
return true
|
|
188124
|
+
}
|
|
188125
|
+
// Same direction decreasing (< or <=)
|
|
188126
|
+
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
|
|
188127
|
+
return true
|
|
188128
|
+
}
|
|
188129
|
+
// same SemVer and both sides are inclusive (<= or >=)
|
|
188130
|
+
if (
|
|
188131
|
+
(this.semver.version === comp.semver.version) &&
|
|
188132
|
+
this.operator.includes('=') && comp.operator.includes('=')) {
|
|
188133
|
+
return true
|
|
188134
|
+
}
|
|
188135
|
+
// opposite directions less than
|
|
188136
|
+
if (cmp(this.semver, '<', comp.semver, options) &&
|
|
188137
|
+
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
|
|
188138
|
+
return true
|
|
188139
|
+
}
|
|
188140
|
+
// opposite directions greater than
|
|
188141
|
+
if (cmp(this.semver, '>', comp.semver, options) &&
|
|
188142
|
+
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
|
|
188143
|
+
return true
|
|
188144
|
+
}
|
|
188145
|
+
return false
|
|
188044
188146
|
}
|
|
188045
188147
|
}
|
|
188046
188148
|
|
|
188047
188149
|
module.exports = Comparator
|
|
188048
188150
|
|
|
188049
188151
|
const parseOptions = __webpack_require__(40932)
|
|
188050
|
-
const { re, t } = __webpack_require__(92805)
|
|
188152
|
+
const { safeRe: re, t } = __webpack_require__(92805)
|
|
188051
188153
|
const cmp = __webpack_require__(36650)
|
|
188052
188154
|
const debug = __webpack_require__(25078)
|
|
188053
188155
|
const SemVer = __webpack_require__(96769)
|
|
@@ -188087,9 +188189,16 @@ class Range {
|
|
|
188087
188189
|
this.loose = !!options.loose
|
|
188088
188190
|
this.includePrerelease = !!options.includePrerelease
|
|
188089
188191
|
|
|
188090
|
-
// First
|
|
188192
|
+
// First reduce all whitespace as much as possible so we do not have to rely
|
|
188193
|
+
// on potentially slow regexes like \s*. This is then stored and used for
|
|
188194
|
+
// future error messages as well.
|
|
188091
188195
|
this.raw = range
|
|
188092
|
-
|
|
188196
|
+
.trim()
|
|
188197
|
+
.split(/\s+/)
|
|
188198
|
+
.join(' ')
|
|
188199
|
+
|
|
188200
|
+
// First, split on ||
|
|
188201
|
+
this.set = this.raw
|
|
188093
188202
|
.split('||')
|
|
188094
188203
|
// map the range to a 2d array of comparators
|
|
188095
188204
|
.map(r => this.parseRange(r.trim()))
|
|
@@ -188099,7 +188208,7 @@ class Range {
|
|
|
188099
188208
|
.filter(c => c.length)
|
|
188100
188209
|
|
|
188101
188210
|
if (!this.set.length) {
|
|
188102
|
-
throw new TypeError(`Invalid SemVer Range: ${
|
|
188211
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
|
|
188103
188212
|
}
|
|
188104
188213
|
|
|
188105
188214
|
// if we have any that are not the null set, throw out null sets.
|
|
@@ -188125,9 +188234,7 @@ class Range {
|
|
|
188125
188234
|
|
|
188126
188235
|
format () {
|
|
188127
188236
|
this.range = this.set
|
|
188128
|
-
.map((comps) =>
|
|
188129
|
-
return comps.join(' ').trim()
|
|
188130
|
-
})
|
|
188237
|
+
.map((comps) => comps.join(' ').trim())
|
|
188131
188238
|
.join('||')
|
|
188132
188239
|
.trim()
|
|
188133
188240
|
return this.range
|
|
@@ -188138,12 +188245,12 @@ class Range {
|
|
|
188138
188245
|
}
|
|
188139
188246
|
|
|
188140
188247
|
parseRange (range) {
|
|
188141
|
-
range = range.trim()
|
|
188142
|
-
|
|
188143
188248
|
// memoize range parsing for performance.
|
|
188144
188249
|
// this is a very hot path, and fully deterministic.
|
|
188145
|
-
const memoOpts =
|
|
188146
|
-
|
|
188250
|
+
const memoOpts =
|
|
188251
|
+
(this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
|
|
188252
|
+
(this.options.loose && FLAG_LOOSE)
|
|
188253
|
+
const memoKey = memoOpts + ':' + range
|
|
188147
188254
|
const cached = cache.get(memoKey)
|
|
188148
188255
|
if (cached) {
|
|
188149
188256
|
return cached
|
|
@@ -188154,18 +188261,18 @@ class Range {
|
|
|
188154
188261
|
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
|
|
188155
188262
|
range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
|
|
188156
188263
|
debug('hyphen replace', range)
|
|
188264
|
+
|
|
188157
188265
|
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
188158
188266
|
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
|
188159
188267
|
debug('comparator trim', range)
|
|
188160
188268
|
|
|
188161
188269
|
// `~ 1.2.3` => `~1.2.3`
|
|
188162
188270
|
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
|
|
188271
|
+
debug('tilde trim', range)
|
|
188163
188272
|
|
|
188164
188273
|
// `^ 1.2.3` => `^1.2.3`
|
|
188165
188274
|
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
|
|
188166
|
-
|
|
188167
|
-
// normalize spaces
|
|
188168
|
-
range = range.split(/\s+/).join(' ')
|
|
188275
|
+
debug('caret trim', range)
|
|
188169
188276
|
|
|
188170
188277
|
// At this point, the range is completely trimmed and
|
|
188171
188278
|
// ready to be split into comparators.
|
|
@@ -188251,6 +188358,7 @@ class Range {
|
|
|
188251
188358
|
return false
|
|
188252
188359
|
}
|
|
188253
188360
|
}
|
|
188361
|
+
|
|
188254
188362
|
module.exports = Range
|
|
188255
188363
|
|
|
188256
188364
|
const LRU = __webpack_require__(68994)
|
|
@@ -188261,12 +188369,13 @@ const Comparator = __webpack_require__(60377)
|
|
|
188261
188369
|
const debug = __webpack_require__(25078)
|
|
188262
188370
|
const SemVer = __webpack_require__(96769)
|
|
188263
188371
|
const {
|
|
188264
|
-
re,
|
|
188372
|
+
safeRe: re,
|
|
188265
188373
|
t,
|
|
188266
188374
|
comparatorTrimReplace,
|
|
188267
188375
|
tildeTrimReplace,
|
|
188268
188376
|
caretTrimReplace,
|
|
188269
188377
|
} = __webpack_require__(92805)
|
|
188378
|
+
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = __webpack_require__(32094)
|
|
188270
188379
|
|
|
188271
188380
|
const isNullSet = c => c.value === '<0.0.0-0'
|
|
188272
188381
|
const isAny = c => c.value === ''
|
|
@@ -188314,10 +188423,13 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
|
|
188314
188423
|
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
|
188315
188424
|
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
|
188316
188425
|
// ~0.0.1 --> >=0.0.1 <0.1.0-0
|
|
188317
|
-
const replaceTildes = (comp, options) =>
|
|
188318
|
-
comp
|
|
188319
|
-
|
|
188320
|
-
|
|
188426
|
+
const replaceTildes = (comp, options) => {
|
|
188427
|
+
return comp
|
|
188428
|
+
.trim()
|
|
188429
|
+
.split(/\s+/)
|
|
188430
|
+
.map((c) => replaceTilde(c, options))
|
|
188431
|
+
.join(' ')
|
|
188432
|
+
}
|
|
188321
188433
|
|
|
188322
188434
|
const replaceTilde = (comp, options) => {
|
|
188323
188435
|
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
|
|
@@ -188355,10 +188467,13 @@ const replaceTilde = (comp, options) => {
|
|
|
188355
188467
|
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
|
188356
188468
|
// ^0.0.1 --> >=0.0.1 <0.0.2-0
|
|
188357
188469
|
// ^0.1.0 --> >=0.1.0 <0.2.0-0
|
|
188358
|
-
const replaceCarets = (comp, options) =>
|
|
188359
|
-
comp
|
|
188360
|
-
|
|
188361
|
-
|
|
188470
|
+
const replaceCarets = (comp, options) => {
|
|
188471
|
+
return comp
|
|
188472
|
+
.trim()
|
|
188473
|
+
.split(/\s+/)
|
|
188474
|
+
.map((c) => replaceCaret(c, options))
|
|
188475
|
+
.join(' ')
|
|
188476
|
+
}
|
|
188362
188477
|
|
|
188363
188478
|
const replaceCaret = (comp, options) => {
|
|
188364
188479
|
debug('caret', comp, options)
|
|
@@ -188415,9 +188530,10 @@ const replaceCaret = (comp, options) => {
|
|
|
188415
188530
|
|
|
188416
188531
|
const replaceXRanges = (comp, options) => {
|
|
188417
188532
|
debug('replaceXRanges', comp, options)
|
|
188418
|
-
return comp
|
|
188419
|
-
|
|
188420
|
-
|
|
188533
|
+
return comp
|
|
188534
|
+
.split(/\s+/)
|
|
188535
|
+
.map((c) => replaceXRange(c, options))
|
|
188536
|
+
.join(' ')
|
|
188421
188537
|
}
|
|
188422
188538
|
|
|
188423
188539
|
const replaceXRange = (comp, options) => {
|
|
@@ -188500,12 +188616,15 @@ const replaceXRange = (comp, options) => {
|
|
|
188500
188616
|
const replaceStars = (comp, options) => {
|
|
188501
188617
|
debug('replaceStars', comp, options)
|
|
188502
188618
|
// Looseness is ignored here. star is always as loose as it gets!
|
|
188503
|
-
return comp
|
|
188619
|
+
return comp
|
|
188620
|
+
.trim()
|
|
188621
|
+
.replace(re[t.STAR], '')
|
|
188504
188622
|
}
|
|
188505
188623
|
|
|
188506
188624
|
const replaceGTE0 = (comp, options) => {
|
|
188507
188625
|
debug('replaceGTE0', comp, options)
|
|
188508
|
-
return comp
|
|
188626
|
+
return comp
|
|
188627
|
+
.trim()
|
|
188509
188628
|
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
|
|
188510
188629
|
}
|
|
188511
188630
|
|
|
@@ -188543,7 +188662,7 @@ const hyphenReplace = incPr => ($0,
|
|
|
188543
188662
|
to = `<=${to}`
|
|
188544
188663
|
}
|
|
188545
188664
|
|
|
188546
|
-
return
|
|
188665
|
+
return `${from} ${to}`.trim()
|
|
188547
188666
|
}
|
|
188548
188667
|
|
|
188549
188668
|
const testSet = (set, version, options) => {
|
|
@@ -188590,7 +188709,7 @@ const testSet = (set, version, options) => {
|
|
|
188590
188709
|
|
|
188591
188710
|
const debug = __webpack_require__(25078)
|
|
188592
188711
|
const { MAX_LENGTH, MAX_SAFE_INTEGER } = __webpack_require__(32094)
|
|
188593
|
-
const { re, t } = __webpack_require__(92805)
|
|
188712
|
+
const { safeRe: re, t } = __webpack_require__(92805)
|
|
188594
188713
|
|
|
188595
188714
|
const parseOptions = __webpack_require__(40932)
|
|
188596
188715
|
const { compareIdentifiers } = __webpack_require__(81960)
|
|
@@ -188606,7 +188725,7 @@ class SemVer {
|
|
|
188606
188725
|
version = version.version
|
|
188607
188726
|
}
|
|
188608
188727
|
} else if (typeof version !== 'string') {
|
|
188609
|
-
throw new TypeError(`Invalid
|
|
188728
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
|
|
188610
188729
|
}
|
|
188611
188730
|
|
|
188612
188731
|
if (version.length > MAX_LENGTH) {
|
|
@@ -188765,36 +188884,36 @@ class SemVer {
|
|
|
188765
188884
|
|
|
188766
188885
|
// preminor will bump the version up to the next minor release, and immediately
|
|
188767
188886
|
// down to pre-release. premajor and prepatch work the same way.
|
|
188768
|
-
inc (release, identifier) {
|
|
188887
|
+
inc (release, identifier, identifierBase) {
|
|
188769
188888
|
switch (release) {
|
|
188770
188889
|
case 'premajor':
|
|
188771
188890
|
this.prerelease.length = 0
|
|
188772
188891
|
this.patch = 0
|
|
188773
188892
|
this.minor = 0
|
|
188774
188893
|
this.major++
|
|
188775
|
-
this.inc('pre', identifier)
|
|
188894
|
+
this.inc('pre', identifier, identifierBase)
|
|
188776
188895
|
break
|
|
188777
188896
|
case 'preminor':
|
|
188778
188897
|
this.prerelease.length = 0
|
|
188779
188898
|
this.patch = 0
|
|
188780
188899
|
this.minor++
|
|
188781
|
-
this.inc('pre', identifier)
|
|
188900
|
+
this.inc('pre', identifier, identifierBase)
|
|
188782
188901
|
break
|
|
188783
188902
|
case 'prepatch':
|
|
188784
188903
|
// If this is already a prerelease, it will bump to the next version
|
|
188785
188904
|
// drop any prereleases that might already exist, since they are not
|
|
188786
188905
|
// relevant at this point.
|
|
188787
188906
|
this.prerelease.length = 0
|
|
188788
|
-
this.inc('patch', identifier)
|
|
188789
|
-
this.inc('pre', identifier)
|
|
188907
|
+
this.inc('patch', identifier, identifierBase)
|
|
188908
|
+
this.inc('pre', identifier, identifierBase)
|
|
188790
188909
|
break
|
|
188791
188910
|
// If the input is a non-prerelease version, this acts the same as
|
|
188792
188911
|
// prepatch.
|
|
188793
188912
|
case 'prerelease':
|
|
188794
188913
|
if (this.prerelease.length === 0) {
|
|
188795
|
-
this.inc('patch', identifier)
|
|
188914
|
+
this.inc('patch', identifier, identifierBase)
|
|
188796
188915
|
}
|
|
188797
|
-
this.inc('pre', identifier)
|
|
188916
|
+
this.inc('pre', identifier, identifierBase)
|
|
188798
188917
|
break
|
|
188799
188918
|
|
|
188800
188919
|
case 'major':
|
|
@@ -188836,9 +188955,15 @@ class SemVer {
|
|
|
188836
188955
|
break
|
|
188837
188956
|
// This probably shouldn't be used publicly.
|
|
188838
188957
|
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
188839
|
-
case 'pre':
|
|
188958
|
+
case 'pre': {
|
|
188959
|
+
const base = Number(identifierBase) ? 1 : 0
|
|
188960
|
+
|
|
188961
|
+
if (!identifier && identifierBase === false) {
|
|
188962
|
+
throw new Error('invalid increment argument: identifier is empty')
|
|
188963
|
+
}
|
|
188964
|
+
|
|
188840
188965
|
if (this.prerelease.length === 0) {
|
|
188841
|
-
this.prerelease = [
|
|
188966
|
+
this.prerelease = [base]
|
|
188842
188967
|
} else {
|
|
188843
188968
|
let i = this.prerelease.length
|
|
188844
188969
|
while (--i >= 0) {
|
|
@@ -188849,27 +188974,36 @@ class SemVer {
|
|
|
188849
188974
|
}
|
|
188850
188975
|
if (i === -1) {
|
|
188851
188976
|
// didn't increment anything
|
|
188852
|
-
this.prerelease.
|
|
188977
|
+
if (identifier === this.prerelease.join('.') && identifierBase === false) {
|
|
188978
|
+
throw new Error('invalid increment argument: identifier already exists')
|
|
188979
|
+
}
|
|
188980
|
+
this.prerelease.push(base)
|
|
188853
188981
|
}
|
|
188854
188982
|
}
|
|
188855
188983
|
if (identifier) {
|
|
188856
188984
|
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
188857
188985
|
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
188986
|
+
let prerelease = [identifier, base]
|
|
188987
|
+
if (identifierBase === false) {
|
|
188988
|
+
prerelease = [identifier]
|
|
188989
|
+
}
|
|
188858
188990
|
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
188859
188991
|
if (isNaN(this.prerelease[1])) {
|
|
188860
|
-
this.prerelease =
|
|
188992
|
+
this.prerelease = prerelease
|
|
188861
188993
|
}
|
|
188862
188994
|
} else {
|
|
188863
|
-
this.prerelease =
|
|
188995
|
+
this.prerelease = prerelease
|
|
188864
188996
|
}
|
|
188865
188997
|
}
|
|
188866
188998
|
break
|
|
188867
|
-
|
|
188999
|
+
}
|
|
188868
189000
|
default:
|
|
188869
189001
|
throw new Error(`invalid increment argument: ${release}`)
|
|
188870
189002
|
}
|
|
188871
|
-
this.format()
|
|
188872
|
-
this.
|
|
189003
|
+
this.raw = this.format()
|
|
189004
|
+
if (this.build.length) {
|
|
189005
|
+
this.raw += `+${this.build.join('.')}`
|
|
189006
|
+
}
|
|
188873
189007
|
return this
|
|
188874
189008
|
}
|
|
188875
189009
|
}
|
|
@@ -188956,7 +189090,7 @@ module.exports = cmp
|
|
|
188956
189090
|
|
|
188957
189091
|
const SemVer = __webpack_require__(96769)
|
|
188958
189092
|
const parse = __webpack_require__(763)
|
|
188959
|
-
const { re, t } = __webpack_require__(92805)
|
|
189093
|
+
const { safeRe: re, t } = __webpack_require__(92805)
|
|
188960
189094
|
|
|
188961
189095
|
const coerce = (version, options) => {
|
|
188962
189096
|
if (version instanceof SemVer) {
|
|
@@ -189050,27 +189184,69 @@ module.exports = compare
|
|
|
189050
189184
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
189051
189185
|
|
|
189052
189186
|
const parse = __webpack_require__(763)
|
|
189053
|
-
const eq = __webpack_require__(17771)
|
|
189054
189187
|
|
|
189055
189188
|
const diff = (version1, version2) => {
|
|
189056
|
-
|
|
189189
|
+
const v1 = parse(version1, null, true)
|
|
189190
|
+
const v2 = parse(version2, null, true)
|
|
189191
|
+
const comparison = v1.compare(v2)
|
|
189192
|
+
|
|
189193
|
+
if (comparison === 0) {
|
|
189057
189194
|
return null
|
|
189058
|
-
}
|
|
189059
|
-
|
|
189060
|
-
|
|
189061
|
-
|
|
189062
|
-
|
|
189063
|
-
|
|
189064
|
-
|
|
189065
|
-
|
|
189066
|
-
|
|
189067
|
-
|
|
189068
|
-
|
|
189069
|
-
|
|
189195
|
+
}
|
|
189196
|
+
|
|
189197
|
+
const v1Higher = comparison > 0
|
|
189198
|
+
const highVersion = v1Higher ? v1 : v2
|
|
189199
|
+
const lowVersion = v1Higher ? v2 : v1
|
|
189200
|
+
const highHasPre = !!highVersion.prerelease.length
|
|
189201
|
+
const lowHasPre = !!lowVersion.prerelease.length
|
|
189202
|
+
|
|
189203
|
+
if (lowHasPre && !highHasPre) {
|
|
189204
|
+
// Going from prerelease -> no prerelease requires some special casing
|
|
189205
|
+
|
|
189206
|
+
// If the low version has only a major, then it will always be a major
|
|
189207
|
+
// Some examples:
|
|
189208
|
+
// 1.0.0-1 -> 1.0.0
|
|
189209
|
+
// 1.0.0-1 -> 1.1.1
|
|
189210
|
+
// 1.0.0-1 -> 2.0.0
|
|
189211
|
+
if (!lowVersion.patch && !lowVersion.minor) {
|
|
189212
|
+
return 'major'
|
|
189070
189213
|
}
|
|
189071
|
-
|
|
189214
|
+
|
|
189215
|
+
// Otherwise it can be determined by checking the high version
|
|
189216
|
+
|
|
189217
|
+
if (highVersion.patch) {
|
|
189218
|
+
// anything higher than a patch bump would result in the wrong version
|
|
189219
|
+
return 'patch'
|
|
189220
|
+
}
|
|
189221
|
+
|
|
189222
|
+
if (highVersion.minor) {
|
|
189223
|
+
// anything higher than a minor bump would result in the wrong version
|
|
189224
|
+
return 'minor'
|
|
189225
|
+
}
|
|
189226
|
+
|
|
189227
|
+
// bumping major/minor/patch all have same result
|
|
189228
|
+
return 'major'
|
|
189072
189229
|
}
|
|
189230
|
+
|
|
189231
|
+
// add the `pre` prefix if we are going to a prerelease version
|
|
189232
|
+
const prefix = highHasPre ? 'pre' : ''
|
|
189233
|
+
|
|
189234
|
+
if (v1.major !== v2.major) {
|
|
189235
|
+
return prefix + 'major'
|
|
189236
|
+
}
|
|
189237
|
+
|
|
189238
|
+
if (v1.minor !== v2.minor) {
|
|
189239
|
+
return prefix + 'minor'
|
|
189240
|
+
}
|
|
189241
|
+
|
|
189242
|
+
if (v1.patch !== v2.patch) {
|
|
189243
|
+
return prefix + 'patch'
|
|
189244
|
+
}
|
|
189245
|
+
|
|
189246
|
+
// high and low are preleases
|
|
189247
|
+
return 'prerelease'
|
|
189073
189248
|
}
|
|
189249
|
+
|
|
189074
189250
|
module.exports = diff
|
|
189075
189251
|
|
|
189076
189252
|
|
|
@@ -189111,8 +189287,9 @@ module.exports = gte
|
|
|
189111
189287
|
|
|
189112
189288
|
const SemVer = __webpack_require__(96769)
|
|
189113
189289
|
|
|
189114
|
-
const inc = (version, release, options, identifier) => {
|
|
189290
|
+
const inc = (version, release, options, identifier, identifierBase) => {
|
|
189115
189291
|
if (typeof (options) === 'string') {
|
|
189292
|
+
identifierBase = identifier
|
|
189116
189293
|
identifier = options
|
|
189117
189294
|
options = undefined
|
|
189118
189295
|
}
|
|
@@ -189121,7 +189298,7 @@ const inc = (version, release, options, identifier) => {
|
|
|
189121
189298
|
return new SemVer(
|
|
189122
189299
|
version instanceof SemVer ? version.version : version,
|
|
189123
189300
|
options
|
|
189124
|
-
).inc(release, identifier).version
|
|
189301
|
+
).inc(release, identifier, identifierBase).version
|
|
189125
189302
|
} catch (er) {
|
|
189126
189303
|
return null
|
|
189127
189304
|
}
|
|
@@ -189184,35 +189361,18 @@ module.exports = neq
|
|
|
189184
189361
|
/***/ 763:
|
|
189185
189362
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
189186
189363
|
|
|
189187
|
-
const { MAX_LENGTH } = __webpack_require__(32094)
|
|
189188
|
-
const { re, t } = __webpack_require__(92805)
|
|
189189
189364
|
const SemVer = __webpack_require__(96769)
|
|
189190
|
-
|
|
189191
|
-
const parseOptions = __webpack_require__(40932)
|
|
189192
|
-
const parse = (version, options) => {
|
|
189193
|
-
options = parseOptions(options)
|
|
189194
|
-
|
|
189365
|
+
const parse = (version, options, throwErrors = false) => {
|
|
189195
189366
|
if (version instanceof SemVer) {
|
|
189196
189367
|
return version
|
|
189197
189368
|
}
|
|
189198
|
-
|
|
189199
|
-
if (typeof version !== 'string') {
|
|
189200
|
-
return null
|
|
189201
|
-
}
|
|
189202
|
-
|
|
189203
|
-
if (version.length > MAX_LENGTH) {
|
|
189204
|
-
return null
|
|
189205
|
-
}
|
|
189206
|
-
|
|
189207
|
-
const r = options.loose ? re[t.LOOSE] : re[t.FULL]
|
|
189208
|
-
if (!r.test(version)) {
|
|
189209
|
-
return null
|
|
189210
|
-
}
|
|
189211
|
-
|
|
189212
189369
|
try {
|
|
189213
189370
|
return new SemVer(version, options)
|
|
189214
189371
|
} catch (er) {
|
|
189215
|
-
|
|
189372
|
+
if (!throwErrors) {
|
|
189373
|
+
return null
|
|
189374
|
+
}
|
|
189375
|
+
throw er
|
|
189216
189376
|
}
|
|
189217
189377
|
}
|
|
189218
189378
|
|
|
@@ -189392,6 +189552,7 @@ module.exports = {
|
|
|
189392
189552
|
src: internalRe.src,
|
|
189393
189553
|
tokens: internalRe.t,
|
|
189394
189554
|
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
189555
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
189395
189556
|
compareIdentifiers: identifiers.compareIdentifiers,
|
|
189396
189557
|
rcompareIdentifiers: identifiers.rcompareIdentifiers,
|
|
189397
189558
|
}
|
|
@@ -189413,11 +189574,29 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
|
189413
189574
|
// Max safe segment length for coercion.
|
|
189414
189575
|
const MAX_SAFE_COMPONENT_LENGTH = 16
|
|
189415
189576
|
|
|
189577
|
+
// Max safe length for a build identifier. The max length minus 6 characters for
|
|
189578
|
+
// the shortest version with a build 0.0.0+BUILD.
|
|
189579
|
+
const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
|
|
189580
|
+
|
|
189581
|
+
const RELEASE_TYPES = [
|
|
189582
|
+
'major',
|
|
189583
|
+
'premajor',
|
|
189584
|
+
'minor',
|
|
189585
|
+
'preminor',
|
|
189586
|
+
'patch',
|
|
189587
|
+
'prepatch',
|
|
189588
|
+
'prerelease',
|
|
189589
|
+
]
|
|
189590
|
+
|
|
189416
189591
|
module.exports = {
|
|
189417
|
-
SEMVER_SPEC_VERSION,
|
|
189418
189592
|
MAX_LENGTH,
|
|
189419
|
-
MAX_SAFE_INTEGER,
|
|
189420
189593
|
MAX_SAFE_COMPONENT_LENGTH,
|
|
189594
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
189595
|
+
MAX_SAFE_INTEGER,
|
|
189596
|
+
RELEASE_TYPES,
|
|
189597
|
+
SEMVER_SPEC_VERSION,
|
|
189598
|
+
FLAG_INCLUDE_PRERELEASE: 0b001,
|
|
189599
|
+
FLAG_LOOSE: 0b010,
|
|
189421
189600
|
}
|
|
189422
189601
|
|
|
189423
189602
|
|
|
@@ -189472,16 +189651,20 @@ module.exports = {
|
|
|
189472
189651
|
/***/ 40932:
|
|
189473
189652
|
/***/ ((module) => {
|
|
189474
189653
|
|
|
189475
|
-
// parse out just the options we care about
|
|
189476
|
-
|
|
189477
|
-
const
|
|
189478
|
-
const parseOptions = options =>
|
|
189479
|
-
!options
|
|
189480
|
-
|
|
189481
|
-
|
|
189482
|
-
|
|
189483
|
-
|
|
189484
|
-
|
|
189654
|
+
// parse out just the options we care about
|
|
189655
|
+
const looseOption = Object.freeze({ loose: true })
|
|
189656
|
+
const emptyOpts = Object.freeze({ })
|
|
189657
|
+
const parseOptions = options => {
|
|
189658
|
+
if (!options) {
|
|
189659
|
+
return emptyOpts
|
|
189660
|
+
}
|
|
189661
|
+
|
|
189662
|
+
if (typeof options !== 'object') {
|
|
189663
|
+
return looseOption
|
|
189664
|
+
}
|
|
189665
|
+
|
|
189666
|
+
return options
|
|
189667
|
+
}
|
|
189485
189668
|
module.exports = parseOptions
|
|
189486
189669
|
|
|
189487
189670
|
|
|
@@ -189490,22 +189673,52 @@ module.exports = parseOptions
|
|
|
189490
189673
|
/***/ 92805:
|
|
189491
189674
|
/***/ ((module, exports, __webpack_require__) => {
|
|
189492
189675
|
|
|
189493
|
-
const {
|
|
189676
|
+
const {
|
|
189677
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
189678
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
189679
|
+
MAX_LENGTH,
|
|
189680
|
+
} = __webpack_require__(32094)
|
|
189494
189681
|
const debug = __webpack_require__(25078)
|
|
189495
189682
|
exports = module.exports = {}
|
|
189496
189683
|
|
|
189497
189684
|
// The actual regexps go on exports.re
|
|
189498
189685
|
const re = exports.re = []
|
|
189686
|
+
const safeRe = exports.safeRe = []
|
|
189499
189687
|
const src = exports.src = []
|
|
189500
189688
|
const t = exports.t = {}
|
|
189501
189689
|
let R = 0
|
|
189502
189690
|
|
|
189691
|
+
const LETTERDASHNUMBER = '[a-zA-Z0-9-]'
|
|
189692
|
+
|
|
189693
|
+
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
|
|
189694
|
+
// used internally via the safeRe object since all inputs in this library get
|
|
189695
|
+
// normalized first to trim and collapse all extra whitespace. The original
|
|
189696
|
+
// regexes are exported for userland consumption and lower level usage. A
|
|
189697
|
+
// future breaking change could export the safer regex only with a note that
|
|
189698
|
+
// all input should have extra whitespace removed.
|
|
189699
|
+
const safeRegexReplacements = [
|
|
189700
|
+
['\\s', 1],
|
|
189701
|
+
['\\d', MAX_LENGTH],
|
|
189702
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
|
|
189703
|
+
]
|
|
189704
|
+
|
|
189705
|
+
const makeSafeRegex = (value) => {
|
|
189706
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
189707
|
+
value = value
|
|
189708
|
+
.split(`${token}*`).join(`${token}{0,${max}}`)
|
|
189709
|
+
.split(`${token}+`).join(`${token}{1,${max}}`)
|
|
189710
|
+
}
|
|
189711
|
+
return value
|
|
189712
|
+
}
|
|
189713
|
+
|
|
189503
189714
|
const createToken = (name, value, isGlobal) => {
|
|
189715
|
+
const safe = makeSafeRegex(value)
|
|
189504
189716
|
const index = R++
|
|
189505
189717
|
debug(name, index, value)
|
|
189506
189718
|
t[name] = index
|
|
189507
189719
|
src[index] = value
|
|
189508
189720
|
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
|
|
189721
|
+
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
|
|
189509
189722
|
}
|
|
189510
189723
|
|
|
189511
189724
|
// The following Regular Expressions can be used for tokenizing,
|
|
@@ -189515,13 +189728,13 @@ const createToken = (name, value, isGlobal) => {
|
|
|
189515
189728
|
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
189516
189729
|
|
|
189517
189730
|
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*')
|
|
189518
|
-
createToken('NUMERICIDENTIFIERLOOSE', '
|
|
189731
|
+
createToken('NUMERICIDENTIFIERLOOSE', '\\d+')
|
|
189519
189732
|
|
|
189520
189733
|
// ## Non-numeric Identifier
|
|
189521
189734
|
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
189522
189735
|
// more letters, digits, or hyphens.
|
|
189523
189736
|
|
|
189524
|
-
createToken('NONNUMERICIDENTIFIER',
|
|
189737
|
+
createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`)
|
|
189525
189738
|
|
|
189526
189739
|
// ## Main Version
|
|
189527
189740
|
// Three dot-separated numeric identifiers.
|
|
@@ -189556,7 +189769,7 @@ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
|
|
189556
189769
|
// ## Build Metadata Identifier
|
|
189557
189770
|
// Any combination of digits, letters, or hyphens.
|
|
189558
189771
|
|
|
189559
|
-
createToken('BUILDIDENTIFIER',
|
|
189772
|
+
createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`)
|
|
189560
189773
|
|
|
189561
189774
|
// ## Build Metadata
|
|
189562
189775
|
// Plus sign, followed by one or more period-separated build metadata
|
|
@@ -189694,7 +189907,7 @@ const Range = __webpack_require__(4142)
|
|
|
189694
189907
|
const intersects = (r1, r2, options) => {
|
|
189695
189908
|
r1 = new Range(r1, options)
|
|
189696
189909
|
r2 = new Range(r2, options)
|
|
189697
|
-
return r1.intersects(r2)
|
|
189910
|
+
return r1.intersects(r2, options)
|
|
189698
189911
|
}
|
|
189699
189912
|
module.exports = intersects
|
|
189700
189913
|
|
|
@@ -190057,6 +190270,9 @@ const subset = (sub, dom, options = {}) => {
|
|
|
190057
190270
|
return true
|
|
190058
190271
|
}
|
|
190059
190272
|
|
|
190273
|
+
const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')]
|
|
190274
|
+
const minimumVersion = [new Comparator('>=0.0.0')]
|
|
190275
|
+
|
|
190060
190276
|
const simpleSubset = (sub, dom, options) => {
|
|
190061
190277
|
if (sub === dom) {
|
|
190062
190278
|
return true
|
|
@@ -190066,9 +190282,9 @@ const simpleSubset = (sub, dom, options) => {
|
|
|
190066
190282
|
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
190067
190283
|
return true
|
|
190068
190284
|
} else if (options.includePrerelease) {
|
|
190069
|
-
sub =
|
|
190285
|
+
sub = minimumVersionWithPreRelease
|
|
190070
190286
|
} else {
|
|
190071
|
-
sub =
|
|
190287
|
+
sub = minimumVersion
|
|
190072
190288
|
}
|
|
190073
190289
|
}
|
|
190074
190290
|
|
|
@@ -190076,7 +190292,7 @@ const simpleSubset = (sub, dom, options) => {
|
|
|
190076
190292
|
if (options.includePrerelease) {
|
|
190077
190293
|
return true
|
|
190078
190294
|
} else {
|
|
190079
|
-
dom =
|
|
190295
|
+
dom = minimumVersion
|
|
190080
190296
|
}
|
|
190081
190297
|
}
|
|
190082
190298
|
|
|
@@ -191053,6 +191269,138 @@ module.exports.tmpNameSync = tmpNameSync;
|
|
|
191053
191269
|
module.exports.setGracefulCleanup = setGracefulCleanup;
|
|
191054
191270
|
|
|
191055
191271
|
|
|
191272
|
+
/***/ }),
|
|
191273
|
+
|
|
191274
|
+
/***/ 81918:
|
|
191275
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
191276
|
+
|
|
191277
|
+
const isWindows = process.platform === 'win32' ||
|
|
191278
|
+
process.env.OSTYPE === 'cygwin' ||
|
|
191279
|
+
process.env.OSTYPE === 'msys'
|
|
191280
|
+
|
|
191281
|
+
const path = __webpack_require__(71017)
|
|
191282
|
+
const COLON = isWindows ? ';' : ':'
|
|
191283
|
+
const isexe = __webpack_require__(31959)
|
|
191284
|
+
|
|
191285
|
+
const getNotFoundError = (cmd) =>
|
|
191286
|
+
Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
|
|
191287
|
+
|
|
191288
|
+
const getPathInfo = (cmd, opt) => {
|
|
191289
|
+
const colon = opt.colon || COLON
|
|
191290
|
+
|
|
191291
|
+
// If it has a slash, then we don't bother searching the pathenv.
|
|
191292
|
+
// just check the file itself, and that's it.
|
|
191293
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
|
|
191294
|
+
: (
|
|
191295
|
+
[
|
|
191296
|
+
// windows always checks the cwd first
|
|
191297
|
+
...(isWindows ? [process.cwd()] : []),
|
|
191298
|
+
...(opt.path || process.env.PATH ||
|
|
191299
|
+
/* istanbul ignore next: very unusual */ '').split(colon),
|
|
191300
|
+
]
|
|
191301
|
+
)
|
|
191302
|
+
const pathExtExe = isWindows
|
|
191303
|
+
? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
|
|
191304
|
+
: ''
|
|
191305
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : ['']
|
|
191306
|
+
|
|
191307
|
+
if (isWindows) {
|
|
191308
|
+
if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
|
|
191309
|
+
pathExt.unshift('')
|
|
191310
|
+
}
|
|
191311
|
+
|
|
191312
|
+
return {
|
|
191313
|
+
pathEnv,
|
|
191314
|
+
pathExt,
|
|
191315
|
+
pathExtExe,
|
|
191316
|
+
}
|
|
191317
|
+
}
|
|
191318
|
+
|
|
191319
|
+
const which = (cmd, opt, cb) => {
|
|
191320
|
+
if (typeof opt === 'function') {
|
|
191321
|
+
cb = opt
|
|
191322
|
+
opt = {}
|
|
191323
|
+
}
|
|
191324
|
+
if (!opt)
|
|
191325
|
+
opt = {}
|
|
191326
|
+
|
|
191327
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
|
|
191328
|
+
const found = []
|
|
191329
|
+
|
|
191330
|
+
const step = i => new Promise((resolve, reject) => {
|
|
191331
|
+
if (i === pathEnv.length)
|
|
191332
|
+
return opt.all && found.length ? resolve(found)
|
|
191333
|
+
: reject(getNotFoundError(cmd))
|
|
191334
|
+
|
|
191335
|
+
const ppRaw = pathEnv[i]
|
|
191336
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
|
|
191337
|
+
|
|
191338
|
+
const pCmd = path.join(pathPart, cmd)
|
|
191339
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|
191340
|
+
: pCmd
|
|
191341
|
+
|
|
191342
|
+
resolve(subStep(p, i, 0))
|
|
191343
|
+
})
|
|
191344
|
+
|
|
191345
|
+
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
191346
|
+
if (ii === pathExt.length)
|
|
191347
|
+
return resolve(step(i + 1))
|
|
191348
|
+
const ext = pathExt[ii]
|
|
191349
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
191350
|
+
if (!er && is) {
|
|
191351
|
+
if (opt.all)
|
|
191352
|
+
found.push(p + ext)
|
|
191353
|
+
else
|
|
191354
|
+
return resolve(p + ext)
|
|
191355
|
+
}
|
|
191356
|
+
return resolve(subStep(p, i, ii + 1))
|
|
191357
|
+
})
|
|
191358
|
+
})
|
|
191359
|
+
|
|
191360
|
+
return cb ? step(0).then(res => cb(null, res), cb) : step(0)
|
|
191361
|
+
}
|
|
191362
|
+
|
|
191363
|
+
const whichSync = (cmd, opt) => {
|
|
191364
|
+
opt = opt || {}
|
|
191365
|
+
|
|
191366
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
|
|
191367
|
+
const found = []
|
|
191368
|
+
|
|
191369
|
+
for (let i = 0; i < pathEnv.length; i ++) {
|
|
191370
|
+
const ppRaw = pathEnv[i]
|
|
191371
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
|
|
191372
|
+
|
|
191373
|
+
const pCmd = path.join(pathPart, cmd)
|
|
191374
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|
191375
|
+
: pCmd
|
|
191376
|
+
|
|
191377
|
+
for (let j = 0; j < pathExt.length; j ++) {
|
|
191378
|
+
const cur = p + pathExt[j]
|
|
191379
|
+
try {
|
|
191380
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe })
|
|
191381
|
+
if (is) {
|
|
191382
|
+
if (opt.all)
|
|
191383
|
+
found.push(cur)
|
|
191384
|
+
else
|
|
191385
|
+
return cur
|
|
191386
|
+
}
|
|
191387
|
+
} catch (ex) {}
|
|
191388
|
+
}
|
|
191389
|
+
}
|
|
191390
|
+
|
|
191391
|
+
if (opt.all && found.length)
|
|
191392
|
+
return found
|
|
191393
|
+
|
|
191394
|
+
if (opt.nothrow)
|
|
191395
|
+
return null
|
|
191396
|
+
|
|
191397
|
+
throw getNotFoundError(cmd)
|
|
191398
|
+
}
|
|
191399
|
+
|
|
191400
|
+
module.exports = which
|
|
191401
|
+
which.sync = whichSync
|
|
191402
|
+
|
|
191403
|
+
|
|
191056
191404
|
/***/ }),
|
|
191057
191405
|
|
|
191058
191406
|
/***/ 26520:
|
|
@@ -263964,6 +264312,7 @@ class Client extends EventEmitter {
|
|
|
263964
264312
|
const DEBUG_HANDLER = (!debug ? undefined : (p, display, msg) => {
|
|
263965
264313
|
debug(`Debug output from server: ${JSON.stringify(msg)}`);
|
|
263966
264314
|
});
|
|
264315
|
+
let serverSigAlgs;
|
|
263967
264316
|
const proto = this._protocol = new Protocol({
|
|
263968
264317
|
ident: this.config.ident,
|
|
263969
264318
|
offer: (allOfferDefaults ? undefined : algorithms),
|
|
@@ -264015,6 +264364,17 @@ class Client extends EventEmitter {
|
|
|
264015
264364
|
if (name === 'ssh-userauth')
|
|
264016
264365
|
tryNextAuth();
|
|
264017
264366
|
},
|
|
264367
|
+
EXT_INFO: (p, exts) => {
|
|
264368
|
+
if (serverSigAlgs === undefined) {
|
|
264369
|
+
for (const ext of exts) {
|
|
264370
|
+
if (ext.name === 'server-sig-algs') {
|
|
264371
|
+
serverSigAlgs = ext.algs;
|
|
264372
|
+
return;
|
|
264373
|
+
}
|
|
264374
|
+
}
|
|
264375
|
+
serverSigAlgs = null;
|
|
264376
|
+
}
|
|
264377
|
+
},
|
|
264018
264378
|
USERAUTH_BANNER: (p, msg) => {
|
|
264019
264379
|
this.emit('banner', msg);
|
|
264020
264380
|
},
|
|
@@ -264027,6 +264387,51 @@ class Client extends EventEmitter {
|
|
|
264027
264387
|
this.emit('ready');
|
|
264028
264388
|
},
|
|
264029
264389
|
USERAUTH_FAILURE: (p, authMethods, partialSuccess) => {
|
|
264390
|
+
// For key-based authentication, check if we should retry the current
|
|
264391
|
+
// key with a different algorithm first
|
|
264392
|
+
if (curAuth.keyAlgos) {
|
|
264393
|
+
const oldKeyAlgo = curAuth.keyAlgos[0][0];
|
|
264394
|
+
if (debug)
|
|
264395
|
+
debug(`Client: ${curAuth.type} (${oldKeyAlgo}) auth failed`);
|
|
264396
|
+
curAuth.keyAlgos.shift();
|
|
264397
|
+
if (curAuth.keyAlgos.length) {
|
|
264398
|
+
const [keyAlgo, hashAlgo] = curAuth.keyAlgos[0];
|
|
264399
|
+
switch (curAuth.type) {
|
|
264400
|
+
case 'agent':
|
|
264401
|
+
proto.authPK(
|
|
264402
|
+
curAuth.username,
|
|
264403
|
+
curAuth.agentCtx.currentKey(),
|
|
264404
|
+
keyAlgo
|
|
264405
|
+
);
|
|
264406
|
+
return;
|
|
264407
|
+
case 'publickey':
|
|
264408
|
+
proto.authPK(curAuth.username, curAuth.key, keyAlgo);
|
|
264409
|
+
return;
|
|
264410
|
+
case 'hostbased':
|
|
264411
|
+
proto.authHostbased(curAuth.username,
|
|
264412
|
+
curAuth.key,
|
|
264413
|
+
curAuth.localHostname,
|
|
264414
|
+
curAuth.localUsername,
|
|
264415
|
+
keyAlgo,
|
|
264416
|
+
(buf, cb) => {
|
|
264417
|
+
const signature = curAuth.key.sign(buf, hashAlgo);
|
|
264418
|
+
if (signature instanceof Error) {
|
|
264419
|
+
signature.message =
|
|
264420
|
+
`Error while signing with key: ${signature.message}`;
|
|
264421
|
+
signature.level = 'client-authentication';
|
|
264422
|
+
this.emit('error', signature);
|
|
264423
|
+
return tryNextAuth();
|
|
264424
|
+
}
|
|
264425
|
+
|
|
264426
|
+
cb(signature);
|
|
264427
|
+
});
|
|
264428
|
+
return;
|
|
264429
|
+
}
|
|
264430
|
+
} else {
|
|
264431
|
+
curAuth.keyAlgos = undefined;
|
|
264432
|
+
}
|
|
264433
|
+
}
|
|
264434
|
+
|
|
264030
264435
|
if (curAuth.type === 'agent') {
|
|
264031
264436
|
const pos = curAuth.agentCtx.pos();
|
|
264032
264437
|
debug && debug(`Client: Agent key #${pos + 1} failed`);
|
|
@@ -264053,10 +264458,15 @@ class Client extends EventEmitter {
|
|
|
264053
264458
|
}
|
|
264054
264459
|
},
|
|
264055
264460
|
USERAUTH_PK_OK: (p) => {
|
|
264461
|
+
let keyAlgo;
|
|
264462
|
+
let hashAlgo;
|
|
264463
|
+
if (curAuth.keyAlgos)
|
|
264464
|
+
[keyAlgo, hashAlgo] = curAuth.keyAlgos[0];
|
|
264056
264465
|
if (curAuth.type === 'agent') {
|
|
264057
264466
|
const key = curAuth.agentCtx.currentKey();
|
|
264058
|
-
proto.authPK(curAuth.username, key, (buf, cb) => {
|
|
264059
|
-
|
|
264467
|
+
proto.authPK(curAuth.username, key, keyAlgo, (buf, cb) => {
|
|
264468
|
+
const opts = { hash: hashAlgo };
|
|
264469
|
+
curAuth.agentCtx.sign(key, buf, opts, (err, signed) => {
|
|
264060
264470
|
if (err) {
|
|
264061
264471
|
err.level = 'agent';
|
|
264062
264472
|
this.emit('error', err);
|
|
@@ -264068,8 +264478,8 @@ class Client extends EventEmitter {
|
|
|
264068
264478
|
});
|
|
264069
264479
|
});
|
|
264070
264480
|
} else if (curAuth.type === 'publickey') {
|
|
264071
|
-
proto.authPK(curAuth.username, curAuth.key, (buf, cb) => {
|
|
264072
|
-
const signature = curAuth.key.sign(buf);
|
|
264481
|
+
proto.authPK(curAuth.username, curAuth.key, keyAlgo, (buf, cb) => {
|
|
264482
|
+
const signature = curAuth.key.sign(buf, hashAlgo);
|
|
264073
264483
|
if (signature instanceof Error) {
|
|
264074
264484
|
signature.message =
|
|
264075
264485
|
`Error signing data with key: ${signature.message}`;
|
|
@@ -264604,16 +265014,42 @@ class Client extends EventEmitter {
|
|
|
264604
265014
|
case 'password':
|
|
264605
265015
|
proto.authPassword(username, curAuth.password);
|
|
264606
265016
|
break;
|
|
264607
|
-
case 'publickey':
|
|
264608
|
-
|
|
265017
|
+
case 'publickey': {
|
|
265018
|
+
let keyAlgo;
|
|
265019
|
+
curAuth.keyAlgos = getKeyAlgos(this, curAuth.key, serverSigAlgs);
|
|
265020
|
+
if (curAuth.keyAlgos) {
|
|
265021
|
+
if (curAuth.keyAlgos.length) {
|
|
265022
|
+
keyAlgo = curAuth.keyAlgos[0][0];
|
|
265023
|
+
} else {
|
|
265024
|
+
return skipAuth(
|
|
265025
|
+
'Skipping key authentication (no mutual hash algorithm)'
|
|
265026
|
+
);
|
|
265027
|
+
}
|
|
265028
|
+
}
|
|
265029
|
+
proto.authPK(username, curAuth.key, keyAlgo);
|
|
264609
265030
|
break;
|
|
264610
|
-
|
|
265031
|
+
}
|
|
265032
|
+
case 'hostbased': {
|
|
265033
|
+
let keyAlgo;
|
|
265034
|
+
let hashAlgo;
|
|
265035
|
+
curAuth.keyAlgos = getKeyAlgos(this, curAuth.key, serverSigAlgs);
|
|
265036
|
+
if (curAuth.keyAlgos) {
|
|
265037
|
+
if (curAuth.keyAlgos.length) {
|
|
265038
|
+
[keyAlgo, hashAlgo] = curAuth.keyAlgos[0];
|
|
265039
|
+
} else {
|
|
265040
|
+
return skipAuth(
|
|
265041
|
+
'Skipping hostbased authentication (no mutual hash algorithm)'
|
|
265042
|
+
);
|
|
265043
|
+
}
|
|
265044
|
+
}
|
|
265045
|
+
|
|
264611
265046
|
proto.authHostbased(username,
|
|
264612
265047
|
curAuth.key,
|
|
264613
265048
|
curAuth.localHostname,
|
|
264614
265049
|
curAuth.localUsername,
|
|
265050
|
+
keyAlgo,
|
|
264615
265051
|
(buf, cb) => {
|
|
264616
|
-
const signature = curAuth.key.sign(buf);
|
|
265052
|
+
const signature = curAuth.key.sign(buf, hashAlgo);
|
|
264617
265053
|
if (signature instanceof Error) {
|
|
264618
265054
|
signature.message =
|
|
264619
265055
|
`Error while signing with key: ${signature.message}`;
|
|
@@ -264625,6 +265061,7 @@ class Client extends EventEmitter {
|
|
|
264625
265061
|
cb(signature);
|
|
264626
265062
|
});
|
|
264627
265063
|
break;
|
|
265064
|
+
}
|
|
264628
265065
|
case 'agent':
|
|
264629
265066
|
curAuth.agentCtx.init((err) => {
|
|
264630
265067
|
if (err) {
|
|
@@ -264669,8 +265106,21 @@ class Client extends EventEmitter {
|
|
|
264669
265106
|
tryNextAuth();
|
|
264670
265107
|
} else {
|
|
264671
265108
|
const pos = curAuth.agentCtx.pos();
|
|
265109
|
+
let keyAlgo;
|
|
265110
|
+
curAuth.keyAlgos = getKeyAlgos(this, key, serverSigAlgs);
|
|
265111
|
+
if (curAuth.keyAlgos) {
|
|
265112
|
+
if (curAuth.keyAlgos.length) {
|
|
265113
|
+
keyAlgo = curAuth.keyAlgos[0][0];
|
|
265114
|
+
} else {
|
|
265115
|
+
debug && debug(
|
|
265116
|
+
`Agent: Skipping key #${pos + 1} (no mutual hash algorithm)`
|
|
265117
|
+
);
|
|
265118
|
+
tryNextAgentKey();
|
|
265119
|
+
return;
|
|
265120
|
+
}
|
|
265121
|
+
}
|
|
264672
265122
|
debug && debug(`Agent: Trying key #${pos + 1}`);
|
|
264673
|
-
proto.authPK(curAuth.username, key);
|
|
265123
|
+
proto.authPK(curAuth.username, key, keyAlgo);
|
|
264674
265124
|
}
|
|
264675
265125
|
}
|
|
264676
265126
|
};
|
|
@@ -264701,7 +265151,6 @@ class Client extends EventEmitter {
|
|
|
264701
265151
|
localAddress: this.config.localAddress,
|
|
264702
265152
|
localPort: this.config.localPort
|
|
264703
265153
|
});
|
|
264704
|
-
sock.setNoDelay(true);
|
|
264705
265154
|
sock.setMaxListeners(0);
|
|
264706
265155
|
sock.setTimeout(typeof cfg.timeout === 'number' ? cfg.timeout : 0);
|
|
264707
265156
|
};
|
|
@@ -265181,6 +265630,13 @@ class Client extends EventEmitter {
|
|
|
265181
265630
|
|
|
265182
265631
|
return this;
|
|
265183
265632
|
}
|
|
265633
|
+
|
|
265634
|
+
setNoDelay(noDelay) {
|
|
265635
|
+
if (this._sock && typeof this._sock.setNoDelay === 'function')
|
|
265636
|
+
this._sock.setNoDelay(noDelay);
|
|
265637
|
+
|
|
265638
|
+
return this;
|
|
265639
|
+
}
|
|
265184
265640
|
}
|
|
265185
265641
|
|
|
265186
265642
|
function openChannel(self, type, opts, cb) {
|
|
@@ -265678,6 +266134,27 @@ function hostKeysProve(client, keys_, cb) {
|
|
|
265678
266134
|
);
|
|
265679
266135
|
}
|
|
265680
266136
|
|
|
266137
|
+
function getKeyAlgos(client, key, serverSigAlgs) {
|
|
266138
|
+
switch (key.type) {
|
|
266139
|
+
case 'ssh-rsa':
|
|
266140
|
+
if (client._protocol._compatFlags & COMPAT.IMPLY_RSA_SHA2_SIGALGS) {
|
|
266141
|
+
if (!Array.isArray(serverSigAlgs))
|
|
266142
|
+
serverSigAlgs = ['rsa-sha2-256', 'rsa-sha2-512'];
|
|
266143
|
+
else
|
|
266144
|
+
serverSigAlgs = ['rsa-sha2-256', 'rsa-sha2-512', ...serverSigAlgs];
|
|
266145
|
+
}
|
|
266146
|
+
if (Array.isArray(serverSigAlgs)) {
|
|
266147
|
+
if (serverSigAlgs.indexOf('rsa-sha2-256') !== -1)
|
|
266148
|
+
return [['rsa-sha2-256', 'sha256']];
|
|
266149
|
+
if (serverSigAlgs.indexOf('rsa-sha2-512') !== -1)
|
|
266150
|
+
return [['rsa-sha2-512', 'sha512']];
|
|
266151
|
+
if (serverSigAlgs.indexOf('ssh-rsa') === -1)
|
|
266152
|
+
return [];
|
|
266153
|
+
}
|
|
266154
|
+
return [['ssh-rsa', 'sha1']];
|
|
266155
|
+
}
|
|
266156
|
+
}
|
|
266157
|
+
|
|
265681
266158
|
module.exports = Client;
|
|
265682
266159
|
|
|
265683
266160
|
|
|
@@ -265814,6 +266291,7 @@ module.exports = {
|
|
|
265814
266291
|
Server: __webpack_require__(37465),
|
|
265815
266292
|
utils: {
|
|
265816
266293
|
parseKey,
|
|
266294
|
+
...__webpack_require__(88970),
|
|
265817
266295
|
sftp: {
|
|
265818
266296
|
flagsToString,
|
|
265819
266297
|
OPEN_MODE,
|
|
@@ -265824,6 +266302,596 @@ module.exports = {
|
|
|
265824
266302
|
};
|
|
265825
266303
|
|
|
265826
266304
|
|
|
266305
|
+
/***/ }),
|
|
266306
|
+
|
|
266307
|
+
/***/ 88970:
|
|
266308
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
266309
|
+
|
|
266310
|
+
"use strict";
|
|
266311
|
+
|
|
266312
|
+
|
|
266313
|
+
const {
|
|
266314
|
+
createCipheriv,
|
|
266315
|
+
generateKeyPair: generateKeyPair_,
|
|
266316
|
+
generateKeyPairSync: generateKeyPairSync_,
|
|
266317
|
+
getCurves,
|
|
266318
|
+
randomBytes,
|
|
266319
|
+
} = __webpack_require__(6113);
|
|
266320
|
+
|
|
266321
|
+
const { Ber } = __webpack_require__(90476);
|
|
266322
|
+
const bcrypt_pbkdf = __webpack_require__(62703).pbkdf;
|
|
266323
|
+
|
|
266324
|
+
const { CIPHER_INFO } = __webpack_require__(83877);
|
|
266325
|
+
|
|
266326
|
+
const SALT_LEN = 16;
|
|
266327
|
+
const DEFAULT_ROUNDS = 16;
|
|
266328
|
+
|
|
266329
|
+
const curves = getCurves();
|
|
266330
|
+
const ciphers = new Map(Object.entries(CIPHER_INFO));
|
|
266331
|
+
|
|
266332
|
+
function makeArgs(type, opts) {
|
|
266333
|
+
if (typeof type !== 'string')
|
|
266334
|
+
throw new TypeError('Key type must be a string');
|
|
266335
|
+
|
|
266336
|
+
const publicKeyEncoding = { type: 'spki', format: 'der' };
|
|
266337
|
+
const privateKeyEncoding = { type: 'pkcs8', format: 'der' };
|
|
266338
|
+
|
|
266339
|
+
switch (type.toLowerCase()) {
|
|
266340
|
+
case 'rsa': {
|
|
266341
|
+
if (typeof opts !== 'object' || opts === null)
|
|
266342
|
+
throw new TypeError('Missing options object for RSA key');
|
|
266343
|
+
const modulusLength = opts.bits;
|
|
266344
|
+
if (!Number.isInteger(modulusLength))
|
|
266345
|
+
throw new TypeError('RSA bits must be an integer');
|
|
266346
|
+
if (modulusLength <= 0 || modulusLength > 16384)
|
|
266347
|
+
throw new RangeError('RSA bits must be non-zero and <= 16384');
|
|
266348
|
+
return ['rsa', { modulusLength, publicKeyEncoding, privateKeyEncoding }];
|
|
266349
|
+
}
|
|
266350
|
+
case 'ecdsa': {
|
|
266351
|
+
if (typeof opts !== 'object' || opts === null)
|
|
266352
|
+
throw new TypeError('Missing options object for ECDSA key');
|
|
266353
|
+
if (!Number.isInteger(opts.bits))
|
|
266354
|
+
throw new TypeError('ECDSA bits must be an integer');
|
|
266355
|
+
let namedCurve;
|
|
266356
|
+
switch (opts.bits) {
|
|
266357
|
+
case 256:
|
|
266358
|
+
namedCurve = 'prime256v1';
|
|
266359
|
+
break;
|
|
266360
|
+
case 384:
|
|
266361
|
+
namedCurve = 'secp384r1';
|
|
266362
|
+
break;
|
|
266363
|
+
case 521:
|
|
266364
|
+
namedCurve = 'secp521r1';
|
|
266365
|
+
break;
|
|
266366
|
+
default:
|
|
266367
|
+
throw new Error('ECDSA bits must be 256, 384, or 521');
|
|
266368
|
+
}
|
|
266369
|
+
if (!curves.includes(namedCurve))
|
|
266370
|
+
throw new Error('Unsupported ECDSA bits value');
|
|
266371
|
+
return ['ec', { namedCurve, publicKeyEncoding, privateKeyEncoding }];
|
|
266372
|
+
}
|
|
266373
|
+
case 'ed25519':
|
|
266374
|
+
return ['ed25519', { publicKeyEncoding, privateKeyEncoding }];
|
|
266375
|
+
default:
|
|
266376
|
+
throw new Error(`Unsupported key type: ${type}`);
|
|
266377
|
+
}
|
|
266378
|
+
}
|
|
266379
|
+
|
|
266380
|
+
function parseDERs(keyType, pub, priv) {
|
|
266381
|
+
switch (keyType) {
|
|
266382
|
+
case 'rsa': {
|
|
266383
|
+
// Note: we don't need to parse the public key since the PKCS8 private key
|
|
266384
|
+
// already includes the public key parameters
|
|
266385
|
+
|
|
266386
|
+
// Parse private key
|
|
266387
|
+
let reader = new Ber.Reader(priv);
|
|
266388
|
+
reader.readSequence();
|
|
266389
|
+
|
|
266390
|
+
// - Version
|
|
266391
|
+
if (reader.readInt() !== 0)
|
|
266392
|
+
throw new Error('Unsupported version in RSA private key');
|
|
266393
|
+
|
|
266394
|
+
// - Algorithm
|
|
266395
|
+
reader.readSequence();
|
|
266396
|
+
if (reader.readOID() !== '1.2.840.113549.1.1.1')
|
|
266397
|
+
throw new Error('Bad RSA private OID');
|
|
266398
|
+
// - Algorithm parameters (RSA has none)
|
|
266399
|
+
if (reader.readByte() !== Ber.Null)
|
|
266400
|
+
throw new Error('Malformed RSA private key (expected null)');
|
|
266401
|
+
if (reader.readByte() !== 0x00) {
|
|
266402
|
+
throw new Error(
|
|
266403
|
+
'Malformed RSA private key (expected zero-length null)'
|
|
266404
|
+
);
|
|
266405
|
+
}
|
|
266406
|
+
|
|
266407
|
+
reader = new Ber.Reader(reader.readString(Ber.OctetString, true));
|
|
266408
|
+
reader.readSequence();
|
|
266409
|
+
if (reader.readInt() !== 0)
|
|
266410
|
+
throw new Error('Unsupported version in RSA private key');
|
|
266411
|
+
const n = reader.readString(Ber.Integer, true);
|
|
266412
|
+
const e = reader.readString(Ber.Integer, true);
|
|
266413
|
+
const d = reader.readString(Ber.Integer, true);
|
|
266414
|
+
const p = reader.readString(Ber.Integer, true);
|
|
266415
|
+
const q = reader.readString(Ber.Integer, true);
|
|
266416
|
+
reader.readString(Ber.Integer, true); // dmp1
|
|
266417
|
+
reader.readString(Ber.Integer, true); // dmq1
|
|
266418
|
+
const iqmp = reader.readString(Ber.Integer, true);
|
|
266419
|
+
|
|
266420
|
+
/*
|
|
266421
|
+
OpenSSH RSA private key:
|
|
266422
|
+
string "ssh-rsa"
|
|
266423
|
+
string n -- public
|
|
266424
|
+
string e -- public
|
|
266425
|
+
string d -- private
|
|
266426
|
+
string iqmp -- private
|
|
266427
|
+
string p -- private
|
|
266428
|
+
string q -- private
|
|
266429
|
+
*/
|
|
266430
|
+
const keyName = Buffer.from('ssh-rsa');
|
|
266431
|
+
const privBuf = Buffer.allocUnsafe(
|
|
266432
|
+
4 + keyName.length
|
|
266433
|
+
+ 4 + n.length
|
|
266434
|
+
+ 4 + e.length
|
|
266435
|
+
+ 4 + d.length
|
|
266436
|
+
+ 4 + iqmp.length
|
|
266437
|
+
+ 4 + p.length
|
|
266438
|
+
+ 4 + q.length
|
|
266439
|
+
);
|
|
266440
|
+
let pos = 0;
|
|
266441
|
+
|
|
266442
|
+
privBuf.writeUInt32BE(keyName.length, pos += 0);
|
|
266443
|
+
privBuf.set(keyName, pos += 4);
|
|
266444
|
+
privBuf.writeUInt32BE(n.length, pos += keyName.length);
|
|
266445
|
+
privBuf.set(n, pos += 4);
|
|
266446
|
+
privBuf.writeUInt32BE(e.length, pos += n.length);
|
|
266447
|
+
privBuf.set(e, pos += 4);
|
|
266448
|
+
privBuf.writeUInt32BE(d.length, pos += e.length);
|
|
266449
|
+
privBuf.set(d, pos += 4);
|
|
266450
|
+
privBuf.writeUInt32BE(iqmp.length, pos += d.length);
|
|
266451
|
+
privBuf.set(iqmp, pos += 4);
|
|
266452
|
+
privBuf.writeUInt32BE(p.length, pos += iqmp.length);
|
|
266453
|
+
privBuf.set(p, pos += 4);
|
|
266454
|
+
privBuf.writeUInt32BE(q.length, pos += p.length);
|
|
266455
|
+
privBuf.set(q, pos += 4);
|
|
266456
|
+
|
|
266457
|
+
/*
|
|
266458
|
+
OpenSSH RSA public key:
|
|
266459
|
+
string "ssh-rsa"
|
|
266460
|
+
string e -- public
|
|
266461
|
+
string n -- public
|
|
266462
|
+
*/
|
|
266463
|
+
const pubBuf = Buffer.allocUnsafe(
|
|
266464
|
+
4 + keyName.length
|
|
266465
|
+
+ 4 + e.length
|
|
266466
|
+
+ 4 + n.length
|
|
266467
|
+
);
|
|
266468
|
+
pos = 0;
|
|
266469
|
+
|
|
266470
|
+
pubBuf.writeUInt32BE(keyName.length, pos += 0);
|
|
266471
|
+
pubBuf.set(keyName, pos += 4);
|
|
266472
|
+
pubBuf.writeUInt32BE(e.length, pos += keyName.length);
|
|
266473
|
+
pubBuf.set(e, pos += 4);
|
|
266474
|
+
pubBuf.writeUInt32BE(n.length, pos += e.length);
|
|
266475
|
+
pubBuf.set(n, pos += 4);
|
|
266476
|
+
|
|
266477
|
+
return { sshName: keyName.toString(), priv: privBuf, pub: pubBuf };
|
|
266478
|
+
}
|
|
266479
|
+
case 'ec': {
|
|
266480
|
+
// Parse public key
|
|
266481
|
+
let reader = new Ber.Reader(pub);
|
|
266482
|
+
reader.readSequence();
|
|
266483
|
+
|
|
266484
|
+
reader.readSequence();
|
|
266485
|
+
if (reader.readOID() !== '1.2.840.10045.2.1')
|
|
266486
|
+
throw new Error('Bad ECDSA public OID');
|
|
266487
|
+
// Skip curve OID, we'll get it from the private key
|
|
266488
|
+
reader.readOID();
|
|
266489
|
+
let pubBin = reader.readString(Ber.BitString, true);
|
|
266490
|
+
{
|
|
266491
|
+
// Remove leading zero bytes
|
|
266492
|
+
let i = 0;
|
|
266493
|
+
for (; i < pubBin.length && pubBin[i] === 0x00; ++i);
|
|
266494
|
+
if (i > 0)
|
|
266495
|
+
pubBin = pubBin.slice(i);
|
|
266496
|
+
}
|
|
266497
|
+
|
|
266498
|
+
// Parse private key
|
|
266499
|
+
reader = new Ber.Reader(priv);
|
|
266500
|
+
reader.readSequence();
|
|
266501
|
+
|
|
266502
|
+
// - Version
|
|
266503
|
+
if (reader.readInt() !== 0)
|
|
266504
|
+
throw new Error('Unsupported version in ECDSA private key');
|
|
266505
|
+
|
|
266506
|
+
reader.readSequence();
|
|
266507
|
+
if (reader.readOID() !== '1.2.840.10045.2.1')
|
|
266508
|
+
throw new Error('Bad ECDSA private OID');
|
|
266509
|
+
const curveOID = reader.readOID();
|
|
266510
|
+
let sshCurveName;
|
|
266511
|
+
switch (curveOID) {
|
|
266512
|
+
case '1.2.840.10045.3.1.7':
|
|
266513
|
+
// prime256v1/secp256r1
|
|
266514
|
+
sshCurveName = 'nistp256';
|
|
266515
|
+
break;
|
|
266516
|
+
case '1.3.132.0.34':
|
|
266517
|
+
// secp384r1
|
|
266518
|
+
sshCurveName = 'nistp384';
|
|
266519
|
+
break;
|
|
266520
|
+
case '1.3.132.0.35':
|
|
266521
|
+
// secp521r1
|
|
266522
|
+
sshCurveName = 'nistp521';
|
|
266523
|
+
break;
|
|
266524
|
+
default:
|
|
266525
|
+
throw new Error('Unsupported curve in ECDSA private key');
|
|
266526
|
+
}
|
|
266527
|
+
|
|
266528
|
+
reader = new Ber.Reader(reader.readString(Ber.OctetString, true));
|
|
266529
|
+
reader.readSequence();
|
|
266530
|
+
|
|
266531
|
+
// - Version
|
|
266532
|
+
if (reader.readInt() !== 1)
|
|
266533
|
+
throw new Error('Unsupported version in ECDSA private key');
|
|
266534
|
+
|
|
266535
|
+
// Add leading zero byte to prevent negative bignum in private key
|
|
266536
|
+
const privBin = Buffer.concat([
|
|
266537
|
+
Buffer.from([0x00]),
|
|
266538
|
+
reader.readString(Ber.OctetString, true)
|
|
266539
|
+
]);
|
|
266540
|
+
|
|
266541
|
+
/*
|
|
266542
|
+
OpenSSH ECDSA private key:
|
|
266543
|
+
string "ecdsa-sha2-<sshCurveName>"
|
|
266544
|
+
string curve name
|
|
266545
|
+
string Q -- public
|
|
266546
|
+
string d -- private
|
|
266547
|
+
*/
|
|
266548
|
+
const keyName = Buffer.from(`ecdsa-sha2-${sshCurveName}`);
|
|
266549
|
+
sshCurveName = Buffer.from(sshCurveName);
|
|
266550
|
+
const privBuf = Buffer.allocUnsafe(
|
|
266551
|
+
4 + keyName.length
|
|
266552
|
+
+ 4 + sshCurveName.length
|
|
266553
|
+
+ 4 + pubBin.length
|
|
266554
|
+
+ 4 + privBin.length
|
|
266555
|
+
);
|
|
266556
|
+
let pos = 0;
|
|
266557
|
+
|
|
266558
|
+
privBuf.writeUInt32BE(keyName.length, pos += 0);
|
|
266559
|
+
privBuf.set(keyName, pos += 4);
|
|
266560
|
+
privBuf.writeUInt32BE(sshCurveName.length, pos += keyName.length);
|
|
266561
|
+
privBuf.set(sshCurveName, pos += 4);
|
|
266562
|
+
privBuf.writeUInt32BE(pubBin.length, pos += sshCurveName.length);
|
|
266563
|
+
privBuf.set(pubBin, pos += 4);
|
|
266564
|
+
privBuf.writeUInt32BE(privBin.length, pos += pubBin.length);
|
|
266565
|
+
privBuf.set(privBin, pos += 4);
|
|
266566
|
+
|
|
266567
|
+
/*
|
|
266568
|
+
OpenSSH ECDSA public key:
|
|
266569
|
+
string "ecdsa-sha2-<sshCurveName>"
|
|
266570
|
+
string curve name
|
|
266571
|
+
string Q -- public
|
|
266572
|
+
*/
|
|
266573
|
+
const pubBuf = Buffer.allocUnsafe(
|
|
266574
|
+
4 + keyName.length
|
|
266575
|
+
+ 4 + sshCurveName.length
|
|
266576
|
+
+ 4 + pubBin.length
|
|
266577
|
+
);
|
|
266578
|
+
pos = 0;
|
|
266579
|
+
|
|
266580
|
+
pubBuf.writeUInt32BE(keyName.length, pos += 0);
|
|
266581
|
+
pubBuf.set(keyName, pos += 4);
|
|
266582
|
+
pubBuf.writeUInt32BE(sshCurveName.length, pos += keyName.length);
|
|
266583
|
+
pubBuf.set(sshCurveName, pos += 4);
|
|
266584
|
+
pubBuf.writeUInt32BE(pubBin.length, pos += sshCurveName.length);
|
|
266585
|
+
pubBuf.set(pubBin, pos += 4);
|
|
266586
|
+
|
|
266587
|
+
return { sshName: keyName.toString(), priv: privBuf, pub: pubBuf };
|
|
266588
|
+
}
|
|
266589
|
+
case 'ed25519': {
|
|
266590
|
+
// Parse public key
|
|
266591
|
+
let reader = new Ber.Reader(pub);
|
|
266592
|
+
reader.readSequence();
|
|
266593
|
+
|
|
266594
|
+
// - Algorithm
|
|
266595
|
+
reader.readSequence();
|
|
266596
|
+
if (reader.readOID() !== '1.3.101.112')
|
|
266597
|
+
throw new Error('Bad ED25519 public OID');
|
|
266598
|
+
// - Attributes (absent for ED25519)
|
|
266599
|
+
|
|
266600
|
+
let pubBin = reader.readString(Ber.BitString, true);
|
|
266601
|
+
{
|
|
266602
|
+
// Remove leading zero bytes
|
|
266603
|
+
let i = 0;
|
|
266604
|
+
for (; i < pubBin.length && pubBin[i] === 0x00; ++i);
|
|
266605
|
+
if (i > 0)
|
|
266606
|
+
pubBin = pubBin.slice(i);
|
|
266607
|
+
}
|
|
266608
|
+
|
|
266609
|
+
// Parse private key
|
|
266610
|
+
reader = new Ber.Reader(priv);
|
|
266611
|
+
reader.readSequence();
|
|
266612
|
+
|
|
266613
|
+
// - Version
|
|
266614
|
+
if (reader.readInt() !== 0)
|
|
266615
|
+
throw new Error('Unsupported version in ED25519 private key');
|
|
266616
|
+
|
|
266617
|
+
// - Algorithm
|
|
266618
|
+
reader.readSequence();
|
|
266619
|
+
if (reader.readOID() !== '1.3.101.112')
|
|
266620
|
+
throw new Error('Bad ED25519 private OID');
|
|
266621
|
+
// - Attributes (absent)
|
|
266622
|
+
|
|
266623
|
+
reader = new Ber.Reader(reader.readString(Ber.OctetString, true));
|
|
266624
|
+
const privBin = reader.readString(Ber.OctetString, true);
|
|
266625
|
+
|
|
266626
|
+
/*
|
|
266627
|
+
OpenSSH ed25519 private key:
|
|
266628
|
+
string "ssh-ed25519"
|
|
266629
|
+
string public key
|
|
266630
|
+
string private key + public key
|
|
266631
|
+
*/
|
|
266632
|
+
const keyName = Buffer.from('ssh-ed25519');
|
|
266633
|
+
const privBuf = Buffer.allocUnsafe(
|
|
266634
|
+
4 + keyName.length
|
|
266635
|
+
+ 4 + pubBin.length
|
|
266636
|
+
+ 4 + (privBin.length + pubBin.length)
|
|
266637
|
+
);
|
|
266638
|
+
let pos = 0;
|
|
266639
|
+
|
|
266640
|
+
privBuf.writeUInt32BE(keyName.length, pos += 0);
|
|
266641
|
+
privBuf.set(keyName, pos += 4);
|
|
266642
|
+
privBuf.writeUInt32BE(pubBin.length, pos += keyName.length);
|
|
266643
|
+
privBuf.set(pubBin, pos += 4);
|
|
266644
|
+
privBuf.writeUInt32BE(
|
|
266645
|
+
privBin.length + pubBin.length,
|
|
266646
|
+
pos += pubBin.length
|
|
266647
|
+
);
|
|
266648
|
+
privBuf.set(privBin, pos += 4);
|
|
266649
|
+
privBuf.set(pubBin, pos += privBin.length);
|
|
266650
|
+
|
|
266651
|
+
/*
|
|
266652
|
+
OpenSSH ed25519 public key:
|
|
266653
|
+
string "ssh-ed25519"
|
|
266654
|
+
string public key
|
|
266655
|
+
*/
|
|
266656
|
+
const pubBuf = Buffer.allocUnsafe(
|
|
266657
|
+
4 + keyName.length
|
|
266658
|
+
+ 4 + pubBin.length
|
|
266659
|
+
);
|
|
266660
|
+
pos = 0;
|
|
266661
|
+
|
|
266662
|
+
pubBuf.writeUInt32BE(keyName.length, pos += 0);
|
|
266663
|
+
pubBuf.set(keyName, pos += 4);
|
|
266664
|
+
pubBuf.writeUInt32BE(pubBin.length, pos += keyName.length);
|
|
266665
|
+
pubBuf.set(pubBin, pos += 4);
|
|
266666
|
+
|
|
266667
|
+
return { sshName: keyName.toString(), priv: privBuf, pub: pubBuf };
|
|
266668
|
+
}
|
|
266669
|
+
}
|
|
266670
|
+
}
|
|
266671
|
+
|
|
266672
|
+
function convertKeys(keyType, pub, priv, opts) {
|
|
266673
|
+
let format = 'new';
|
|
266674
|
+
let encrypted;
|
|
266675
|
+
let comment = '';
|
|
266676
|
+
if (typeof opts === 'object' && opts !== null) {
|
|
266677
|
+
if (typeof opts.comment === 'string' && opts.comment)
|
|
266678
|
+
comment = opts.comment;
|
|
266679
|
+
if (typeof opts.format === 'string' && opts.format)
|
|
266680
|
+
format = opts.format;
|
|
266681
|
+
if (opts.passphrase) {
|
|
266682
|
+
let passphrase;
|
|
266683
|
+
if (typeof opts.passphrase === 'string')
|
|
266684
|
+
passphrase = Buffer.from(opts.passphrase);
|
|
266685
|
+
else if (Buffer.isBuffer(opts.passphrase))
|
|
266686
|
+
passphrase = opts.passphrase;
|
|
266687
|
+
else
|
|
266688
|
+
throw new Error('Invalid passphrase');
|
|
266689
|
+
|
|
266690
|
+
if (opts.cipher === undefined)
|
|
266691
|
+
throw new Error('Missing cipher name');
|
|
266692
|
+
const cipher = ciphers.get(opts.cipher);
|
|
266693
|
+
if (cipher === undefined)
|
|
266694
|
+
throw new Error('Invalid cipher name');
|
|
266695
|
+
|
|
266696
|
+
if (format === 'new') {
|
|
266697
|
+
let rounds = DEFAULT_ROUNDS;
|
|
266698
|
+
if (opts.rounds !== undefined) {
|
|
266699
|
+
if (!Number.isInteger(opts.rounds))
|
|
266700
|
+
throw new TypeError('rounds must be an integer');
|
|
266701
|
+
if (opts.rounds > 0)
|
|
266702
|
+
rounds = opts.rounds;
|
|
266703
|
+
}
|
|
266704
|
+
|
|
266705
|
+
const gen = Buffer.allocUnsafe(cipher.keyLen + cipher.ivLen);
|
|
266706
|
+
const salt = randomBytes(SALT_LEN);
|
|
266707
|
+
const r = bcrypt_pbkdf(
|
|
266708
|
+
passphrase,
|
|
266709
|
+
passphrase.length,
|
|
266710
|
+
salt,
|
|
266711
|
+
salt.length,
|
|
266712
|
+
gen,
|
|
266713
|
+
gen.length,
|
|
266714
|
+
rounds
|
|
266715
|
+
);
|
|
266716
|
+
if (r !== 0)
|
|
266717
|
+
return new Error('Failed to generate information to encrypt key');
|
|
266718
|
+
|
|
266719
|
+
/*
|
|
266720
|
+
string salt
|
|
266721
|
+
uint32 rounds
|
|
266722
|
+
*/
|
|
266723
|
+
const kdfOptions = Buffer.allocUnsafe(4 + salt.length + 4);
|
|
266724
|
+
{
|
|
266725
|
+
let pos = 0;
|
|
266726
|
+
kdfOptions.writeUInt32BE(salt.length, pos += 0);
|
|
266727
|
+
kdfOptions.set(salt, pos += 4);
|
|
266728
|
+
kdfOptions.writeUInt32BE(rounds, pos += salt.length);
|
|
266729
|
+
}
|
|
266730
|
+
|
|
266731
|
+
encrypted = {
|
|
266732
|
+
cipher,
|
|
266733
|
+
cipherName: opts.cipher,
|
|
266734
|
+
kdfName: 'bcrypt',
|
|
266735
|
+
kdfOptions,
|
|
266736
|
+
key: gen.slice(0, cipher.keyLen),
|
|
266737
|
+
iv: gen.slice(cipher.keyLen),
|
|
266738
|
+
};
|
|
266739
|
+
}
|
|
266740
|
+
}
|
|
266741
|
+
}
|
|
266742
|
+
|
|
266743
|
+
switch (format) {
|
|
266744
|
+
case 'new': {
|
|
266745
|
+
let privateB64 = '-----BEGIN OPENSSH PRIVATE KEY-----\n';
|
|
266746
|
+
let publicB64;
|
|
266747
|
+
/*
|
|
266748
|
+
byte[] "openssh-key-v1\0"
|
|
266749
|
+
string ciphername
|
|
266750
|
+
string kdfname
|
|
266751
|
+
string kdfoptions
|
|
266752
|
+
uint32 number of keys N
|
|
266753
|
+
string publickey1
|
|
266754
|
+
string encrypted, padded list of private keys
|
|
266755
|
+
uint32 checkint
|
|
266756
|
+
uint32 checkint
|
|
266757
|
+
byte[] privatekey1
|
|
266758
|
+
string comment1
|
|
266759
|
+
byte 1
|
|
266760
|
+
byte 2
|
|
266761
|
+
byte 3
|
|
266762
|
+
...
|
|
266763
|
+
byte padlen % 255
|
|
266764
|
+
*/
|
|
266765
|
+
const cipherName = Buffer.from(encrypted ? encrypted.cipherName : 'none');
|
|
266766
|
+
const kdfName = Buffer.from(encrypted ? encrypted.kdfName : 'none');
|
|
266767
|
+
const kdfOptions = (encrypted ? encrypted.kdfOptions : Buffer.alloc(0));
|
|
266768
|
+
const blockLen = (encrypted ? encrypted.cipher.blockLen : 8);
|
|
266769
|
+
|
|
266770
|
+
const parsed = parseDERs(keyType, pub, priv);
|
|
266771
|
+
|
|
266772
|
+
const checkInt = randomBytes(4);
|
|
266773
|
+
const commentBin = Buffer.from(comment);
|
|
266774
|
+
const privBlobLen = (4 + 4 + parsed.priv.length + 4 + commentBin.length);
|
|
266775
|
+
let padding = [];
|
|
266776
|
+
for (let i = 1; ((privBlobLen + padding.length) % blockLen); ++i)
|
|
266777
|
+
padding.push(i & 0xFF);
|
|
266778
|
+
padding = Buffer.from(padding);
|
|
266779
|
+
|
|
266780
|
+
let privBlob = Buffer.allocUnsafe(privBlobLen + padding.length);
|
|
266781
|
+
let extra;
|
|
266782
|
+
{
|
|
266783
|
+
let pos = 0;
|
|
266784
|
+
privBlob.set(checkInt, pos += 0);
|
|
266785
|
+
privBlob.set(checkInt, pos += 4);
|
|
266786
|
+
privBlob.set(parsed.priv, pos += 4);
|
|
266787
|
+
privBlob.writeUInt32BE(commentBin.length, pos += parsed.priv.length);
|
|
266788
|
+
privBlob.set(commentBin, pos += 4);
|
|
266789
|
+
privBlob.set(padding, pos += commentBin.length);
|
|
266790
|
+
}
|
|
266791
|
+
|
|
266792
|
+
if (encrypted) {
|
|
266793
|
+
const options = { authTagLength: encrypted.cipher.authLen };
|
|
266794
|
+
const cipher = createCipheriv(
|
|
266795
|
+
encrypted.cipher.sslName,
|
|
266796
|
+
encrypted.key,
|
|
266797
|
+
encrypted.iv,
|
|
266798
|
+
options
|
|
266799
|
+
);
|
|
266800
|
+
cipher.setAutoPadding(false);
|
|
266801
|
+
privBlob = Buffer.concat([ cipher.update(privBlob), cipher.final() ]);
|
|
266802
|
+
if (encrypted.cipher.authLen > 0)
|
|
266803
|
+
extra = cipher.getAuthTag();
|
|
266804
|
+
else
|
|
266805
|
+
extra = Buffer.alloc(0);
|
|
266806
|
+
encrypted.key.fill(0);
|
|
266807
|
+
encrypted.iv.fill(0);
|
|
266808
|
+
} else {
|
|
266809
|
+
extra = Buffer.alloc(0);
|
|
266810
|
+
}
|
|
266811
|
+
|
|
266812
|
+
const magicBytes = Buffer.from('openssh-key-v1\0');
|
|
266813
|
+
const privBin = Buffer.allocUnsafe(
|
|
266814
|
+
magicBytes.length
|
|
266815
|
+
+ 4 + cipherName.length
|
|
266816
|
+
+ 4 + kdfName.length
|
|
266817
|
+
+ 4 + kdfOptions.length
|
|
266818
|
+
+ 4
|
|
266819
|
+
+ 4 + parsed.pub.length
|
|
266820
|
+
+ 4 + privBlob.length
|
|
266821
|
+
+ extra.length
|
|
266822
|
+
);
|
|
266823
|
+
{
|
|
266824
|
+
let pos = 0;
|
|
266825
|
+
privBin.set(magicBytes, pos += 0);
|
|
266826
|
+
privBin.writeUInt32BE(cipherName.length, pos += magicBytes.length);
|
|
266827
|
+
privBin.set(cipherName, pos += 4);
|
|
266828
|
+
privBin.writeUInt32BE(kdfName.length, pos += cipherName.length);
|
|
266829
|
+
privBin.set(kdfName, pos += 4);
|
|
266830
|
+
privBin.writeUInt32BE(kdfOptions.length, pos += kdfName.length);
|
|
266831
|
+
privBin.set(kdfOptions, pos += 4);
|
|
266832
|
+
privBin.writeUInt32BE(1, pos += kdfOptions.length);
|
|
266833
|
+
privBin.writeUInt32BE(parsed.pub.length, pos += 4);
|
|
266834
|
+
privBin.set(parsed.pub, pos += 4);
|
|
266835
|
+
privBin.writeUInt32BE(privBlob.length, pos += parsed.pub.length);
|
|
266836
|
+
privBin.set(privBlob, pos += 4);
|
|
266837
|
+
privBin.set(extra, pos += privBlob.length);
|
|
266838
|
+
}
|
|
266839
|
+
|
|
266840
|
+
{
|
|
266841
|
+
const b64 = privBin.base64Slice(0, privBin.length);
|
|
266842
|
+
let formatted = b64.replace(/.{64}/g, '$&\n');
|
|
266843
|
+
if (b64.length & 63)
|
|
266844
|
+
formatted += '\n';
|
|
266845
|
+
privateB64 += formatted;
|
|
266846
|
+
}
|
|
266847
|
+
|
|
266848
|
+
{
|
|
266849
|
+
const b64 = parsed.pub.base64Slice(0, parsed.pub.length);
|
|
266850
|
+
publicB64 = `${parsed.sshName} ${b64}${comment ? ` ${comment}` : ''}`;
|
|
266851
|
+
}
|
|
266852
|
+
|
|
266853
|
+
privateB64 += '-----END OPENSSH PRIVATE KEY-----\n';
|
|
266854
|
+
return {
|
|
266855
|
+
private: privateB64,
|
|
266856
|
+
public: publicB64,
|
|
266857
|
+
};
|
|
266858
|
+
}
|
|
266859
|
+
default:
|
|
266860
|
+
throw new Error('Invalid output key format');
|
|
266861
|
+
}
|
|
266862
|
+
}
|
|
266863
|
+
|
|
266864
|
+
function noop() {}
|
|
266865
|
+
|
|
266866
|
+
module.exports = {
|
|
266867
|
+
generateKeyPair: (keyType, opts, cb) => {
|
|
266868
|
+
if (typeof opts === 'function') {
|
|
266869
|
+
cb = opts;
|
|
266870
|
+
opts = undefined;
|
|
266871
|
+
}
|
|
266872
|
+
if (typeof cb !== 'function')
|
|
266873
|
+
cb = noop;
|
|
266874
|
+
const args = makeArgs(keyType, opts);
|
|
266875
|
+
generateKeyPair_(...args, (err, pub, priv) => {
|
|
266876
|
+
if (err)
|
|
266877
|
+
return cb(err);
|
|
266878
|
+
let ret;
|
|
266879
|
+
try {
|
|
266880
|
+
ret = convertKeys(args[0], pub, priv, opts);
|
|
266881
|
+
} catch (ex) {
|
|
266882
|
+
return cb(ex);
|
|
266883
|
+
}
|
|
266884
|
+
cb(null, ret);
|
|
266885
|
+
});
|
|
266886
|
+
},
|
|
266887
|
+
generateKeyPairSync: (keyType, opts) => {
|
|
266888
|
+
const args = makeArgs(keyType, opts);
|
|
266889
|
+
const { publicKey: pub, privateKey: priv } = generateKeyPairSync_(...args);
|
|
266890
|
+
return convertKeys(args[0], pub, priv, opts);
|
|
266891
|
+
}
|
|
266892
|
+
};
|
|
266893
|
+
|
|
266894
|
+
|
|
265827
266895
|
/***/ }),
|
|
265828
266896
|
|
|
265829
266897
|
/***/ 53603:
|
|
@@ -265876,12 +266944,14 @@ const { bindingAvailable, NullCipher, NullDecipher } = __webpack_require__(83877
|
|
|
265876
266944
|
const {
|
|
265877
266945
|
COMPAT_CHECKS,
|
|
265878
266946
|
DISCONNECT_REASON,
|
|
266947
|
+
eddsaSupported,
|
|
265879
266948
|
MESSAGE,
|
|
265880
266949
|
SIGNALS,
|
|
265881
266950
|
TERMINAL_MODE,
|
|
265882
266951
|
} = __webpack_require__(3190);
|
|
265883
266952
|
const {
|
|
265884
|
-
|
|
266953
|
+
DEFAULT_KEXINIT_CLIENT,
|
|
266954
|
+
DEFAULT_KEXINIT_SERVER,
|
|
265885
266955
|
KexInit,
|
|
265886
266956
|
kexinit,
|
|
265887
266957
|
onKEXPayload,
|
|
@@ -265970,8 +267040,13 @@ class Protocol {
|
|
|
265970
267040
|
let onHandshakeComplete = config.onHandshakeComplete;
|
|
265971
267041
|
if (typeof onHandshakeComplete !== 'function')
|
|
265972
267042
|
onHandshakeComplete = noop;
|
|
267043
|
+
let firstHandshake;
|
|
265973
267044
|
this._onHandshakeComplete = (...args) => {
|
|
265974
267045
|
this._debug && this._debug('Handshake completed');
|
|
267046
|
+
if (firstHandshake === undefined)
|
|
267047
|
+
firstHandshake = true;
|
|
267048
|
+
else
|
|
267049
|
+
firstHandshake = false;
|
|
265975
267050
|
|
|
265976
267051
|
// Process packets queued during a rekey where necessary
|
|
265977
267052
|
const oldQueue = this._queue;
|
|
@@ -265997,6 +267072,9 @@ class Protocol {
|
|
|
265997
267072
|
this._debug && this._debug('... finished draining outbound queue');
|
|
265998
267073
|
}
|
|
265999
267074
|
|
|
267075
|
+
if (firstHandshake && this._server && this._kex.remoteExtInfoEnabled)
|
|
267076
|
+
sendExtInfo(this);
|
|
267077
|
+
|
|
266000
267078
|
onHandshakeComplete(...args);
|
|
266001
267079
|
};
|
|
266002
267080
|
this._queue = undefined;
|
|
@@ -266037,10 +267115,13 @@ class Protocol {
|
|
|
266037
267115
|
}
|
|
266038
267116
|
|
|
266039
267117
|
let offer = config.offer;
|
|
266040
|
-
if (typeof offer !== 'object' || offer === null)
|
|
266041
|
-
offer =
|
|
266042
|
-
else if (offer.constructor !== KexInit)
|
|
267118
|
+
if (typeof offer !== 'object' || offer === null) {
|
|
267119
|
+
offer = (this._server ? DEFAULT_KEXINIT_SERVER : DEFAULT_KEXINIT_CLIENT);
|
|
267120
|
+
} else if (offer.constructor !== KexInit) {
|
|
267121
|
+
if (!this._server)
|
|
267122
|
+
offer.kex = offer.kex.concat(['ext-info-c']);
|
|
266043
267123
|
offer = new KexInit(offer);
|
|
267124
|
+
}
|
|
266044
267125
|
this._kex = undefined;
|
|
266045
267126
|
this._kexinit = undefined;
|
|
266046
267127
|
this._offer = offer;
|
|
@@ -266440,7 +267521,7 @@ class Protocol {
|
|
|
266440
267521
|
|
|
266441
267522
|
sendPacket(this, this._packetRW.write.finalize(packet));
|
|
266442
267523
|
}
|
|
266443
|
-
authPK(username, pubKey, cbSign) {
|
|
267524
|
+
authPK(username, pubKey, keyAlgo, cbSign) {
|
|
266444
267525
|
if (this._server)
|
|
266445
267526
|
throw new Error('Client-only method called in server mode');
|
|
266446
267527
|
|
|
@@ -266451,8 +267532,15 @@ class Protocol {
|
|
|
266451
267532
|
const keyType = pubKey.type;
|
|
266452
267533
|
pubKey = pubKey.getPublicSSH();
|
|
266453
267534
|
|
|
267535
|
+
if (typeof keyAlgo === 'function') {
|
|
267536
|
+
cbSign = keyAlgo;
|
|
267537
|
+
keyAlgo = undefined;
|
|
267538
|
+
}
|
|
267539
|
+
if (!keyAlgo)
|
|
267540
|
+
keyAlgo = keyType;
|
|
267541
|
+
|
|
266454
267542
|
const userLen = Buffer.byteLength(username);
|
|
266455
|
-
const algoLen = Buffer.byteLength(
|
|
267543
|
+
const algoLen = Buffer.byteLength(keyAlgo);
|
|
266456
267544
|
const pubKeyLen = pubKey.length;
|
|
266457
267545
|
const sessionID = this._kex.sessionID;
|
|
266458
267546
|
const sesLen = sessionID.length;
|
|
@@ -266486,7 +267574,7 @@ class Protocol {
|
|
|
266486
267574
|
packet[p += 9] = (cbSign ? 1 : 0);
|
|
266487
267575
|
|
|
266488
267576
|
writeUInt32BE(packet, algoLen, ++p);
|
|
266489
|
-
packet.utf8Write(
|
|
267577
|
+
packet.utf8Write(keyAlgo, p += 4, algoLen);
|
|
266490
267578
|
|
|
266491
267579
|
writeUInt32BE(packet, pubKeyLen, p += algoLen);
|
|
266492
267580
|
packet.set(pubKey, p += 4);
|
|
@@ -266529,7 +267617,7 @@ class Protocol {
|
|
|
266529
267617
|
packet[p += 9] = 1;
|
|
266530
267618
|
|
|
266531
267619
|
writeUInt32BE(packet, algoLen, ++p);
|
|
266532
|
-
packet.utf8Write(
|
|
267620
|
+
packet.utf8Write(keyAlgo, p += 4, algoLen);
|
|
266533
267621
|
|
|
266534
267622
|
writeUInt32BE(packet, pubKeyLen, p += algoLen);
|
|
266535
267623
|
packet.set(pubKey, p += 4);
|
|
@@ -266537,7 +267625,7 @@ class Protocol {
|
|
|
266537
267625
|
writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += pubKeyLen);
|
|
266538
267626
|
|
|
266539
267627
|
writeUInt32BE(packet, algoLen, p += 4);
|
|
266540
|
-
packet.utf8Write(
|
|
267628
|
+
packet.utf8Write(keyAlgo, p += 4, algoLen);
|
|
266541
267629
|
|
|
266542
267630
|
writeUInt32BE(packet, sigLen, p += algoLen);
|
|
266543
267631
|
packet.set(signature, p += 4);
|
|
@@ -266552,7 +267640,7 @@ class Protocol {
|
|
|
266552
267640
|
sendPacket(this, this._packetRW.write.finalize(packet));
|
|
266553
267641
|
});
|
|
266554
267642
|
}
|
|
266555
|
-
authHostbased(username, pubKey, hostname, userlocal, cbSign) {
|
|
267643
|
+
authHostbased(username, pubKey, hostname, userlocal, keyAlgo, cbSign) {
|
|
266556
267644
|
// TODO: Make DRY by sharing similar code with authPK()
|
|
266557
267645
|
if (this._server)
|
|
266558
267646
|
throw new Error('Client-only method called in server mode');
|
|
@@ -266564,8 +267652,15 @@ class Protocol {
|
|
|
266564
267652
|
const keyType = pubKey.type;
|
|
266565
267653
|
pubKey = pubKey.getPublicSSH();
|
|
266566
267654
|
|
|
267655
|
+
if (typeof keyAlgo === 'function') {
|
|
267656
|
+
cbSign = keyAlgo;
|
|
267657
|
+
keyAlgo = undefined;
|
|
267658
|
+
}
|
|
267659
|
+
if (!keyAlgo)
|
|
267660
|
+
keyAlgo = keyType;
|
|
267661
|
+
|
|
266567
267662
|
const userLen = Buffer.byteLength(username);
|
|
266568
|
-
const algoLen = Buffer.byteLength(
|
|
267663
|
+
const algoLen = Buffer.byteLength(keyAlgo);
|
|
266569
267664
|
const pubKeyLen = pubKey.length;
|
|
266570
267665
|
const sessionID = this._kex.sessionID;
|
|
266571
267666
|
const sesLen = sessionID.length;
|
|
@@ -266592,7 +267687,7 @@ class Protocol {
|
|
|
266592
267687
|
data.utf8Write('hostbased', p += 4, 9);
|
|
266593
267688
|
|
|
266594
267689
|
writeUInt32BE(data, algoLen, p += 9);
|
|
266595
|
-
data.utf8Write(
|
|
267690
|
+
data.utf8Write(keyAlgo, p += 4, algoLen);
|
|
266596
267691
|
|
|
266597
267692
|
writeUInt32BE(data, pubKeyLen, p += algoLen);
|
|
266598
267693
|
data.set(pubKey, p += 4);
|
|
@@ -266619,7 +267714,7 @@ class Protocol {
|
|
|
266619
267714
|
|
|
266620
267715
|
writeUInt32BE(packet, 4 + algoLen + 4 + sigLen, p += reqDataLen);
|
|
266621
267716
|
writeUInt32BE(packet, algoLen, p += 4);
|
|
266622
|
-
packet.utf8Write(
|
|
267717
|
+
packet.utf8Write(keyAlgo, p += 4, algoLen);
|
|
266623
267718
|
writeUInt32BE(packet, sigLen, p += algoLen);
|
|
266624
267719
|
packet.set(signature, p += 4);
|
|
266625
267720
|
|
|
@@ -267906,6 +269001,31 @@ function modesToBytes(modes) {
|
|
|
267906
269001
|
return bytes;
|
|
267907
269002
|
}
|
|
267908
269003
|
|
|
269004
|
+
function sendExtInfo(proto) {
|
|
269005
|
+
let serverSigAlgs =
|
|
269006
|
+
'ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521'
|
|
269007
|
+
+ 'rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss';
|
|
269008
|
+
if (eddsaSupported)
|
|
269009
|
+
serverSigAlgs = `ssh-ed25519,${serverSigAlgs}`;
|
|
269010
|
+
const algsLen = Buffer.byteLength(serverSigAlgs);
|
|
269011
|
+
|
|
269012
|
+
let p = proto._packetRW.write.allocStart;
|
|
269013
|
+
const packet = proto._packetRW.write.alloc(1 + 4 + 4 + 15 + 4 + algsLen);
|
|
269014
|
+
|
|
269015
|
+
packet[p] = MESSAGE.EXT_INFO;
|
|
269016
|
+
|
|
269017
|
+
writeUInt32BE(packet, 1, ++p);
|
|
269018
|
+
|
|
269019
|
+
writeUInt32BE(packet, 15, p += 4);
|
|
269020
|
+
packet.utf8Write('server-sig-algs', p += 4, 15);
|
|
269021
|
+
|
|
269022
|
+
writeUInt32BE(packet, algsLen, p += 15);
|
|
269023
|
+
packet.utf8Write(serverSigAlgs, p += 4, algsLen);
|
|
269024
|
+
|
|
269025
|
+
proto._debug && proto._debug('Outbound: Sending EXT_INFO');
|
|
269026
|
+
sendPacket(proto, proto._packetRW.write.finalize(packet));
|
|
269027
|
+
}
|
|
269028
|
+
|
|
267909
269029
|
module.exports = Protocol;
|
|
267910
269030
|
|
|
267911
269031
|
|
|
@@ -269505,7 +270625,17 @@ class SFTP extends EventEmitter {
|
|
|
269505
270625
|
writeUInt32BE(buf, pathLen, p += 20);
|
|
269506
270626
|
buf.utf8Write(path, p += 4, pathLen);
|
|
269507
270627
|
|
|
269508
|
-
this._requests[reqid] = {
|
|
270628
|
+
this._requests[reqid] = {
|
|
270629
|
+
cb: (err, names) => {
|
|
270630
|
+
if (typeof cb !== 'function')
|
|
270631
|
+
return;
|
|
270632
|
+
if (err)
|
|
270633
|
+
return cb(err);
|
|
270634
|
+
if (!names || !names.length)
|
|
270635
|
+
return cb(new Error('Response missing expanded path'));
|
|
270636
|
+
cb(undefined, names[0].filename);
|
|
270637
|
+
}
|
|
270638
|
+
};
|
|
269509
270639
|
|
|
269510
270640
|
const isBuffered = sendOrBuffer(this, buf);
|
|
269511
270641
|
if (this._debug) {
|
|
@@ -269598,6 +270728,146 @@ class SFTP extends EventEmitter {
|
|
|
269598
270728
|
this._debug(`SFTP: Outbound: ${status} copy-data`);
|
|
269599
270729
|
}
|
|
269600
270730
|
}
|
|
270731
|
+
ext_home_dir(username, cb) {
|
|
270732
|
+
if (this.server)
|
|
270733
|
+
throw new Error('Client-only method called in server mode');
|
|
270734
|
+
|
|
270735
|
+
const ext = this._extensions['home-directory'];
|
|
270736
|
+
if (ext !== '1')
|
|
270737
|
+
throw new Error('Server does not support this extended request');
|
|
270738
|
+
|
|
270739
|
+
if (typeof username !== 'string')
|
|
270740
|
+
throw new TypeError('username is not a string');
|
|
270741
|
+
|
|
270742
|
+
/*
|
|
270743
|
+
uint32 id
|
|
270744
|
+
string "home-directory"
|
|
270745
|
+
string username
|
|
270746
|
+
*/
|
|
270747
|
+
let p = 0;
|
|
270748
|
+
const usernameLen = Buffer.byteLength(username);
|
|
270749
|
+
const buf = Buffer.allocUnsafe(
|
|
270750
|
+
4 + 1
|
|
270751
|
+
+ 4
|
|
270752
|
+
+ 4 + 14
|
|
270753
|
+
+ 4 + usernameLen
|
|
270754
|
+
);
|
|
270755
|
+
|
|
270756
|
+
writeUInt32BE(buf, buf.length - 4, p);
|
|
270757
|
+
p += 4;
|
|
270758
|
+
|
|
270759
|
+
buf[p] = REQUEST.EXTENDED;
|
|
270760
|
+
++p;
|
|
270761
|
+
|
|
270762
|
+
const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
|
|
270763
|
+
writeUInt32BE(buf, reqid, p);
|
|
270764
|
+
p += 4;
|
|
270765
|
+
|
|
270766
|
+
writeUInt32BE(buf, 14, p);
|
|
270767
|
+
p += 4;
|
|
270768
|
+
buf.utf8Write('home-directory', p, 14);
|
|
270769
|
+
p += 14;
|
|
270770
|
+
|
|
270771
|
+
writeUInt32BE(buf, usernameLen, p);
|
|
270772
|
+
p += 4;
|
|
270773
|
+
buf.utf8Write(username, p, usernameLen);
|
|
270774
|
+
p += usernameLen;
|
|
270775
|
+
|
|
270776
|
+
this._requests[reqid] = {
|
|
270777
|
+
cb: (err, names) => {
|
|
270778
|
+
if (typeof cb !== 'function')
|
|
270779
|
+
return;
|
|
270780
|
+
if (err)
|
|
270781
|
+
return cb(err);
|
|
270782
|
+
if (!names || !names.length)
|
|
270783
|
+
return cb(new Error('Response missing home directory'));
|
|
270784
|
+
cb(undefined, names[0].filename);
|
|
270785
|
+
}
|
|
270786
|
+
};
|
|
270787
|
+
|
|
270788
|
+
const isBuffered = sendOrBuffer(this, buf);
|
|
270789
|
+
if (this._debug) {
|
|
270790
|
+
const status = (isBuffered ? 'Buffered' : 'Sending');
|
|
270791
|
+
this._debug(`SFTP: Outbound: ${status} home-directory`);
|
|
270792
|
+
}
|
|
270793
|
+
}
|
|
270794
|
+
ext_users_groups(uids, gids, cb) {
|
|
270795
|
+
if (this.server)
|
|
270796
|
+
throw new Error('Client-only method called in server mode');
|
|
270797
|
+
|
|
270798
|
+
const ext = this._extensions['users-groups-by-id@openssh.com'];
|
|
270799
|
+
if (ext !== '1')
|
|
270800
|
+
throw new Error('Server does not support this extended request');
|
|
270801
|
+
|
|
270802
|
+
if (!Array.isArray(uids))
|
|
270803
|
+
throw new TypeError('uids is not an array');
|
|
270804
|
+
for (const val of uids) {
|
|
270805
|
+
if (!Number.isInteger(val) || val < 0 || val > (2 ** 32 - 1))
|
|
270806
|
+
throw new Error('uid values must all be 32-bit unsigned integers');
|
|
270807
|
+
}
|
|
270808
|
+
if (!Array.isArray(gids))
|
|
270809
|
+
throw new TypeError('gids is not an array');
|
|
270810
|
+
for (const val of gids) {
|
|
270811
|
+
if (!Number.isInteger(val) || val < 0 || val > (2 ** 32 - 1))
|
|
270812
|
+
throw new Error('gid values must all be 32-bit unsigned integers');
|
|
270813
|
+
}
|
|
270814
|
+
|
|
270815
|
+
/*
|
|
270816
|
+
uint32 id
|
|
270817
|
+
string "users-groups-by-id@openssh.com"
|
|
270818
|
+
string uids
|
|
270819
|
+
uint32 uid1
|
|
270820
|
+
...
|
|
270821
|
+
string gids
|
|
270822
|
+
uint32 gid1
|
|
270823
|
+
...
|
|
270824
|
+
*/
|
|
270825
|
+
let p = 0;
|
|
270826
|
+
const buf = Buffer.allocUnsafe(
|
|
270827
|
+
4 + 1
|
|
270828
|
+
+ 4
|
|
270829
|
+
+ 4 + 30
|
|
270830
|
+
+ 4 + (4 * uids.length)
|
|
270831
|
+
+ 4 + (4 * gids.length)
|
|
270832
|
+
);
|
|
270833
|
+
|
|
270834
|
+
writeUInt32BE(buf, buf.length - 4, p);
|
|
270835
|
+
p += 4;
|
|
270836
|
+
|
|
270837
|
+
buf[p] = REQUEST.EXTENDED;
|
|
270838
|
+
++p;
|
|
270839
|
+
|
|
270840
|
+
const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
|
|
270841
|
+
writeUInt32BE(buf, reqid, p);
|
|
270842
|
+
p += 4;
|
|
270843
|
+
|
|
270844
|
+
writeUInt32BE(buf, 30, p);
|
|
270845
|
+
p += 4;
|
|
270846
|
+
buf.utf8Write('users-groups-by-id@openssh.com', p, 30);
|
|
270847
|
+
p += 30;
|
|
270848
|
+
|
|
270849
|
+
writeUInt32BE(buf, 4 * uids.length, p);
|
|
270850
|
+
p += 4;
|
|
270851
|
+
for (const val of uids) {
|
|
270852
|
+
writeUInt32BE(buf, val, p);
|
|
270853
|
+
p += 4;
|
|
270854
|
+
}
|
|
270855
|
+
|
|
270856
|
+
writeUInt32BE(buf, 4 * gids.length, p);
|
|
270857
|
+
p += 4;
|
|
270858
|
+
for (const val of gids) {
|
|
270859
|
+
writeUInt32BE(buf, val, p);
|
|
270860
|
+
p += 4;
|
|
270861
|
+
}
|
|
270862
|
+
|
|
270863
|
+
this._requests[reqid] = { extended: 'users-groups-by-id@openssh.com', cb };
|
|
270864
|
+
|
|
270865
|
+
const isBuffered = sendOrBuffer(this, buf);
|
|
270866
|
+
if (this._debug) {
|
|
270867
|
+
const status = (isBuffered ? 'Buffered' : 'Sending');
|
|
270868
|
+
this._debug(`SFTP: Outbound: ${status} users-groups-by-id@openssh.com`);
|
|
270869
|
+
}
|
|
270870
|
+
}
|
|
269601
270871
|
// ===========================================================================
|
|
269602
270872
|
// Server-specific ===========================================================
|
|
269603
270873
|
// ===========================================================================
|
|
@@ -270845,6 +272115,44 @@ const CLIENT_HANDLERS = {
|
|
|
270845
272115
|
req.cb(undefined, limits);
|
|
270846
272116
|
return;
|
|
270847
272117
|
}
|
|
272118
|
+
case 'users-groups-by-id@openssh.com': {
|
|
272119
|
+
/*
|
|
272120
|
+
string usernames
|
|
272121
|
+
string username1
|
|
272122
|
+
...
|
|
272123
|
+
string groupnames
|
|
272124
|
+
string groupname1
|
|
272125
|
+
...
|
|
272126
|
+
*/
|
|
272127
|
+
const usernameCount = bufferParser.readUInt32BE();
|
|
272128
|
+
if (usernameCount === undefined)
|
|
272129
|
+
break;
|
|
272130
|
+
const usernames = new Array(usernameCount);
|
|
272131
|
+
for (let i = 0; i < usernames.length; ++i)
|
|
272132
|
+
usernames[i] = bufferParser.readString(true);
|
|
272133
|
+
|
|
272134
|
+
const groupnameCount = bufferParser.readUInt32BE();
|
|
272135
|
+
if (groupnameCount === undefined)
|
|
272136
|
+
break;
|
|
272137
|
+
const groupnames = new Array(groupnameCount);
|
|
272138
|
+
for (let i = 0; i < groupnames.length; ++i)
|
|
272139
|
+
groupnames[i] = bufferParser.readString(true);
|
|
272140
|
+
if (groupnames.length > 0
|
|
272141
|
+
&& groupnames[groupnames.length - 1] === undefined) {
|
|
272142
|
+
break;
|
|
272143
|
+
}
|
|
272144
|
+
|
|
272145
|
+
if (sftp._debug) {
|
|
272146
|
+
sftp._debug(
|
|
272147
|
+
'SFTP: Inbound: Received EXTENDED_REPLY '
|
|
272148
|
+
+ `(id:${reqID}, ${req.extended})`
|
|
272149
|
+
);
|
|
272150
|
+
}
|
|
272151
|
+
bufferParser.clear();
|
|
272152
|
+
if (typeof req.cb === 'function')
|
|
272153
|
+
req.cb(undefined, usernames, groupnames);
|
|
272154
|
+
return;
|
|
272155
|
+
}
|
|
270848
272156
|
default:
|
|
270849
272157
|
// Unknown extended request
|
|
270850
272158
|
sftp._debug && sftp._debug(
|
|
@@ -271948,6 +273256,7 @@ const COMPAT = {
|
|
|
271948
273256
|
OLD_EXIT: 1 << 1,
|
|
271949
273257
|
DYN_RPORT_BUG: 1 << 2,
|
|
271950
273258
|
BUG_DHGEX_LARGE: 1 << 3,
|
|
273259
|
+
IMPLY_RSA_SHA2_SIGALGS: 1 << 4,
|
|
271951
273260
|
};
|
|
271952
273261
|
|
|
271953
273262
|
module.exports = {
|
|
@@ -271959,6 +273268,7 @@ module.exports = {
|
|
|
271959
273268
|
DEBUG: 4,
|
|
271960
273269
|
SERVICE_REQUEST: 5,
|
|
271961
273270
|
SERVICE_ACCEPT: 6,
|
|
273271
|
+
EXT_INFO: 7, // RFC 8308
|
|
271962
273272
|
|
|
271963
273273
|
// Transport layer protocol -- algorithm negotiation (20-29)
|
|
271964
273274
|
KEXINIT: 20,
|
|
@@ -272116,9 +273426,10 @@ module.exports = {
|
|
|
272116
273426
|
COMPAT,
|
|
272117
273427
|
COMPAT_CHECKS: [
|
|
272118
273428
|
[ 'Cisco-1.25', COMPAT.BAD_DHGEX ],
|
|
272119
|
-
[ /^Cisco-1
|
|
273429
|
+
[ /^Cisco-1[.]/, COMPAT.BUG_DHGEX_LARGE ],
|
|
272120
273430
|
[ /^[0-9.]+$/, COMPAT.OLD_EXIT ], // old SSH.com implementations
|
|
272121
|
-
[ /^OpenSSH_5
|
|
273431
|
+
[ /^OpenSSH_5[.][0-9]+/, COMPAT.DYN_RPORT_BUG ],
|
|
273432
|
+
[ /^OpenSSH_7[.]4/, COMPAT.IMPLY_RSA_SHA2_SIGALGS ],
|
|
272122
273433
|
],
|
|
272123
273434
|
|
|
272124
273435
|
// KEX proposal-related
|
|
@@ -273977,6 +275288,48 @@ module.exports = {
|
|
|
273977
275288
|
const handler = self._handlers.SERVICE_ACCEPT;
|
|
273978
275289
|
handler && handler(self, name);
|
|
273979
275290
|
},
|
|
275291
|
+
[MESSAGE.EXT_INFO]: (self, payload) => {
|
|
275292
|
+
/*
|
|
275293
|
+
byte SSH_MSG_EXT_INFO
|
|
275294
|
+
uint32 nr-extensions
|
|
275295
|
+
repeat the following 2 fields "nr-extensions" times:
|
|
275296
|
+
string extension-name
|
|
275297
|
+
string extension-value (binary)
|
|
275298
|
+
*/
|
|
275299
|
+
bufferParser.init(payload, 1);
|
|
275300
|
+
const numExts = bufferParser.readUInt32BE();
|
|
275301
|
+
let exts;
|
|
275302
|
+
if (numExts !== undefined) {
|
|
275303
|
+
exts = [];
|
|
275304
|
+
for (let i = 0; i < numExts; ++i) {
|
|
275305
|
+
const name = bufferParser.readString(true);
|
|
275306
|
+
const data = bufferParser.readString();
|
|
275307
|
+
if (data !== undefined) {
|
|
275308
|
+
switch (name) {
|
|
275309
|
+
case 'server-sig-algs': {
|
|
275310
|
+
const algs = data.latin1Slice(0, data.length).split(',');
|
|
275311
|
+
exts.push({ name, algs });
|
|
275312
|
+
continue;
|
|
275313
|
+
}
|
|
275314
|
+
default:
|
|
275315
|
+
continue;
|
|
275316
|
+
}
|
|
275317
|
+
}
|
|
275318
|
+
// Malformed
|
|
275319
|
+
exts = undefined;
|
|
275320
|
+
break;
|
|
275321
|
+
}
|
|
275322
|
+
}
|
|
275323
|
+
bufferParser.clear();
|
|
275324
|
+
|
|
275325
|
+
if (exts === undefined)
|
|
275326
|
+
return doFatalError(self, 'Inbound: Malformed EXT_INFO packet');
|
|
275327
|
+
|
|
275328
|
+
self._debug && self._debug('Inbound: Received EXT_INFO');
|
|
275329
|
+
|
|
275330
|
+
const handler = self._handlers.EXT_INFO;
|
|
275331
|
+
handler && handler(self, exts);
|
|
275332
|
+
},
|
|
273980
275333
|
|
|
273981
275334
|
// User auth protocol -- generic =============================================
|
|
273982
275335
|
[MESSAGE.USERAUTH_REQUEST]: (self, payload) => {
|
|
@@ -274026,7 +275379,21 @@ module.exports = {
|
|
|
274026
275379
|
const hasSig = bufferParser.readBool();
|
|
274027
275380
|
if (hasSig !== undefined) {
|
|
274028
275381
|
const keyAlgo = bufferParser.readString(true);
|
|
275382
|
+
let realKeyAlgo = keyAlgo;
|
|
274029
275383
|
const key = bufferParser.readString();
|
|
275384
|
+
|
|
275385
|
+
let hashAlgo;
|
|
275386
|
+
switch (keyAlgo) {
|
|
275387
|
+
case 'rsa-sha2-256':
|
|
275388
|
+
realKeyAlgo = 'ssh-rsa';
|
|
275389
|
+
hashAlgo = 'sha256';
|
|
275390
|
+
break;
|
|
275391
|
+
case 'rsa-sha2-512':
|
|
275392
|
+
realKeyAlgo = 'ssh-rsa';
|
|
275393
|
+
hashAlgo = 'sha512';
|
|
275394
|
+
break;
|
|
275395
|
+
}
|
|
275396
|
+
|
|
274030
275397
|
if (hasSig) {
|
|
274031
275398
|
const blobEnd = bufferParser.pos();
|
|
274032
275399
|
let signature = bufferParser.readString();
|
|
@@ -274037,7 +275404,7 @@ module.exports = {
|
|
|
274037
275404
|
signature = bufferSlice(signature, 4 + keyAlgo.length + 4);
|
|
274038
275405
|
}
|
|
274039
275406
|
|
|
274040
|
-
signature = sigSSHToASN1(signature,
|
|
275407
|
+
signature = sigSSHToASN1(signature, realKeyAlgo);
|
|
274041
275408
|
if (signature) {
|
|
274042
275409
|
const sessionID = self._kex.sessionID;
|
|
274043
275410
|
const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);
|
|
@@ -274048,15 +275415,16 @@ module.exports = {
|
|
|
274048
275415
|
4 + sessionID.length
|
|
274049
275416
|
);
|
|
274050
275417
|
methodData = {
|
|
274051
|
-
keyAlgo,
|
|
275418
|
+
keyAlgo: realKeyAlgo,
|
|
274052
275419
|
key,
|
|
274053
275420
|
signature,
|
|
274054
275421
|
blob,
|
|
275422
|
+
hashAlgo,
|
|
274055
275423
|
};
|
|
274056
275424
|
}
|
|
274057
275425
|
}
|
|
274058
275426
|
} else {
|
|
274059
|
-
methodData = { keyAlgo, key };
|
|
275427
|
+
methodData = { keyAlgo: realKeyAlgo, key, hashAlgo };
|
|
274060
275428
|
methodDesc = 'publickey -- check';
|
|
274061
275429
|
}
|
|
274062
275430
|
}
|
|
@@ -274072,10 +275440,23 @@ module.exports = {
|
|
|
274072
275440
|
string signature
|
|
274073
275441
|
*/
|
|
274074
275442
|
const keyAlgo = bufferParser.readString(true);
|
|
275443
|
+
let realKeyAlgo = keyAlgo;
|
|
274075
275444
|
const key = bufferParser.readString();
|
|
274076
275445
|
const localHostname = bufferParser.readString(true);
|
|
274077
275446
|
const localUsername = bufferParser.readString(true);
|
|
274078
275447
|
|
|
275448
|
+
let hashAlgo;
|
|
275449
|
+
switch (keyAlgo) {
|
|
275450
|
+
case 'rsa-sha2-256':
|
|
275451
|
+
realKeyAlgo = 'ssh-rsa';
|
|
275452
|
+
hashAlgo = 'sha256';
|
|
275453
|
+
break;
|
|
275454
|
+
case 'rsa-sha2-512':
|
|
275455
|
+
realKeyAlgo = 'ssh-rsa';
|
|
275456
|
+
hashAlgo = 'sha512';
|
|
275457
|
+
break;
|
|
275458
|
+
}
|
|
275459
|
+
|
|
274079
275460
|
const blobEnd = bufferParser.pos();
|
|
274080
275461
|
let signature = bufferParser.readString();
|
|
274081
275462
|
if (signature !== undefined) {
|
|
@@ -274085,7 +275466,7 @@ module.exports = {
|
|
|
274085
275466
|
signature = bufferSlice(signature, 4 + keyAlgo.length + 4);
|
|
274086
275467
|
}
|
|
274087
275468
|
|
|
274088
|
-
signature = sigSSHToASN1(signature,
|
|
275469
|
+
signature = sigSSHToASN1(signature, realKeyAlgo);
|
|
274089
275470
|
if (signature !== undefined) {
|
|
274090
275471
|
const sessionID = self._kex.sessionID;
|
|
274091
275472
|
const blob = Buffer.allocUnsafe(4 + sessionID.length + blobEnd);
|
|
@@ -274096,12 +275477,13 @@ module.exports = {
|
|
|
274096
275477
|
4 + sessionID.length
|
|
274097
275478
|
);
|
|
274098
275479
|
methodData = {
|
|
274099
|
-
keyAlgo,
|
|
275480
|
+
keyAlgo: realKeyAlgo,
|
|
274100
275481
|
key,
|
|
274101
275482
|
signature,
|
|
274102
275483
|
blob,
|
|
274103
275484
|
localHostname,
|
|
274104
275485
|
localUsername,
|
|
275486
|
+
hashAlgo
|
|
274105
275487
|
};
|
|
274106
275488
|
}
|
|
274107
275489
|
}
|
|
@@ -275275,12 +276657,15 @@ function handleKexInit(self, payload) {
|
|
|
275275
276657
|
// Key exchange method =======================================================
|
|
275276
276658
|
debug && debug(`Handshake: (local) KEX method: ${localKex}`);
|
|
275277
276659
|
debug && debug(`Handshake: (remote) KEX method: ${remote.kex}`);
|
|
276660
|
+
let remoteExtInfoEnabled;
|
|
275278
276661
|
if (self._server) {
|
|
275279
276662
|
serverList = localKex;
|
|
275280
276663
|
clientList = remote.kex;
|
|
276664
|
+
remoteExtInfoEnabled = (clientList.indexOf('ext-info-c') !== -1);
|
|
275281
276665
|
} else {
|
|
275282
276666
|
serverList = remote.kex;
|
|
275283
276667
|
clientList = localKex;
|
|
276668
|
+
remoteExtInfoEnabled = (serverList.indexOf('ext-info-s') !== -1);
|
|
275284
276669
|
}
|
|
275285
276670
|
// Check for agreeable key exchange algorithm
|
|
275286
276671
|
for (i = 0;
|
|
@@ -275532,6 +276917,7 @@ function handleKexInit(self, payload) {
|
|
|
275532
276917
|
}
|
|
275533
276918
|
|
|
275534
276919
|
self._kex = createKeyExchange(init, self, payload);
|
|
276920
|
+
self._kex.remoteExtInfoEnabled = remoteExtInfoEnabled;
|
|
275535
276921
|
self._kex.start();
|
|
275536
276922
|
}
|
|
275537
276923
|
|
|
@@ -275563,6 +276949,7 @@ const createKeyExchange = (() => {
|
|
|
275563
276949
|
|
|
275564
276950
|
this.sessionID = (protocol._kex ? protocol._kex.sessionID : undefined);
|
|
275565
276951
|
this.negotiated = negotiated;
|
|
276952
|
+
this.remoteExtInfoEnabled = false;
|
|
275566
276953
|
this._step = 1;
|
|
275567
276954
|
this._public = null;
|
|
275568
276955
|
this._dh = null;
|
|
@@ -275580,7 +276967,7 @@ const createKeyExchange = (() => {
|
|
|
275580
276967
|
this._dhData = undefined;
|
|
275581
276968
|
this._sig = undefined;
|
|
275582
276969
|
}
|
|
275583
|
-
finish() {
|
|
276970
|
+
finish(scOnly) {
|
|
275584
276971
|
if (this._finished)
|
|
275585
276972
|
return false;
|
|
275586
276973
|
this._finished = true;
|
|
@@ -275831,9 +277218,26 @@ const createKeyExchange = (() => {
|
|
|
275831
277218
|
this._protocol._packetRW.write.finalize(packet, true)
|
|
275832
277219
|
);
|
|
275833
277220
|
}
|
|
275834
|
-
trySendNEWKEYS(this);
|
|
275835
277221
|
|
|
275836
|
-
|
|
277222
|
+
if (isServer || !scOnly)
|
|
277223
|
+
trySendNEWKEYS(this);
|
|
277224
|
+
|
|
277225
|
+
let hsCipherConfig;
|
|
277226
|
+
let hsWrite;
|
|
277227
|
+
const completeHandshake = (partial) => {
|
|
277228
|
+
if (hsCipherConfig) {
|
|
277229
|
+
trySendNEWKEYS(this);
|
|
277230
|
+
hsCipherConfig.outbound.seqno = this._protocol._cipher.outSeqno;
|
|
277231
|
+
this._protocol._cipher.free();
|
|
277232
|
+
this._protocol._cipher = createCipher(hsCipherConfig);
|
|
277233
|
+
this._protocol._packetRW.write = hsWrite;
|
|
277234
|
+
hsCipherConfig = undefined;
|
|
277235
|
+
hsWrite = undefined;
|
|
277236
|
+
this._protocol._onHandshakeComplete(negotiated);
|
|
277237
|
+
|
|
277238
|
+
return false;
|
|
277239
|
+
}
|
|
277240
|
+
|
|
275837
277241
|
if (!this.sessionID)
|
|
275838
277242
|
this.sessionID = exchangeHash;
|
|
275839
277243
|
|
|
@@ -275916,9 +277320,8 @@ const createKeyExchange = (() => {
|
|
|
275916
277320
|
macKey: (isServer ? scMacKey : csMacKey),
|
|
275917
277321
|
},
|
|
275918
277322
|
};
|
|
275919
|
-
this._protocol.
|
|
275920
|
-
|
|
275921
|
-
this._protocol._cipher = createCipher(config);
|
|
277323
|
+
this._protocol._decipher.free();
|
|
277324
|
+
hsCipherConfig = config;
|
|
275922
277325
|
this._protocol._decipher = createDecipher(config);
|
|
275923
277326
|
|
|
275924
277327
|
const rw = {
|
|
@@ -275985,7 +277388,8 @@ const createKeyExchange = (() => {
|
|
|
275985
277388
|
}
|
|
275986
277389
|
this._protocol._packetRW.read.cleanup();
|
|
275987
277390
|
this._protocol._packetRW.write.cleanup();
|
|
275988
|
-
this._protocol._packetRW = rw;
|
|
277391
|
+
this._protocol._packetRW.read = rw.read;
|
|
277392
|
+
hsWrite = rw.write;
|
|
275989
277393
|
|
|
275990
277394
|
// Cleanup/reset various state
|
|
275991
277395
|
this._public = null;
|
|
@@ -275998,13 +277402,16 @@ const createKeyExchange = (() => {
|
|
|
275998
277402
|
this._dhData = undefined;
|
|
275999
277403
|
this._sig = undefined;
|
|
276000
277404
|
|
|
276001
|
-
|
|
276002
|
-
|
|
277405
|
+
if (!partial)
|
|
277406
|
+
return completeHandshake();
|
|
276003
277407
|
return false;
|
|
276004
277408
|
};
|
|
277409
|
+
|
|
277410
|
+
if (isServer || scOnly)
|
|
277411
|
+
this.finish = completeHandshake;
|
|
277412
|
+
|
|
276005
277413
|
if (!isServer)
|
|
276006
|
-
return completeHandshake();
|
|
276007
|
-
this.finish = completeHandshake;
|
|
277414
|
+
return completeHandshake(scOnly);
|
|
276008
277415
|
}
|
|
276009
277416
|
|
|
276010
277417
|
start() {
|
|
@@ -276265,12 +277672,8 @@ const createKeyExchange = (() => {
|
|
|
276265
277672
|
);
|
|
276266
277673
|
this._receivedNEWKEYS = true;
|
|
276267
277674
|
++this._step;
|
|
276268
|
-
if (this._protocol._server || this._hostVerified)
|
|
276269
|
-
return this.finish();
|
|
276270
277675
|
|
|
276271
|
-
|
|
276272
|
-
// for the next packet
|
|
276273
|
-
return false;
|
|
277676
|
+
return this.finish(!this._protocol._server && !this._hostVerified);
|
|
276274
277677
|
default:
|
|
276275
277678
|
return doFatalError(
|
|
276276
277679
|
this._protocol,
|
|
@@ -276431,7 +277834,7 @@ const createKeyExchange = (() => {
|
|
|
276431
277834
|
parse(payload) {
|
|
276432
277835
|
const type = payload[0];
|
|
276433
277836
|
switch (this._step) {
|
|
276434
|
-
case 1:
|
|
277837
|
+
case 1: {
|
|
276435
277838
|
if (this._protocol._server) {
|
|
276436
277839
|
if (type !== MESSAGE.KEXDH_GEX_REQUEST) {
|
|
276437
277840
|
return doFatalError(
|
|
@@ -276506,6 +277909,7 @@ const createKeyExchange = (() => {
|
|
|
276506
277909
|
|
|
276507
277910
|
++this._step;
|
|
276508
277911
|
break;
|
|
277912
|
+
}
|
|
276509
277913
|
case 2:
|
|
276510
277914
|
if (this._protocol._server) {
|
|
276511
277915
|
if (type !== MESSAGE.KEXDH_GEX_INIT) {
|
|
@@ -276862,7 +278266,23 @@ module.exports = {
|
|
|
276862
278266
|
KexInit,
|
|
276863
278267
|
kexinit,
|
|
276864
278268
|
onKEXPayload,
|
|
276865
|
-
|
|
278269
|
+
DEFAULT_KEXINIT_CLIENT: new KexInit({
|
|
278270
|
+
kex: DEFAULT_KEX.concat(['ext-info-c']),
|
|
278271
|
+
serverHostKey: DEFAULT_SERVER_HOST_KEY,
|
|
278272
|
+
cs: {
|
|
278273
|
+
cipher: DEFAULT_CIPHER,
|
|
278274
|
+
mac: DEFAULT_MAC,
|
|
278275
|
+
compress: DEFAULT_COMPRESSION,
|
|
278276
|
+
lang: [],
|
|
278277
|
+
},
|
|
278278
|
+
sc: {
|
|
278279
|
+
cipher: DEFAULT_CIPHER,
|
|
278280
|
+
mac: DEFAULT_MAC,
|
|
278281
|
+
compress: DEFAULT_COMPRESSION,
|
|
278282
|
+
lang: [],
|
|
278283
|
+
},
|
|
278284
|
+
}),
|
|
278285
|
+
DEFAULT_KEXINIT_SERVER: new KexInit({
|
|
276866
278286
|
kex: DEFAULT_KEX,
|
|
276867
278287
|
serverHostKey: DEFAULT_SERVER_HOST_KEY,
|
|
276868
278288
|
cs: {
|
|
@@ -277404,7 +278824,7 @@ OpenSSH_Private.prototype = BaseKey;
|
|
|
277404
278824
|
switch (kdfName) {
|
|
277405
278825
|
case 'none':
|
|
277406
278826
|
return new Error('Malformed OpenSSH private key');
|
|
277407
|
-
case 'bcrypt':
|
|
278827
|
+
case 'bcrypt': {
|
|
277408
278828
|
/*
|
|
277409
278829
|
string salt
|
|
277410
278830
|
uint32 rounds
|
|
@@ -277426,6 +278846,7 @@ OpenSSH_Private.prototype = BaseKey;
|
|
|
277426
278846
|
cipherKey = bufferSlice(gen, 0, encInfo.keyLen);
|
|
277427
278847
|
cipherIV = bufferSlice(gen, encInfo.keyLen, gen.length);
|
|
277428
278848
|
break;
|
|
278849
|
+
}
|
|
277429
278850
|
}
|
|
277430
278851
|
} else if (kdfName !== 'none') {
|
|
277431
278852
|
return new Error('Malformed OpenSSH private key');
|
|
@@ -277465,6 +278886,7 @@ OpenSSH_Private.prototype = BaseKey;
|
|
|
277465
278886
|
cipherKey,
|
|
277466
278887
|
cipherIV,
|
|
277467
278888
|
options);
|
|
278889
|
+
decipher.setAutoPadding(false);
|
|
277468
278890
|
if (encInfo.authLen > 0) {
|
|
277469
278891
|
if (data.length - data._pos < encInfo.authLen)
|
|
277470
278892
|
return new Error('Malformed OpenSSH private key');
|
|
@@ -277824,7 +279246,7 @@ OpenSSH_Old_Private.prototype = BaseKey;
|
|
|
277824
279246
|
}
|
|
277825
279247
|
algo = 'sha1';
|
|
277826
279248
|
break;
|
|
277827
|
-
case 'EC':
|
|
279249
|
+
case 'EC': {
|
|
277828
279250
|
let ecSSLName;
|
|
277829
279251
|
let ecPriv;
|
|
277830
279252
|
let ecOID;
|
|
@@ -277873,6 +279295,7 @@ OpenSSH_Old_Private.prototype = BaseKey;
|
|
|
277873
279295
|
pubPEM = genOpenSSLECDSAPub(ecOID, pubBlob);
|
|
277874
279296
|
pubSSH = genOpenSSHECDSAPub(ecOID, pubBlob);
|
|
277875
279297
|
break;
|
|
279298
|
+
}
|
|
277876
279299
|
}
|
|
277877
279300
|
|
|
277878
279301
|
return new OpenSSH_Old_Private(type, '', privPEM, pubPEM, pubSSH, algo,
|
|
@@ -277948,9 +279371,7 @@ PPK_Private.prototype = BaseKey;
|
|
|
277948
279371
|
if (cipherKey.length > encInfo.keyLen)
|
|
277949
279372
|
cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);
|
|
277950
279373
|
try {
|
|
277951
|
-
const decipher = createDecipheriv(encInfo.sslName,
|
|
277952
|
-
cipherKey,
|
|
277953
|
-
PPK_IV);
|
|
279374
|
+
const decipher = createDecipheriv(encInfo.sslName, cipherKey, PPK_IV);
|
|
277954
279375
|
decipher.setAutoPadding(false);
|
|
277955
279376
|
privBlob = combineBuffers(decipher.update(privBlob),
|
|
277956
279377
|
decipher.final());
|
|
@@ -279269,6 +280690,7 @@ class PKAuthContext extends AuthContext {
|
|
|
279269
280690
|
super(protocol, username, service, method, cb);
|
|
279270
280691
|
|
|
279271
280692
|
this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };
|
|
280693
|
+
this.hashAlgo = pkInfo.hashAlgo;
|
|
279272
280694
|
this.signature = pkInfo.signature;
|
|
279273
280695
|
this.blob = pkInfo.blob;
|
|
279274
280696
|
}
|
|
@@ -279288,6 +280710,7 @@ class HostbasedAuthContext extends AuthContext {
|
|
|
279288
280710
|
super(protocol, username, service, method, cb);
|
|
279289
280711
|
|
|
279290
280712
|
this.key = { algo: pkInfo.keyAlgo, data: pkInfo.key };
|
|
280713
|
+
this.hashAlgo = pkInfo.hashAlgo;
|
|
279291
280714
|
this.signature = pkInfo.signature;
|
|
279292
280715
|
this.blob = pkInfo.blob;
|
|
279293
280716
|
this.localHostname = pkInfo.localHostname;
|
|
@@ -280449,6 +281872,13 @@ class Client extends EventEmitter {
|
|
|
280449
281872
|
this.once('rekey', cb);
|
|
280450
281873
|
}
|
|
280451
281874
|
}
|
|
281875
|
+
|
|
281876
|
+
setNoDelay(noDelay) {
|
|
281877
|
+
if (this._sock && typeof this._sock.setNoDelay === 'function')
|
|
281878
|
+
this._sock.setNoDelay(noDelay);
|
|
281879
|
+
|
|
281880
|
+
return this;
|
|
281881
|
+
}
|
|
280452
281882
|
}
|
|
280453
281883
|
|
|
280454
281884
|
|
|
@@ -297353,6 +298783,1375 @@ exports.quote = quote;
|
|
|
297353
298783
|
exports.quoteAll = quoteAll;
|
|
297354
298784
|
|
|
297355
298785
|
|
|
298786
|
+
/***/ }),
|
|
298787
|
+
|
|
298788
|
+
/***/ 66710:
|
|
298789
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
298790
|
+
|
|
298791
|
+
"use strict";
|
|
298792
|
+
|
|
298793
|
+
|
|
298794
|
+
var os = __webpack_require__(22037);
|
|
298795
|
+
var process = __webpack_require__(77282);
|
|
298796
|
+
var fs = __webpack_require__(57147);
|
|
298797
|
+
var path = __webpack_require__(71017);
|
|
298798
|
+
var which = __webpack_require__(81918);
|
|
298799
|
+
var util = __webpack_require__(73837);
|
|
298800
|
+
|
|
298801
|
+
function _interopNamespaceDefault(e) {
|
|
298802
|
+
var n = Object.create(null);
|
|
298803
|
+
if (e) {
|
|
298804
|
+
Object.keys(e).forEach(function (k) {
|
|
298805
|
+
if (k !== 'default') {
|
|
298806
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
298807
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
298808
|
+
enumerable: true,
|
|
298809
|
+
get: function () { return e[k]; }
|
|
298810
|
+
});
|
|
298811
|
+
}
|
|
298812
|
+
});
|
|
298813
|
+
}
|
|
298814
|
+
n.default = e;
|
|
298815
|
+
return Object.freeze(n);
|
|
298816
|
+
}
|
|
298817
|
+
|
|
298818
|
+
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
298819
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
298820
|
+
|
|
298821
|
+
/**
|
|
298822
|
+
* @overview Provides functionality related to working with executables.
|
|
298823
|
+
* @license MPL-2.0
|
|
298824
|
+
*/
|
|
298825
|
+
|
|
298826
|
+
/**
|
|
298827
|
+
* Resolves the location of an executable given an arbitrary valid string
|
|
298828
|
+
* representation of that executable.
|
|
298829
|
+
*
|
|
298830
|
+
* To obtain the location of the executable this function (if necessary):
|
|
298831
|
+
* - Expands the provided string to a absolute path.
|
|
298832
|
+
* - Follows symbolic links.
|
|
298833
|
+
*
|
|
298834
|
+
* @param {object} args The arguments for this function.
|
|
298835
|
+
* @param {string} args.executable A string representation of the executable.
|
|
298836
|
+
* @param {object} deps The dependencies for this function.
|
|
298837
|
+
* @param {Function} deps.exists A function to check if a file exists.
|
|
298838
|
+
* @param {Function} deps.readlink A function to resolve (sym)links.
|
|
298839
|
+
* @param {Function} deps.which A function to perform a `which(1)`-like lookup.
|
|
298840
|
+
* @returns {string} The full path to the binary of the executable.
|
|
298841
|
+
* @throws {Error} If the `deps` aren't provided.
|
|
298842
|
+
*/
|
|
298843
|
+
function resolveExecutable({ executable }, { exists, readlink, which }) {
|
|
298844
|
+
if (readlink === undefined || which === undefined) {
|
|
298845
|
+
throw new Error();
|
|
298846
|
+
}
|
|
298847
|
+
|
|
298848
|
+
try {
|
|
298849
|
+
executable = which(executable);
|
|
298850
|
+
} catch (_) {
|
|
298851
|
+
// For backwards compatibility return the executable even if its location
|
|
298852
|
+
// cannot be obtained
|
|
298853
|
+
return executable;
|
|
298854
|
+
}
|
|
298855
|
+
|
|
298856
|
+
if (!exists(executable)) {
|
|
298857
|
+
// For backwards compatibility return the executable even if there exists no
|
|
298858
|
+
// file at the specified path
|
|
298859
|
+
return executable;
|
|
298860
|
+
}
|
|
298861
|
+
|
|
298862
|
+
try {
|
|
298863
|
+
executable = readlink(executable);
|
|
298864
|
+
} catch (_) {
|
|
298865
|
+
// An error will be thrown if the executable is not a (sym)link, this is not
|
|
298866
|
+
// a problem so the error is ignored
|
|
298867
|
+
}
|
|
298868
|
+
|
|
298869
|
+
return executable;
|
|
298870
|
+
}
|
|
298871
|
+
|
|
298872
|
+
/**
|
|
298873
|
+
* @overview Provides reflection functionality.
|
|
298874
|
+
* @license MPL-2.0
|
|
298875
|
+
*/
|
|
298876
|
+
|
|
298877
|
+
/**
|
|
298878
|
+
* The error message for incorrect parameter types.
|
|
298879
|
+
*
|
|
298880
|
+
* @constant
|
|
298881
|
+
* @type {string}
|
|
298882
|
+
*/
|
|
298883
|
+
const typeError =
|
|
298884
|
+
"Shescape requires strings or values that can be converted into a string using .toString()";
|
|
298885
|
+
|
|
298886
|
+
/**
|
|
298887
|
+
* The `typeof` value of functions.
|
|
298888
|
+
*
|
|
298889
|
+
* @constant
|
|
298890
|
+
* @type {string}
|
|
298891
|
+
*/
|
|
298892
|
+
const typeofFunction = "function";
|
|
298893
|
+
|
|
298894
|
+
/**
|
|
298895
|
+
* The `typeof` value of strings.
|
|
298896
|
+
*
|
|
298897
|
+
* @constant
|
|
298898
|
+
* @type {string}
|
|
298899
|
+
*/
|
|
298900
|
+
const typeofString = "string";
|
|
298901
|
+
|
|
298902
|
+
/**
|
|
298903
|
+
* Checks if a value can be converted into a string and converts it if possible.
|
|
298904
|
+
*
|
|
298905
|
+
* @param {any} value The value of interest.
|
|
298906
|
+
* @returns {string|null} The `.toString()` if it's a string, otherwise `null`.
|
|
298907
|
+
*/
|
|
298908
|
+
function maybeToString(value) {
|
|
298909
|
+
if (value === undefined || value === null) {
|
|
298910
|
+
return null;
|
|
298911
|
+
}
|
|
298912
|
+
|
|
298913
|
+
if (typeof value.toString !== typeofFunction) {
|
|
298914
|
+
return null;
|
|
298915
|
+
}
|
|
298916
|
+
|
|
298917
|
+
const maybeStr = value.toString();
|
|
298918
|
+
if (isString(maybeStr)) {
|
|
298919
|
+
return maybeStr;
|
|
298920
|
+
} else {
|
|
298921
|
+
return null;
|
|
298922
|
+
}
|
|
298923
|
+
}
|
|
298924
|
+
|
|
298925
|
+
/**
|
|
298926
|
+
* Convert a value into a string if that is possible.
|
|
298927
|
+
*
|
|
298928
|
+
* @param {any} value The value to convert into a string.
|
|
298929
|
+
* @returns {string} The `value` as a string.
|
|
298930
|
+
* @throws {TypeError} The `value` is not stringable.
|
|
298931
|
+
*/
|
|
298932
|
+
function checkedToString(value) {
|
|
298933
|
+
if (isString(value)) {
|
|
298934
|
+
return value;
|
|
298935
|
+
}
|
|
298936
|
+
|
|
298937
|
+
const maybeStr = maybeToString(value);
|
|
298938
|
+
if (maybeStr === null) {
|
|
298939
|
+
throw new TypeError(typeError);
|
|
298940
|
+
}
|
|
298941
|
+
|
|
298942
|
+
return maybeStr;
|
|
298943
|
+
}
|
|
298944
|
+
|
|
298945
|
+
/**
|
|
298946
|
+
* Checks if a value is a string.
|
|
298947
|
+
*
|
|
298948
|
+
* @param {any} value The value of interest.
|
|
298949
|
+
* @returns {boolean} `true` if `value` is a string, `false` otherwise.
|
|
298950
|
+
*/
|
|
298951
|
+
function isString(value) {
|
|
298952
|
+
return typeof value === typeofString;
|
|
298953
|
+
}
|
|
298954
|
+
|
|
298955
|
+
/**
|
|
298956
|
+
* Converts the provided value into an array if it is not already an array and
|
|
298957
|
+
* returns the array.
|
|
298958
|
+
*
|
|
298959
|
+
* @param {Array | any} value The value to convert to an array if necessary.
|
|
298960
|
+
* @returns {Array} An array containing `value` or `value` itself.
|
|
298961
|
+
*/
|
|
298962
|
+
function toArrayIfNecessary(value) {
|
|
298963
|
+
return Array.isArray(value) ? value : [value];
|
|
298964
|
+
}
|
|
298965
|
+
|
|
298966
|
+
/**
|
|
298967
|
+
* @overview Provides functionality for parsing shescape options.
|
|
298968
|
+
* @license MPL-2.0
|
|
298969
|
+
*/
|
|
298970
|
+
|
|
298971
|
+
|
|
298972
|
+
/**
|
|
298973
|
+
* Parses options provided to shescape.
|
|
298974
|
+
*
|
|
298975
|
+
* @param {object} args The arguments for this function.
|
|
298976
|
+
* @param {object} args.options The options for escaping.
|
|
298977
|
+
* @param {boolean} [args.options.flagProtection] Is flag protection enabled.
|
|
298978
|
+
* @param {boolean} [args.options.interpolation] Is interpolation enabled.
|
|
298979
|
+
* @param {boolean | string} [args.options.shell] The shell to escape for.
|
|
298980
|
+
* @param {object} args.process The `process` values.
|
|
298981
|
+
* @param {object} args.process.env The environment variables.
|
|
298982
|
+
* @param {object} deps The dependencies for this function.
|
|
298983
|
+
* @param {Function} deps.getDefaultShell Function to get the default shell.
|
|
298984
|
+
* @param {Function} deps.getShellName Function to get the name of a shell.
|
|
298985
|
+
* @returns {object} The parsed arguments.
|
|
298986
|
+
*/
|
|
298987
|
+
function parseOptions(
|
|
298988
|
+
{ options: { flagProtection, interpolation, shell }, process: { env } },
|
|
298989
|
+
{ getDefaultShell, getShellName },
|
|
298990
|
+
) {
|
|
298991
|
+
flagProtection = flagProtection ? true : false;
|
|
298992
|
+
interpolation = interpolation ? true : false;
|
|
298993
|
+
shell = isString(shell) ? shell : getDefaultShell({ env });
|
|
298994
|
+
|
|
298995
|
+
const shellName = getShellName({ shell }, { resolveExecutable });
|
|
298996
|
+
return { flagProtection, interpolation, shellName };
|
|
298997
|
+
}
|
|
298998
|
+
|
|
298999
|
+
/**
|
|
299000
|
+
* @overview Provides functionality for the Bourne-again shell (Bash).
|
|
299001
|
+
* @license MPL-2.0
|
|
299002
|
+
*/
|
|
299003
|
+
|
|
299004
|
+
/**
|
|
299005
|
+
* Escape an argument for use in Bash when interpolation is active.
|
|
299006
|
+
*
|
|
299007
|
+
* @param {string} arg The argument to escape.
|
|
299008
|
+
* @returns {string} The escaped argument.
|
|
299009
|
+
*/
|
|
299010
|
+
function escapeArgForInterpolation$5(arg) {
|
|
299011
|
+
return arg
|
|
299012
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299013
|
+
.replace(/\r(?!\n)/gu, "")
|
|
299014
|
+
.replace(/\\/gu, "\\\\")
|
|
299015
|
+
.replace(/\r?\n/gu, " ")
|
|
299016
|
+
.replace(/(?<=^|\s)([#~])/gu, "\\$1")
|
|
299017
|
+
.replace(/(["$&'()*;<>?`{|])/gu, "\\$1")
|
|
299018
|
+
.replace(/(?<=[:=])(~)(?=[\s+\-/0:=]|$)/gu, "\\$1")
|
|
299019
|
+
.replace(/([\t ])/gu, "\\$1");
|
|
299020
|
+
}
|
|
299021
|
+
|
|
299022
|
+
/**
|
|
299023
|
+
* Escape an argument for use in Bash when the argument is not being quoted (but
|
|
299024
|
+
* interpolation is inactive).
|
|
299025
|
+
*
|
|
299026
|
+
* @param {string} arg The argument to escape.
|
|
299027
|
+
* @returns {string} The escaped argument.
|
|
299028
|
+
*/
|
|
299029
|
+
function escapeArgForNoInterpolation$5(arg) {
|
|
299030
|
+
return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
|
|
299031
|
+
}
|
|
299032
|
+
|
|
299033
|
+
/**
|
|
299034
|
+
* Returns a function to escape arguments for use in Bash for the given use
|
|
299035
|
+
* case.
|
|
299036
|
+
*
|
|
299037
|
+
* @param {object} options The options for escaping arguments.
|
|
299038
|
+
* @param {boolean} options.interpolation Is interpolation enabled.
|
|
299039
|
+
* @returns {Function} A function to escape arguments.
|
|
299040
|
+
*/
|
|
299041
|
+
function getEscapeFunction$7(options) {
|
|
299042
|
+
if (options.interpolation) {
|
|
299043
|
+
return escapeArgForInterpolation$5;
|
|
299044
|
+
} else {
|
|
299045
|
+
return escapeArgForNoInterpolation$5;
|
|
299046
|
+
}
|
|
299047
|
+
}
|
|
299048
|
+
|
|
299049
|
+
/**
|
|
299050
|
+
* Escape an argument for use in Bash when the argument is being quoted.
|
|
299051
|
+
*
|
|
299052
|
+
* @param {string} arg The argument to escape.
|
|
299053
|
+
* @returns {string} The escaped argument.
|
|
299054
|
+
*/
|
|
299055
|
+
function escapeArgForQuoted$5(arg) {
|
|
299056
|
+
return arg
|
|
299057
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299058
|
+
.replace(/\r(?!\n)/gu, "")
|
|
299059
|
+
.replace(/'/gu, "'\\''");
|
|
299060
|
+
}
|
|
299061
|
+
|
|
299062
|
+
/**
|
|
299063
|
+
* Quotes an argument for use in Bash.
|
|
299064
|
+
*
|
|
299065
|
+
* @param {string} arg The argument to quote.
|
|
299066
|
+
* @returns {string} The quoted argument.
|
|
299067
|
+
*/
|
|
299068
|
+
function quoteArg$5(arg) {
|
|
299069
|
+
return `'${arg}'`;
|
|
299070
|
+
}
|
|
299071
|
+
|
|
299072
|
+
/**
|
|
299073
|
+
* Returns a pair of functions to escape and quote arguments for use in Bash.
|
|
299074
|
+
*
|
|
299075
|
+
* @returns {Function[]} A function pair to escape & quote arguments.
|
|
299076
|
+
*/
|
|
299077
|
+
function getQuoteFunction$7() {
|
|
299078
|
+
return [escapeArgForQuoted$5, quoteArg$5];
|
|
299079
|
+
}
|
|
299080
|
+
|
|
299081
|
+
/**
|
|
299082
|
+
* Remove any prefix from the provided argument that might be interpreted as a
|
|
299083
|
+
* flag on Unix systems for Bash.
|
|
299084
|
+
*
|
|
299085
|
+
* @param {string} arg The argument to update.
|
|
299086
|
+
* @returns {string} The updated argument.
|
|
299087
|
+
*/
|
|
299088
|
+
function stripFlagPrefix$5(arg) {
|
|
299089
|
+
return arg.replace(/^-+/gu, "");
|
|
299090
|
+
}
|
|
299091
|
+
|
|
299092
|
+
/**
|
|
299093
|
+
* Returns a function to protect against flag injection for Bash.
|
|
299094
|
+
*
|
|
299095
|
+
* @returns {Function} A function to protect against flag injection.
|
|
299096
|
+
*/
|
|
299097
|
+
function getFlagProtectionFunction$7() {
|
|
299098
|
+
return stripFlagPrefix$5;
|
|
299099
|
+
}
|
|
299100
|
+
|
|
299101
|
+
/**
|
|
299102
|
+
* @overview Provides functionality for the C shell (csh).
|
|
299103
|
+
* @license MPL-2.0
|
|
299104
|
+
*/
|
|
299105
|
+
|
|
299106
|
+
|
|
299107
|
+
/**
|
|
299108
|
+
* Escape an argument for use in csh when interpolation is active.
|
|
299109
|
+
*
|
|
299110
|
+
* @param {string} arg The argument to escape.
|
|
299111
|
+
* @returns {string} The escaped argument.
|
|
299112
|
+
*/
|
|
299113
|
+
function escapeArgForInterpolation$4(arg) {
|
|
299114
|
+
const textEncoder = new util.TextEncoder();
|
|
299115
|
+
return arg
|
|
299116
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299117
|
+
.replace(/\r?\n|\r/gu, " ")
|
|
299118
|
+
.replace(/\\/gu, "\\\\")
|
|
299119
|
+
.replace(/(?<=^|\s)(~)/gu, "\\$1")
|
|
299120
|
+
.replace(/(["#$&'()*;<>?[`{|])/gu, "\\$1")
|
|
299121
|
+
.replace(/([\t ])/gu, "\\$1")
|
|
299122
|
+
.split("")
|
|
299123
|
+
.map(
|
|
299124
|
+
// Due to a bug in C shell version 20110502-7, when a character whose
|
|
299125
|
+
// utf-8 encoding includes the bytes 0xA0 (160 in decimal) appears in
|
|
299126
|
+
// an argument after an escaped character, it will hang and endlessly
|
|
299127
|
+
// consume memory unless the character is escaped with quotes.
|
|
299128
|
+
// ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=995013
|
|
299129
|
+
(char) => (textEncoder.encode(char).includes(160) ? `'${char}'` : char),
|
|
299130
|
+
)
|
|
299131
|
+
.join("")
|
|
299132
|
+
.replace(/!(?!$)/gu, "\\!");
|
|
299133
|
+
}
|
|
299134
|
+
|
|
299135
|
+
/**
|
|
299136
|
+
* Escape an argument for use in csh when the argument is not being quoted (but
|
|
299137
|
+
* interpolation is inactive).
|
|
299138
|
+
*
|
|
299139
|
+
* @param {string} arg The argument to escape.
|
|
299140
|
+
* @returns {string} The escaped argument.
|
|
299141
|
+
*/
|
|
299142
|
+
function escapeArgForNoInterpolation$4(arg) {
|
|
299143
|
+
return arg
|
|
299144
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299145
|
+
.replace(/\r?\n|\r/gu, " ")
|
|
299146
|
+
.replace(/\\!$/gu, "\\\\!")
|
|
299147
|
+
.replace(/!(?!$)/gu, "\\!");
|
|
299148
|
+
}
|
|
299149
|
+
|
|
299150
|
+
/**
|
|
299151
|
+
* Returns a function to escape arguments for use in csh for the given use case.
|
|
299152
|
+
*
|
|
299153
|
+
* @param {object} options The options for escaping arguments.
|
|
299154
|
+
* @param {boolean} options.interpolation Is interpolation enabled.
|
|
299155
|
+
* @returns {Function} A function to escape arguments.
|
|
299156
|
+
*/
|
|
299157
|
+
function getEscapeFunction$6(options) {
|
|
299158
|
+
if (options.interpolation) {
|
|
299159
|
+
return escapeArgForInterpolation$4;
|
|
299160
|
+
} else {
|
|
299161
|
+
return escapeArgForNoInterpolation$4;
|
|
299162
|
+
}
|
|
299163
|
+
}
|
|
299164
|
+
|
|
299165
|
+
/**
|
|
299166
|
+
* Escape an argument for use in csh when the argument is being quoted.
|
|
299167
|
+
*
|
|
299168
|
+
* @param {string} arg The argument to escape.
|
|
299169
|
+
* @returns {string} The escaped argument.
|
|
299170
|
+
*/
|
|
299171
|
+
function escapeArgForQuoted$4(arg) {
|
|
299172
|
+
return arg
|
|
299173
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299174
|
+
.replace(/\r?\n|\r/gu, " ")
|
|
299175
|
+
.replace(/\\!$/gu, "\\\\!")
|
|
299176
|
+
.replace(/'/gu, "'\\''")
|
|
299177
|
+
.replace(/!(?!$)/gu, "\\!");
|
|
299178
|
+
}
|
|
299179
|
+
|
|
299180
|
+
/**
|
|
299181
|
+
* Quotes an argument for use in csh.
|
|
299182
|
+
*
|
|
299183
|
+
* @param {string} arg The argument to quote.
|
|
299184
|
+
* @returns {string} The quoted argument.
|
|
299185
|
+
*/
|
|
299186
|
+
function quoteArg$4(arg) {
|
|
299187
|
+
return `'${arg}'`;
|
|
299188
|
+
}
|
|
299189
|
+
|
|
299190
|
+
/**
|
|
299191
|
+
* Returns a pair of functions to escape and quote arguments for use in csh.
|
|
299192
|
+
*
|
|
299193
|
+
* @returns {Function[]} A function pair to escape & quote arguments.
|
|
299194
|
+
*/
|
|
299195
|
+
function getQuoteFunction$6() {
|
|
299196
|
+
return [escapeArgForQuoted$4, quoteArg$4];
|
|
299197
|
+
}
|
|
299198
|
+
|
|
299199
|
+
/**
|
|
299200
|
+
* Remove any prefix from the provided argument that might be interpreted as a
|
|
299201
|
+
* flag on Unix systems for csh.
|
|
299202
|
+
*
|
|
299203
|
+
* @param {string} arg The argument to update.
|
|
299204
|
+
* @returns {string} The updated argument.
|
|
299205
|
+
*/
|
|
299206
|
+
function stripFlagPrefix$4(arg) {
|
|
299207
|
+
return arg.replace(/^-+/gu, "");
|
|
299208
|
+
}
|
|
299209
|
+
|
|
299210
|
+
/**
|
|
299211
|
+
* Returns a function to protect against flag injection for csh.
|
|
299212
|
+
*
|
|
299213
|
+
* @returns {Function} A function to protect against flag injection.
|
|
299214
|
+
*/
|
|
299215
|
+
function getFlagProtectionFunction$6() {
|
|
299216
|
+
return stripFlagPrefix$4;
|
|
299217
|
+
}
|
|
299218
|
+
|
|
299219
|
+
/**
|
|
299220
|
+
* @overview Provides functionality for the Debian Almquist shell (Dash).
|
|
299221
|
+
* @license MPL-2.0
|
|
299222
|
+
*/
|
|
299223
|
+
|
|
299224
|
+
/**
|
|
299225
|
+
* Escape an argument for use in Dash when interpolation is active.
|
|
299226
|
+
*
|
|
299227
|
+
* @param {string} arg The argument to escape.
|
|
299228
|
+
* @returns {string} The escaped argument.
|
|
299229
|
+
*/
|
|
299230
|
+
function escapeArgForInterpolation$3(arg) {
|
|
299231
|
+
return arg
|
|
299232
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299233
|
+
.replace(/\r(?!\n)/gu, "")
|
|
299234
|
+
.replace(/\\/gu, "\\\\")
|
|
299235
|
+
.replace(/\r?\n/gu, " ")
|
|
299236
|
+
.replace(/(?<=^|\s)([#~])/gu, "\\$1")
|
|
299237
|
+
.replace(/(["$&'()*;<>?`|])/gu, "\\$1")
|
|
299238
|
+
.replace(/([\t\n ])/gu, "\\$1");
|
|
299239
|
+
}
|
|
299240
|
+
|
|
299241
|
+
/**
|
|
299242
|
+
* Escape an argument for use in Dash when the argument is not being quoted (but
|
|
299243
|
+
* interpolation is inactive).
|
|
299244
|
+
*
|
|
299245
|
+
* @param {string} arg The argument to escape.
|
|
299246
|
+
* @returns {string} The escaped argument.
|
|
299247
|
+
*/
|
|
299248
|
+
function escapeArgForNoInterpolation$3(arg) {
|
|
299249
|
+
return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
|
|
299250
|
+
}
|
|
299251
|
+
|
|
299252
|
+
/**
|
|
299253
|
+
* Returns a function to escape arguments for use in Dash for the given use
|
|
299254
|
+
* case.
|
|
299255
|
+
*
|
|
299256
|
+
* @param {object} options The options for escaping arguments.
|
|
299257
|
+
* @param {boolean} options.interpolation Is interpolation enabled.
|
|
299258
|
+
* @returns {Function} A function to escape arguments.
|
|
299259
|
+
*/
|
|
299260
|
+
function getEscapeFunction$5(options) {
|
|
299261
|
+
if (options.interpolation) {
|
|
299262
|
+
return escapeArgForInterpolation$3;
|
|
299263
|
+
} else {
|
|
299264
|
+
return escapeArgForNoInterpolation$3;
|
|
299265
|
+
}
|
|
299266
|
+
}
|
|
299267
|
+
|
|
299268
|
+
/**
|
|
299269
|
+
* Escape an argument for use in Dash when the argument is being quoted.
|
|
299270
|
+
*
|
|
299271
|
+
* @param {string} arg The argument to escape.
|
|
299272
|
+
* @returns {string} The escaped argument.
|
|
299273
|
+
*/
|
|
299274
|
+
function escapeArgForQuoted$3(arg) {
|
|
299275
|
+
return arg
|
|
299276
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299277
|
+
.replace(/\r(?!\n)/gu, "")
|
|
299278
|
+
.replace(/'/gu, "'\\''");
|
|
299279
|
+
}
|
|
299280
|
+
|
|
299281
|
+
/**
|
|
299282
|
+
* Quotes an argument for use in Dash.
|
|
299283
|
+
*
|
|
299284
|
+
* @param {string} arg The argument to quote.
|
|
299285
|
+
* @returns {string} The quoted argument.
|
|
299286
|
+
*/
|
|
299287
|
+
function quoteArg$3(arg) {
|
|
299288
|
+
return `'${arg}'`;
|
|
299289
|
+
}
|
|
299290
|
+
|
|
299291
|
+
/**
|
|
299292
|
+
* Returns a pair of functions to escape and quote arguments for use in Dash.
|
|
299293
|
+
*
|
|
299294
|
+
* @returns {Function[]} A function pair to escape & quote arguments.
|
|
299295
|
+
*/
|
|
299296
|
+
function getQuoteFunction$5() {
|
|
299297
|
+
return [escapeArgForQuoted$3, quoteArg$3];
|
|
299298
|
+
}
|
|
299299
|
+
|
|
299300
|
+
/**
|
|
299301
|
+
* Remove any prefix from the provided argument that might be interpreted as a
|
|
299302
|
+
* flag on Unix systems for Dash.
|
|
299303
|
+
*
|
|
299304
|
+
* @param {string} arg The argument to update.
|
|
299305
|
+
* @returns {string} The updated argument.
|
|
299306
|
+
*/
|
|
299307
|
+
function stripFlagPrefix$3(arg) {
|
|
299308
|
+
return arg.replace(/^-+/gu, "");
|
|
299309
|
+
}
|
|
299310
|
+
|
|
299311
|
+
/**
|
|
299312
|
+
* Returns a function to protect against flag injection for Dash.
|
|
299313
|
+
*
|
|
299314
|
+
* @returns {Function} A function to protect against flag injection.
|
|
299315
|
+
*/
|
|
299316
|
+
function getFlagProtectionFunction$5() {
|
|
299317
|
+
return stripFlagPrefix$3;
|
|
299318
|
+
}
|
|
299319
|
+
|
|
299320
|
+
/**
|
|
299321
|
+
* @overview Provides functionality for the Z shell (Zsh).
|
|
299322
|
+
* @license MPL-2.0
|
|
299323
|
+
*/
|
|
299324
|
+
|
|
299325
|
+
/**
|
|
299326
|
+
* Escape an argument for use in Zsh when interpolation is active.
|
|
299327
|
+
*
|
|
299328
|
+
* @param {string} arg The argument to escape.
|
|
299329
|
+
* @returns {string} The escaped argument.
|
|
299330
|
+
*/
|
|
299331
|
+
function escapeArgForInterpolation$2(arg) {
|
|
299332
|
+
return arg
|
|
299333
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299334
|
+
.replace(/\r(?!\n)/gu, "")
|
|
299335
|
+
.replace(/\\/gu, "\\\\")
|
|
299336
|
+
.replace(/\r?\n/gu, " ")
|
|
299337
|
+
.replace(/(?<=^|\s)([#=~])/gu, "\\$1")
|
|
299338
|
+
.replace(/(["$&'()*;<>?[\]`{|}])/gu, "\\$1")
|
|
299339
|
+
.replace(/([\t ])/gu, "\\$1");
|
|
299340
|
+
}
|
|
299341
|
+
|
|
299342
|
+
/**
|
|
299343
|
+
* Escape an argument for use in Zsh when the argument is not being quoted (but
|
|
299344
|
+
* interpolation is inactive).
|
|
299345
|
+
*
|
|
299346
|
+
* @param {string} arg The argument to escape.
|
|
299347
|
+
* @returns {string} The escaped argument.
|
|
299348
|
+
*/
|
|
299349
|
+
function escapeArgForNoInterpolation$2(arg) {
|
|
299350
|
+
return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
|
|
299351
|
+
}
|
|
299352
|
+
|
|
299353
|
+
/**
|
|
299354
|
+
* Returns a function to escape arguments for use in Zsh for the given use case.
|
|
299355
|
+
*
|
|
299356
|
+
* @param {object} options The options for escaping arguments.
|
|
299357
|
+
* @param {boolean} options.interpolation Is interpolation enabled.
|
|
299358
|
+
* @returns {Function} A function to escape arguments.
|
|
299359
|
+
*/
|
|
299360
|
+
function getEscapeFunction$4(options) {
|
|
299361
|
+
if (options.interpolation) {
|
|
299362
|
+
return escapeArgForInterpolation$2;
|
|
299363
|
+
} else {
|
|
299364
|
+
return escapeArgForNoInterpolation$2;
|
|
299365
|
+
}
|
|
299366
|
+
}
|
|
299367
|
+
|
|
299368
|
+
/**
|
|
299369
|
+
* Escape an argument for use in Zsh when the argument is being quoted.
|
|
299370
|
+
*
|
|
299371
|
+
* @param {string} arg The argument to escape.
|
|
299372
|
+
* @returns {string} The escaped argument.
|
|
299373
|
+
*/
|
|
299374
|
+
function escapeArgForQuoted$2(arg) {
|
|
299375
|
+
return arg
|
|
299376
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299377
|
+
.replace(/\r(?!\n)/gu, "")
|
|
299378
|
+
.replace(/'/gu, "'\\''");
|
|
299379
|
+
}
|
|
299380
|
+
|
|
299381
|
+
/**
|
|
299382
|
+
* Quotes an argument for use in Zsh.
|
|
299383
|
+
*
|
|
299384
|
+
* @param {string} arg The argument to quote.
|
|
299385
|
+
* @returns {string} The quoted argument.
|
|
299386
|
+
*/
|
|
299387
|
+
function quoteArg$2(arg) {
|
|
299388
|
+
return `'${arg}'`;
|
|
299389
|
+
}
|
|
299390
|
+
|
|
299391
|
+
/**
|
|
299392
|
+
* Returns a pair of functions to escape and quote arguments for use in Zsh.
|
|
299393
|
+
*
|
|
299394
|
+
* @returns {Function[]} A function pair to escape & quote arguments.
|
|
299395
|
+
*/
|
|
299396
|
+
function getQuoteFunction$4() {
|
|
299397
|
+
return [escapeArgForQuoted$2, quoteArg$2];
|
|
299398
|
+
}
|
|
299399
|
+
|
|
299400
|
+
/**
|
|
299401
|
+
* Remove any prefix from the provided argument that might be interpreted as a
|
|
299402
|
+
* flag on Unix systems for Zsh.
|
|
299403
|
+
*
|
|
299404
|
+
* @param {string} arg The argument to update.
|
|
299405
|
+
* @returns {string} The updated argument.
|
|
299406
|
+
*/
|
|
299407
|
+
function stripFlagPrefix$2(arg) {
|
|
299408
|
+
return arg.replace(/^-+/gu, "");
|
|
299409
|
+
}
|
|
299410
|
+
|
|
299411
|
+
/**
|
|
299412
|
+
* Returns a function to protect against flag injection for Zsh.
|
|
299413
|
+
*
|
|
299414
|
+
* @returns {Function} A function to protect against flag injection.
|
|
299415
|
+
*/
|
|
299416
|
+
function getFlagProtectionFunction$4() {
|
|
299417
|
+
return stripFlagPrefix$2;
|
|
299418
|
+
}
|
|
299419
|
+
|
|
299420
|
+
/**
|
|
299421
|
+
* @overview Provides functionality for Unix systems.
|
|
299422
|
+
* @license MPL-2.0
|
|
299423
|
+
*/
|
|
299424
|
+
|
|
299425
|
+
|
|
299426
|
+
/**
|
|
299427
|
+
* The name of the Bourne-again shell (Bash) binary.
|
|
299428
|
+
*
|
|
299429
|
+
* @constant
|
|
299430
|
+
* @type {string}
|
|
299431
|
+
*/
|
|
299432
|
+
const binBash = "bash";
|
|
299433
|
+
|
|
299434
|
+
/**
|
|
299435
|
+
* The name of the C shell (csh) binary.
|
|
299436
|
+
*
|
|
299437
|
+
* @constant
|
|
299438
|
+
* @type {string}
|
|
299439
|
+
*/
|
|
299440
|
+
const binCsh = "csh";
|
|
299441
|
+
|
|
299442
|
+
/**
|
|
299443
|
+
* The name of the Debian Almquist shell (Dash) binary.
|
|
299444
|
+
*
|
|
299445
|
+
* @constant
|
|
299446
|
+
* @type {string}
|
|
299447
|
+
*/
|
|
299448
|
+
const binDash = "dash";
|
|
299449
|
+
|
|
299450
|
+
/**
|
|
299451
|
+
* The name of the Z shell (Zsh) binary.
|
|
299452
|
+
*
|
|
299453
|
+
* @constant
|
|
299454
|
+
* @type {string}
|
|
299455
|
+
*/
|
|
299456
|
+
const binZsh = "zsh";
|
|
299457
|
+
|
|
299458
|
+
/**
|
|
299459
|
+
* Returns the default shell for Unix systems.
|
|
299460
|
+
*
|
|
299461
|
+
* For more information, see `options.shell` in:
|
|
299462
|
+
* https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback.
|
|
299463
|
+
*
|
|
299464
|
+
* @returns {string} The default shell.
|
|
299465
|
+
*/
|
|
299466
|
+
function getDefaultShell$1() {
|
|
299467
|
+
return "/bin/sh";
|
|
299468
|
+
}
|
|
299469
|
+
|
|
299470
|
+
/**
|
|
299471
|
+
* Returns a function to escape arguments for use in a particular shell.
|
|
299472
|
+
*
|
|
299473
|
+
* @param {string} shellName The name of a Unix shell.
|
|
299474
|
+
* @param {object} options The options for escaping arguments.
|
|
299475
|
+
* @param {boolean} options.interpolation Is interpolation enabled.
|
|
299476
|
+
* @returns {Function | undefined} A function to escape arguments.
|
|
299477
|
+
*/
|
|
299478
|
+
function getEscapeFunction$3(shellName, options) {
|
|
299479
|
+
switch (shellName) {
|
|
299480
|
+
case binBash:
|
|
299481
|
+
return getEscapeFunction$7(options);
|
|
299482
|
+
case binCsh:
|
|
299483
|
+
return getEscapeFunction$6(options);
|
|
299484
|
+
case binDash:
|
|
299485
|
+
return getEscapeFunction$5(options);
|
|
299486
|
+
case binZsh:
|
|
299487
|
+
return getEscapeFunction$4(options);
|
|
299488
|
+
}
|
|
299489
|
+
}
|
|
299490
|
+
|
|
299491
|
+
/**
|
|
299492
|
+
* Returns a pair of functions to escape and quote arguments for use in a
|
|
299493
|
+
* particular shell.
|
|
299494
|
+
*
|
|
299495
|
+
* @param {string} shellName The name of a Unix shell.
|
|
299496
|
+
* @returns {Function[] | undefined} A function pair to escape & quote arguments.
|
|
299497
|
+
*/
|
|
299498
|
+
function getQuoteFunction$3(shellName) {
|
|
299499
|
+
switch (shellName) {
|
|
299500
|
+
case binBash:
|
|
299501
|
+
return getQuoteFunction$7();
|
|
299502
|
+
case binCsh:
|
|
299503
|
+
return getQuoteFunction$6();
|
|
299504
|
+
case binDash:
|
|
299505
|
+
return getQuoteFunction$5();
|
|
299506
|
+
case binZsh:
|
|
299507
|
+
return getQuoteFunction$4();
|
|
299508
|
+
}
|
|
299509
|
+
}
|
|
299510
|
+
|
|
299511
|
+
/**
|
|
299512
|
+
* Returns a function to protect against flag injection.
|
|
299513
|
+
*
|
|
299514
|
+
* @param {string} shellName The name of a Unix shell.
|
|
299515
|
+
* @returns {Function | undefined} A function to protect against flag injection.
|
|
299516
|
+
*/
|
|
299517
|
+
function getFlagProtectionFunction$3(shellName) {
|
|
299518
|
+
switch (shellName) {
|
|
299519
|
+
case binBash:
|
|
299520
|
+
return getFlagProtectionFunction$7();
|
|
299521
|
+
case binCsh:
|
|
299522
|
+
return getFlagProtectionFunction$6();
|
|
299523
|
+
case binDash:
|
|
299524
|
+
return getFlagProtectionFunction$5();
|
|
299525
|
+
case binZsh:
|
|
299526
|
+
return getFlagProtectionFunction$4();
|
|
299527
|
+
}
|
|
299528
|
+
}
|
|
299529
|
+
|
|
299530
|
+
/**
|
|
299531
|
+
* Determines the name of the shell identified by a file path or file name.
|
|
299532
|
+
*
|
|
299533
|
+
* @param {object} args The arguments for this function.
|
|
299534
|
+
* @param {string} args.shell The name or path of the shell.
|
|
299535
|
+
* @param {object} deps The dependencies for this function.
|
|
299536
|
+
* @param {Function} deps.resolveExecutable Resolve the path to an executable.
|
|
299537
|
+
* @returns {string} The shell name.
|
|
299538
|
+
*/
|
|
299539
|
+
function getShellName$1({ shell }, { resolveExecutable }) {
|
|
299540
|
+
shell = resolveExecutable(
|
|
299541
|
+
{ executable: shell },
|
|
299542
|
+
{ exists: fs__namespace.existsSync, readlink: fs__namespace.readlinkSync, which: which.sync },
|
|
299543
|
+
);
|
|
299544
|
+
|
|
299545
|
+
const shellName = path__namespace.basename(shell);
|
|
299546
|
+
if (getEscapeFunction$3(shellName, {}) === undefined) {
|
|
299547
|
+
return binBash;
|
|
299548
|
+
}
|
|
299549
|
+
|
|
299550
|
+
return shellName;
|
|
299551
|
+
}
|
|
299552
|
+
|
|
299553
|
+
var unix = /*#__PURE__*/Object.freeze({
|
|
299554
|
+
__proto__: null,
|
|
299555
|
+
getDefaultShell: getDefaultShell$1,
|
|
299556
|
+
getEscapeFunction: getEscapeFunction$3,
|
|
299557
|
+
getFlagProtectionFunction: getFlagProtectionFunction$3,
|
|
299558
|
+
getQuoteFunction: getQuoteFunction$3,
|
|
299559
|
+
getShellName: getShellName$1
|
|
299560
|
+
});
|
|
299561
|
+
|
|
299562
|
+
/**
|
|
299563
|
+
* @overview Provides functionality for the Windows Command Prompt.
|
|
299564
|
+
* @license MPL-2.0
|
|
299565
|
+
*/
|
|
299566
|
+
|
|
299567
|
+
/**
|
|
299568
|
+
* Escape an argument for use in CMD when interpolation is active.
|
|
299569
|
+
*
|
|
299570
|
+
* @param {string} arg The argument to escape.
|
|
299571
|
+
* @returns {string} The escaped argument.
|
|
299572
|
+
*/
|
|
299573
|
+
function escapeArgForInterpolation$1(arg) {
|
|
299574
|
+
let shouldEscapeSpecialChar = true;
|
|
299575
|
+
return arg
|
|
299576
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299577
|
+
.replace(/\r?\n|\r/gu, " ")
|
|
299578
|
+
.replace(/(?<!\\)(\\*)"/gu, '$1$1\\"')
|
|
299579
|
+
.split("")
|
|
299580
|
+
.map(
|
|
299581
|
+
// Due to the way CMD determines if it is inside a quoted section, and the
|
|
299582
|
+
// way we escape double quotes, whether or not special character need to
|
|
299583
|
+
// be escaped depends on the number of double quotes that proceed it. So,
|
|
299584
|
+
// we flip a flag for every double quote we encounter and escape special
|
|
299585
|
+
// characters conditionally on that flag.
|
|
299586
|
+
(char) => {
|
|
299587
|
+
if (char === '"') {
|
|
299588
|
+
shouldEscapeSpecialChar = !shouldEscapeSpecialChar;
|
|
299589
|
+
} else if (shouldEscapeSpecialChar && /[%&<>^|]/u.test(char)) {
|
|
299590
|
+
return `^${char}`;
|
|
299591
|
+
}
|
|
299592
|
+
|
|
299593
|
+
return char;
|
|
299594
|
+
},
|
|
299595
|
+
)
|
|
299596
|
+
.join("");
|
|
299597
|
+
}
|
|
299598
|
+
|
|
299599
|
+
/**
|
|
299600
|
+
* Escape an argument for use in CMD when the argument is not being quoted (but
|
|
299601
|
+
* interpolation is inactive).
|
|
299602
|
+
*
|
|
299603
|
+
* @param {string} arg The argument to escape.
|
|
299604
|
+
* @returns {string} The escaped argument.
|
|
299605
|
+
*/
|
|
299606
|
+
function escapeArgForNoInterpolation$1(arg) {
|
|
299607
|
+
return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r?\n|\r/gu, " ");
|
|
299608
|
+
}
|
|
299609
|
+
|
|
299610
|
+
/**
|
|
299611
|
+
* Returns a function to escape arguments for use in CMD for the given use case.
|
|
299612
|
+
*
|
|
299613
|
+
* @param {object} options The options for escaping arguments.
|
|
299614
|
+
* @param {boolean} options.interpolation Is interpolation enabled.
|
|
299615
|
+
* @returns {Function} A function to escape arguments.
|
|
299616
|
+
*/
|
|
299617
|
+
function getEscapeFunction$2(options) {
|
|
299618
|
+
if (options.interpolation) {
|
|
299619
|
+
return escapeArgForInterpolation$1;
|
|
299620
|
+
} else {
|
|
299621
|
+
return escapeArgForNoInterpolation$1;
|
|
299622
|
+
}
|
|
299623
|
+
}
|
|
299624
|
+
|
|
299625
|
+
/**
|
|
299626
|
+
* Escape an argument for use in CMD when the argument is being quoted.
|
|
299627
|
+
*
|
|
299628
|
+
* @param {string} arg The argument to escape.
|
|
299629
|
+
* @returns {string} The escaped argument.
|
|
299630
|
+
*/
|
|
299631
|
+
function escapeArgForQuoted$1(arg) {
|
|
299632
|
+
return escapeArgForInterpolation$1(arg).replace(
|
|
299633
|
+
/(?<!\\)(\\*)([\t ])/gu,
|
|
299634
|
+
"$1$1$2",
|
|
299635
|
+
);
|
|
299636
|
+
}
|
|
299637
|
+
|
|
299638
|
+
/**
|
|
299639
|
+
* Quotes an argument for use in CMD.
|
|
299640
|
+
*
|
|
299641
|
+
* @param {string} arg The argument to quote.
|
|
299642
|
+
* @returns {string} The quoted argument.
|
|
299643
|
+
*/
|
|
299644
|
+
function quoteArg$1(arg) {
|
|
299645
|
+
return arg.replace(/([\t ]+)/gu, '"$1"');
|
|
299646
|
+
}
|
|
299647
|
+
|
|
299648
|
+
/**
|
|
299649
|
+
* Returns a pair of functions to escape and quote arguments for use in CMD.
|
|
299650
|
+
*
|
|
299651
|
+
* @returns {Function[]} A function pair to escape & quote arguments.
|
|
299652
|
+
*/
|
|
299653
|
+
function getQuoteFunction$2() {
|
|
299654
|
+
return [escapeArgForQuoted$1, quoteArg$1];
|
|
299655
|
+
}
|
|
299656
|
+
|
|
299657
|
+
/**
|
|
299658
|
+
* Remove any prefix from the provided argument that might be interpreted as a
|
|
299659
|
+
* flag on Windows systems for CMD.
|
|
299660
|
+
*
|
|
299661
|
+
* @param {string} arg The argument to update.
|
|
299662
|
+
* @returns {string} The updated argument.
|
|
299663
|
+
*/
|
|
299664
|
+
function stripFlagPrefix$1(arg) {
|
|
299665
|
+
return arg.replace(/^(?:-+|\/+)/gu, "");
|
|
299666
|
+
}
|
|
299667
|
+
|
|
299668
|
+
/**
|
|
299669
|
+
* Returns a function to protect against flag injection for CMD.
|
|
299670
|
+
*
|
|
299671
|
+
* @returns {Function} A function to protect against flag injection.
|
|
299672
|
+
*/
|
|
299673
|
+
function getFlagProtectionFunction$2() {
|
|
299674
|
+
return stripFlagPrefix$1;
|
|
299675
|
+
}
|
|
299676
|
+
|
|
299677
|
+
/**
|
|
299678
|
+
* @overview Provides functionality for Windows PowerShell.
|
|
299679
|
+
* @license MPL-2.0
|
|
299680
|
+
*/
|
|
299681
|
+
|
|
299682
|
+
/**
|
|
299683
|
+
* Escape an argument for use in PowerShell when interpolation is active.
|
|
299684
|
+
*
|
|
299685
|
+
* @param {string} arg The argument to escape.
|
|
299686
|
+
* @returns {string} The escaped argument.
|
|
299687
|
+
*/
|
|
299688
|
+
function escapeArgForInterpolation(arg) {
|
|
299689
|
+
arg = arg
|
|
299690
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299691
|
+
.replace(/`/gu, "``")
|
|
299692
|
+
.replace(/\r(?!\n)/gu, "")
|
|
299693
|
+
.replace(/\r?\n/gu, " ")
|
|
299694
|
+
.replace(/(?<=^|[\s\u0085])([*1-6]?)(>)/gu, "$1`$2")
|
|
299695
|
+
.replace(/(?<=^|[\s\u0085])([#\-:<@\]])/gu, "`$1")
|
|
299696
|
+
.replace(/([$&'(),;{|}‘’‚‛“”„])/gu, "`$1");
|
|
299697
|
+
|
|
299698
|
+
if (/[\s\u0085]/u.test(arg.replace(/^[\s\u0085]+/gu, ""))) {
|
|
299699
|
+
arg = arg
|
|
299700
|
+
.replace(/(?<!\\)(\\*)"/gu, '$1$1`"`"')
|
|
299701
|
+
.replace(/(?<!\\)(\\+)$/gu, "$1$1");
|
|
299702
|
+
} else {
|
|
299703
|
+
arg = arg.replace(/(?<!\\)(\\*)"/gu, '$1$1\\`"');
|
|
299704
|
+
}
|
|
299705
|
+
|
|
299706
|
+
arg = arg.replace(/([\s\u0085])/gu, "`$1");
|
|
299707
|
+
|
|
299708
|
+
return arg;
|
|
299709
|
+
}
|
|
299710
|
+
|
|
299711
|
+
/**
|
|
299712
|
+
* Escape an argument for use in PowerShell when the argument is not being
|
|
299713
|
+
* quoted (but interpolation is inactive).
|
|
299714
|
+
*
|
|
299715
|
+
* @param {string} arg The argument to escape.
|
|
299716
|
+
* @returns {string} The escaped argument.
|
|
299717
|
+
*/
|
|
299718
|
+
function escapeArgForNoInterpolation(arg) {
|
|
299719
|
+
return arg.replace(/[\0\u0008\u001B\u009B]/gu, "").replace(/\r(?!\n)/gu, "");
|
|
299720
|
+
}
|
|
299721
|
+
|
|
299722
|
+
/**
|
|
299723
|
+
* Returns a function to escape arguments for use in PowerShell for the given
|
|
299724
|
+
* use case.
|
|
299725
|
+
*
|
|
299726
|
+
* @param {object} options The options for escaping arguments.
|
|
299727
|
+
* @param {boolean} options.interpolation Is interpolation enabled.
|
|
299728
|
+
* @returns {Function} A function to escape arguments.
|
|
299729
|
+
*/
|
|
299730
|
+
function getEscapeFunction$1(options) {
|
|
299731
|
+
if (options.interpolation) {
|
|
299732
|
+
return escapeArgForInterpolation;
|
|
299733
|
+
} else {
|
|
299734
|
+
return escapeArgForNoInterpolation;
|
|
299735
|
+
}
|
|
299736
|
+
}
|
|
299737
|
+
|
|
299738
|
+
/**
|
|
299739
|
+
* Escape an argument for use in PowerShell when the argument is being quoted.
|
|
299740
|
+
*
|
|
299741
|
+
* @param {string} arg The argument to escape.
|
|
299742
|
+
* @returns {string} The escaped argument.
|
|
299743
|
+
*/
|
|
299744
|
+
function escapeArgForQuoted(arg) {
|
|
299745
|
+
arg = arg
|
|
299746
|
+
.replace(/[\0\u0008\u001B\u009B]/gu, "")
|
|
299747
|
+
.replace(/\r(?!\n)/gu, "")
|
|
299748
|
+
.replace(/(['‘’‚‛])/gu, "$1$1");
|
|
299749
|
+
|
|
299750
|
+
if (/[\s\u0085]/u.test(arg)) {
|
|
299751
|
+
arg = arg
|
|
299752
|
+
.replace(/(?<!\\)(\\*)"/gu, '$1$1""')
|
|
299753
|
+
.replace(/(?<!\\)(\\+)$/gu, "$1$1");
|
|
299754
|
+
} else {
|
|
299755
|
+
arg = arg.replace(/(?<!\\)(\\*)"/gu, '$1$1\\"');
|
|
299756
|
+
}
|
|
299757
|
+
|
|
299758
|
+
return arg;
|
|
299759
|
+
}
|
|
299760
|
+
|
|
299761
|
+
/**
|
|
299762
|
+
* Quotes an argument for use in PowerShell.
|
|
299763
|
+
*
|
|
299764
|
+
* @param {string} arg The argument to quote and escape.
|
|
299765
|
+
* @returns {string} The quoted and escaped argument.
|
|
299766
|
+
*/
|
|
299767
|
+
function quoteArg(arg) {
|
|
299768
|
+
return `'${arg}'`;
|
|
299769
|
+
}
|
|
299770
|
+
|
|
299771
|
+
/**
|
|
299772
|
+
* Returns a pair of functions to escape and quote arguments for use in
|
|
299773
|
+
* PowerShell.
|
|
299774
|
+
*
|
|
299775
|
+
* @returns {Function[]} A function pair to escape & quote arguments.
|
|
299776
|
+
*/
|
|
299777
|
+
function getQuoteFunction$1() {
|
|
299778
|
+
return [escapeArgForQuoted, quoteArg];
|
|
299779
|
+
}
|
|
299780
|
+
|
|
299781
|
+
/**
|
|
299782
|
+
* Remove any prefix from the provided argument that might be interpreted as a
|
|
299783
|
+
* flag on Windows systems for PowerShell.
|
|
299784
|
+
*
|
|
299785
|
+
* @param {string} arg The argument to update.
|
|
299786
|
+
* @returns {string} The updated argument.
|
|
299787
|
+
*/
|
|
299788
|
+
function stripFlagPrefix(arg) {
|
|
299789
|
+
return arg.replace(/^(?:`?-+|\/+)/gu, "");
|
|
299790
|
+
}
|
|
299791
|
+
|
|
299792
|
+
/**
|
|
299793
|
+
* Returns a function to protect against flag injection for PowerShell.
|
|
299794
|
+
*
|
|
299795
|
+
* @returns {Function} A function to protect against flag injection.
|
|
299796
|
+
*/
|
|
299797
|
+
function getFlagProtectionFunction$1() {
|
|
299798
|
+
return stripFlagPrefix;
|
|
299799
|
+
}
|
|
299800
|
+
|
|
299801
|
+
/**
|
|
299802
|
+
* @overview Provides functionality for Windows systems.
|
|
299803
|
+
* @license MPL-2.0
|
|
299804
|
+
*/
|
|
299805
|
+
|
|
299806
|
+
|
|
299807
|
+
/**
|
|
299808
|
+
* The name of the Windows Command Prompt binary.
|
|
299809
|
+
*
|
|
299810
|
+
* @constant
|
|
299811
|
+
* @type {string}
|
|
299812
|
+
*/
|
|
299813
|
+
const binCmd = "cmd.exe";
|
|
299814
|
+
|
|
299815
|
+
/**
|
|
299816
|
+
* The name of the Windows PowerShell binary.
|
|
299817
|
+
*
|
|
299818
|
+
* @constant
|
|
299819
|
+
* @type {string}
|
|
299820
|
+
*/
|
|
299821
|
+
const binPowerShell = "powershell.exe";
|
|
299822
|
+
|
|
299823
|
+
/**
|
|
299824
|
+
* Returns the default shell for Windows systems.
|
|
299825
|
+
*
|
|
299826
|
+
* For more information, see:
|
|
299827
|
+
* https://nodejs.org/api/child_process.html#default-windows-shell.
|
|
299828
|
+
*
|
|
299829
|
+
* @param {object} args The arguments for this function.
|
|
299830
|
+
* @param {object} args.env The environment variables.
|
|
299831
|
+
* @param {string} [args.env.ComSpec] The %COMSPEC% value.
|
|
299832
|
+
* @returns {string} The default shell.
|
|
299833
|
+
*/
|
|
299834
|
+
function getDefaultShell({ env: { ComSpec } }) {
|
|
299835
|
+
if (ComSpec !== undefined) {
|
|
299836
|
+
return ComSpec;
|
|
299837
|
+
}
|
|
299838
|
+
|
|
299839
|
+
return binCmd;
|
|
299840
|
+
}
|
|
299841
|
+
|
|
299842
|
+
/**
|
|
299843
|
+
* Returns a function to escape arguments for use in a particular shell.
|
|
299844
|
+
*
|
|
299845
|
+
* @param {string} shellName The name of a Windows shell.
|
|
299846
|
+
* @param {object} options The options for escaping arguments.
|
|
299847
|
+
* @param {boolean} options.interpolation Is interpolation enabled.
|
|
299848
|
+
* @returns {Function | undefined} A function to escape arguments.
|
|
299849
|
+
*/
|
|
299850
|
+
function getEscapeFunction(shellName, options) {
|
|
299851
|
+
switch (shellName) {
|
|
299852
|
+
case binCmd:
|
|
299853
|
+
return getEscapeFunction$2(options);
|
|
299854
|
+
case binPowerShell:
|
|
299855
|
+
return getEscapeFunction$1(options);
|
|
299856
|
+
}
|
|
299857
|
+
}
|
|
299858
|
+
|
|
299859
|
+
/**
|
|
299860
|
+
* Returns a pair of functions to escape and quote arguments for use in a
|
|
299861
|
+
* particular shell.
|
|
299862
|
+
*
|
|
299863
|
+
* @param {string} shellName The name of a Windows shell.
|
|
299864
|
+
* @returns {Function[] | undefined} A function pair to escape & quote arguments.
|
|
299865
|
+
*/
|
|
299866
|
+
function getQuoteFunction(shellName) {
|
|
299867
|
+
switch (shellName) {
|
|
299868
|
+
case binCmd:
|
|
299869
|
+
return getQuoteFunction$2();
|
|
299870
|
+
case binPowerShell:
|
|
299871
|
+
return getQuoteFunction$1();
|
|
299872
|
+
}
|
|
299873
|
+
}
|
|
299874
|
+
|
|
299875
|
+
/**
|
|
299876
|
+
* Returns a function to protect against flag injection.
|
|
299877
|
+
*
|
|
299878
|
+
* @param {string} shellName The name of a Windows shell.
|
|
299879
|
+
* @returns {Function | undefined} A function to protect against flag injection.
|
|
299880
|
+
*/
|
|
299881
|
+
function getFlagProtectionFunction(shellName) {
|
|
299882
|
+
switch (shellName) {
|
|
299883
|
+
case binCmd:
|
|
299884
|
+
return getFlagProtectionFunction$2();
|
|
299885
|
+
case binPowerShell:
|
|
299886
|
+
return getFlagProtectionFunction$1();
|
|
299887
|
+
}
|
|
299888
|
+
}
|
|
299889
|
+
|
|
299890
|
+
/**
|
|
299891
|
+
* Determines the name of the shell identified by a file path or file name.
|
|
299892
|
+
*
|
|
299893
|
+
* @param {object} args The arguments for this function.
|
|
299894
|
+
* @param {string} args.shell The name or path of the shell.
|
|
299895
|
+
* @param {object} deps The dependencies for this function.
|
|
299896
|
+
* @param {Function} deps.resolveExecutable Resolve the path to an executable.
|
|
299897
|
+
* @returns {string} The shell name.
|
|
299898
|
+
*/
|
|
299899
|
+
function getShellName({ shell }, { resolveExecutable }) {
|
|
299900
|
+
shell = resolveExecutable(
|
|
299901
|
+
{ executable: shell },
|
|
299902
|
+
{ exists: fs__namespace.existsSync, readlink: fs__namespace.readlinkSync, which: which.sync },
|
|
299903
|
+
);
|
|
299904
|
+
|
|
299905
|
+
const shellName = path__namespace.win32.basename(shell);
|
|
299906
|
+
if (getEscapeFunction(shellName, {}) === undefined) {
|
|
299907
|
+
return binCmd;
|
|
299908
|
+
}
|
|
299909
|
+
|
|
299910
|
+
return shellName;
|
|
299911
|
+
}
|
|
299912
|
+
|
|
299913
|
+
var win = /*#__PURE__*/Object.freeze({
|
|
299914
|
+
__proto__: null,
|
|
299915
|
+
getDefaultShell: getDefaultShell,
|
|
299916
|
+
getEscapeFunction: getEscapeFunction,
|
|
299917
|
+
getFlagProtectionFunction: getFlagProtectionFunction,
|
|
299918
|
+
getQuoteFunction: getQuoteFunction,
|
|
299919
|
+
getShellName: getShellName
|
|
299920
|
+
});
|
|
299921
|
+
|
|
299922
|
+
/**
|
|
299923
|
+
* @overview Provides functionality related to getting the platform module for
|
|
299924
|
+
* the current system.
|
|
299925
|
+
* @license MPL-2.0
|
|
299926
|
+
*/
|
|
299927
|
+
|
|
299928
|
+
|
|
299929
|
+
/**
|
|
299930
|
+
* The string identifying the OS type Cygwin.
|
|
299931
|
+
*
|
|
299932
|
+
* @constant
|
|
299933
|
+
* @type {string}
|
|
299934
|
+
*/
|
|
299935
|
+
const cygwin = "cygwin";
|
|
299936
|
+
|
|
299937
|
+
/**
|
|
299938
|
+
* The string identifying the OS type MSYS.
|
|
299939
|
+
*
|
|
299940
|
+
* @constant
|
|
299941
|
+
* @type {string}
|
|
299942
|
+
*/
|
|
299943
|
+
const msys = "msys";
|
|
299944
|
+
|
|
299945
|
+
/**
|
|
299946
|
+
* The string identifying Windows platforms.
|
|
299947
|
+
*
|
|
299948
|
+
* @constant
|
|
299949
|
+
* @type {string}
|
|
299950
|
+
*/
|
|
299951
|
+
const win32 = "win32";
|
|
299952
|
+
|
|
299953
|
+
/**
|
|
299954
|
+
* Checks if the current system is a Windows system.
|
|
299955
|
+
*
|
|
299956
|
+
* @param {object} args The arguments for this function.
|
|
299957
|
+
* @param {Object<string, string>} args.env The environment variables.
|
|
299958
|
+
* @param {string} args.platform The `os.platform()` value.
|
|
299959
|
+
* @returns {boolean} `true` if the system is Windows, `false` otherwise.
|
|
299960
|
+
*/
|
|
299961
|
+
function isWindow({ env, platform }) {
|
|
299962
|
+
return env.OSTYPE === cygwin || env.OSTYPE === msys || platform === win32;
|
|
299963
|
+
}
|
|
299964
|
+
|
|
299965
|
+
/**
|
|
299966
|
+
* Returns all helper functions for a specific system.
|
|
299967
|
+
*
|
|
299968
|
+
* @param {object} args The arguments for this function.
|
|
299969
|
+
* @param {Object<string, string>} args.env The environment variables.
|
|
299970
|
+
* @param {string} args.platform The `os.platform()` value.
|
|
299971
|
+
* @returns {object} The helper functions for the current system.
|
|
299972
|
+
*/
|
|
299973
|
+
function getHelpersByPlatform({ env, platform }) {
|
|
299974
|
+
if (isWindow({ env, platform })) {
|
|
299975
|
+
return win;
|
|
299976
|
+
}
|
|
299977
|
+
|
|
299978
|
+
return unix;
|
|
299979
|
+
}
|
|
299980
|
+
|
|
299981
|
+
/**
|
|
299982
|
+
* A simple shell escape library. Use it to escape user-controlled inputs to
|
|
299983
|
+
* shell commands to prevent shell injection.
|
|
299984
|
+
*
|
|
299985
|
+
* @overview Entrypoint for the library.
|
|
299986
|
+
* @module shescape
|
|
299987
|
+
* @version 1.7.2
|
|
299988
|
+
* @license MPL-2.0
|
|
299989
|
+
*/
|
|
299990
|
+
|
|
299991
|
+
|
|
299992
|
+
/**
|
|
299993
|
+
* Get the helper functions for the current platform.
|
|
299994
|
+
*
|
|
299995
|
+
* @returns {object} The helper functions for the current platform.
|
|
299996
|
+
*/
|
|
299997
|
+
function getPlatformHelpers() {
|
|
299998
|
+
const platform = os.platform();
|
|
299999
|
+
const helpers = getHelpersByPlatform({ env: process.env, platform });
|
|
300000
|
+
return helpers;
|
|
300001
|
+
}
|
|
300002
|
+
|
|
300003
|
+
/**
|
|
300004
|
+
* Take a single value, the argument, and escape any dangerous characters.
|
|
300005
|
+
*
|
|
300006
|
+
* Non-string inputs will be converted to strings using a `toString()` method.
|
|
300007
|
+
*
|
|
300008
|
+
* NOTE: when the `interpolation` option is set to `true`, whitespace is escaped
|
|
300009
|
+
* to prevent argument splitting except for cmd.exe (which does not support it).
|
|
300010
|
+
*
|
|
300011
|
+
* @example
|
|
300012
|
+
* import { spawn } from "node:child_process";
|
|
300013
|
+
* spawn(
|
|
300014
|
+
* "echo",
|
|
300015
|
+
* ["Hello", shescape.escape(userInput)],
|
|
300016
|
+
* null // `options.shell` MUST be falsy
|
|
300017
|
+
* );
|
|
300018
|
+
* @param {string} arg The argument to escape.
|
|
300019
|
+
* @param {object} [options] The escape options.
|
|
300020
|
+
* @param {boolean} [options.flagProtection=false] Is flag protection enabled.
|
|
300021
|
+
* @param {boolean} [options.interpolation=false] Is interpolation enabled.
|
|
300022
|
+
* @param {boolean | string} [options.shell] The shell to escape for.
|
|
300023
|
+
* @returns {string} The escaped argument.
|
|
300024
|
+
* @throws {TypeError} The argument is not stringable.
|
|
300025
|
+
* @since 0.1.0
|
|
300026
|
+
*/
|
|
300027
|
+
function escape(arg, options = {}) {
|
|
300028
|
+
const helpers = getPlatformHelpers();
|
|
300029
|
+
const { flagProtection, interpolation, shellName } = parseOptions(
|
|
300030
|
+
{ options, process },
|
|
300031
|
+
helpers,
|
|
300032
|
+
);
|
|
300033
|
+
const argAsString = checkedToString(arg);
|
|
300034
|
+
const escape = helpers.getEscapeFunction(shellName, { interpolation });
|
|
300035
|
+
const escapedArg = escape(argAsString);
|
|
300036
|
+
if (flagProtection) {
|
|
300037
|
+
const flagProtect = helpers.getFlagProtectionFunction(shellName);
|
|
300038
|
+
return flagProtect(escapedArg);
|
|
300039
|
+
} else {
|
|
300040
|
+
return escapedArg;
|
|
300041
|
+
}
|
|
300042
|
+
}
|
|
300043
|
+
|
|
300044
|
+
/**
|
|
300045
|
+
* Take a array of values, the arguments, and escape any dangerous characters in
|
|
300046
|
+
* every argument.
|
|
300047
|
+
*
|
|
300048
|
+
* Non-array inputs will be converted to one-value arrays and non-string values
|
|
300049
|
+
* will be converted to strings using a `toString()` method.
|
|
300050
|
+
*
|
|
300051
|
+
* @example
|
|
300052
|
+
* import { spawn } from "node:child_process";
|
|
300053
|
+
* spawn(
|
|
300054
|
+
* "echo",
|
|
300055
|
+
* shescape.escapeAll(["Hello", userInput]),
|
|
300056
|
+
* null // `options.shell` MUST be falsy
|
|
300057
|
+
* );
|
|
300058
|
+
* @param {string[]} args The arguments to escape.
|
|
300059
|
+
* @param {object} [options] The escape options.
|
|
300060
|
+
* @param {boolean} [options.flagProtection=false] Is flag protection enabled.
|
|
300061
|
+
* @param {boolean} [options.interpolation=false] Is interpolation enabled.
|
|
300062
|
+
* @param {boolean | string} [options.shell] The shell to escape for.
|
|
300063
|
+
* @returns {string[]} The escaped arguments.
|
|
300064
|
+
* @throws {TypeError} One of the arguments is not stringable.
|
|
300065
|
+
* @since 1.1.0
|
|
300066
|
+
*/
|
|
300067
|
+
function escapeAll(args, options = {}) {
|
|
300068
|
+
args = toArrayIfNecessary(args);
|
|
300069
|
+
return args.map((arg) => escape(arg, options));
|
|
300070
|
+
}
|
|
300071
|
+
|
|
300072
|
+
/**
|
|
300073
|
+
* Take a single value, the argument, put shell-specific quotes around it and
|
|
300074
|
+
* escape any dangerous characters.
|
|
300075
|
+
*
|
|
300076
|
+
* Non-string inputs will be converted to strings using a `toString()` method.
|
|
300077
|
+
*
|
|
300078
|
+
* @example
|
|
300079
|
+
* import { spawn } from "node:child_process";
|
|
300080
|
+
* const spawnOptions = { shell: true }; // `options.shell` SHOULD be truthy
|
|
300081
|
+
* const shescapeOptions = { ...spawnOptions };
|
|
300082
|
+
* spawn(
|
|
300083
|
+
* "echo",
|
|
300084
|
+
* ["Hello", shescape.quote(userInput, shescapeOptions)],
|
|
300085
|
+
* spawnOptions
|
|
300086
|
+
* );
|
|
300087
|
+
* @example
|
|
300088
|
+
* import { exec } from "node:child_process";
|
|
300089
|
+
* const execOptions = null || { };
|
|
300090
|
+
* const shescapeOptions = { ...execOptions };
|
|
300091
|
+
* exec(
|
|
300092
|
+
* `echo Hello ${shescape.quote(userInput, shescapeOptions)}`,
|
|
300093
|
+
* execOptions
|
|
300094
|
+
* );
|
|
300095
|
+
* @param {string} arg The argument to quote and escape.
|
|
300096
|
+
* @param {object} [options] The escape and quote options.
|
|
300097
|
+
* @param {boolean} [options.flagProtection=false] Is flag protection enabled.
|
|
300098
|
+
* @param {boolean | string} [options.shell] The shell to escape for.
|
|
300099
|
+
* @returns {string} The quoted and escaped argument.
|
|
300100
|
+
* @throws {TypeError} The argument is not stringable.
|
|
300101
|
+
* @since 0.3.0
|
|
300102
|
+
*/
|
|
300103
|
+
function quote(arg, options = {}) {
|
|
300104
|
+
const helpers = getPlatformHelpers();
|
|
300105
|
+
const { flagProtection, shellName } = parseOptions(
|
|
300106
|
+
{ options, process },
|
|
300107
|
+
helpers,
|
|
300108
|
+
);
|
|
300109
|
+
const argAsString = checkedToString(arg);
|
|
300110
|
+
const [escape, quote] = helpers.getQuoteFunction(shellName);
|
|
300111
|
+
const escapedArg = escape(argAsString);
|
|
300112
|
+
if (flagProtection) {
|
|
300113
|
+
const flagProtect = helpers.getFlagProtectionFunction(shellName);
|
|
300114
|
+
return quote(flagProtect(escapedArg));
|
|
300115
|
+
} else {
|
|
300116
|
+
return quote(escapedArg);
|
|
300117
|
+
}
|
|
300118
|
+
}
|
|
300119
|
+
|
|
300120
|
+
/**
|
|
300121
|
+
* Take an array of values, the arguments, put shell-specific quotes around
|
|
300122
|
+
* every argument and escape any dangerous characters in every argument.
|
|
300123
|
+
*
|
|
300124
|
+
* Non-array inputs will be converted to one-value arrays and non-string values
|
|
300125
|
+
* will be converted to strings using a `toString()` method.
|
|
300126
|
+
*
|
|
300127
|
+
* @example
|
|
300128
|
+
* import { spawn } from "node:child_process";
|
|
300129
|
+
* const spawnOptions = { shell: true }; // `options.shell` SHOULD be truthy
|
|
300130
|
+
* const shescapeOptions = { ...spawnOptions };
|
|
300131
|
+
* spawn(
|
|
300132
|
+
* "echo",
|
|
300133
|
+
* shescape.quoteAll(["Hello", userInput], shescapeOptions),
|
|
300134
|
+
* spawnOptions
|
|
300135
|
+
* );
|
|
300136
|
+
* @param {string[]} args The arguments to quote and escape.
|
|
300137
|
+
* @param {object} [options] The escape and quote options.
|
|
300138
|
+
* @param {boolean} [options.flagProtection=false] Is flag protection enabled.
|
|
300139
|
+
* @param {boolean | string} [options.shell] The shell to escape for.
|
|
300140
|
+
* @returns {string[]} The quoted and escaped arguments.
|
|
300141
|
+
* @throws {TypeError} One of the arguments is not stringable.
|
|
300142
|
+
* @since 0.4.0
|
|
300143
|
+
*/
|
|
300144
|
+
function quoteAll(args, options = {}) {
|
|
300145
|
+
args = toArrayIfNecessary(args);
|
|
300146
|
+
return args.map((arg) => quote(arg, options));
|
|
300147
|
+
}
|
|
300148
|
+
|
|
300149
|
+
exports.escape = escape;
|
|
300150
|
+
exports.escapeAll = escapeAll;
|
|
300151
|
+
exports.quote = quote;
|
|
300152
|
+
exports.quoteAll = quoteAll;
|
|
300153
|
+
|
|
300154
|
+
|
|
297356
300155
|
/***/ }),
|
|
297357
300156
|
|
|
297358
300157
|
/***/ 53966:
|
|
@@ -304142,7 +306941,7 @@ module.exports = JSON.parse('[{"name":"AppVeyor","constant":"APPVEYOR","env":"AP
|
|
|
304142
306941
|
/***/ ((module) => {
|
|
304143
306942
|
|
|
304144
306943
|
"use strict";
|
|
304145
|
-
module.exports = {"i8":"1.
|
|
306944
|
+
module.exports = {"i8":"1.14.0"};
|
|
304146
306945
|
|
|
304147
306946
|
/***/ })
|
|
304148
306947
|
|