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