snyk 1.799.0 → 1.803.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/727.index.js
CHANGED
|
@@ -15249,10 +15249,12 @@ exports.getLayer = getLayer;
|
|
|
15249
15249
|
"use strict";
|
|
15250
15250
|
|
|
15251
15251
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
15252
|
-
exports.getManifest = void 0;
|
|
15252
|
+
exports.computeDigest = exports.getManifest = void 0;
|
|
15253
15253
|
const registry_call_1 = __webpack_require__(15271);
|
|
15254
15254
|
const contentTypes = __webpack_require__(42625);
|
|
15255
15255
|
const needle_1 = __webpack_require__(48360);
|
|
15256
|
+
const crypto_1 = __webpack_require__(76417);
|
|
15257
|
+
const digestRegex = /^sha256:[a-f0-9]{64}$/i;
|
|
15256
15258
|
/**
|
|
15257
15259
|
* A request to get image manifest by tag or digest
|
|
15258
15260
|
* @param registryBase the hostname (and optionally base path) from which to get the manifest.
|
|
@@ -15265,20 +15267,55 @@ const needle_1 = __webpack_require__(48360);
|
|
|
15265
15267
|
* Defaults to linux/amd64. In case the requested manifest platform is not found an error is thrown.
|
|
15266
15268
|
* @returns
|
|
15267
15269
|
*/
|
|
15268
|
-
async function getManifest(registryBase, repo,
|
|
15270
|
+
async function getManifest(registryBase, repo, imageReference, username, password, options = {}, platform) {
|
|
15269
15271
|
var _a;
|
|
15270
15272
|
const accept = (_a = options.acceptManifest) !== null && _a !== void 0 ? _a : `${contentTypes.MANIFEST_V2}, ${contentTypes.MANIFEST_LIST_V2}`;
|
|
15271
|
-
const endpoint = `/${repo}/manifests/${
|
|
15272
|
-
|
|
15273
|
+
const endpoint = `/${repo}/manifests/${imageReference}`;
|
|
15274
|
+
let manifestResponse = await registry_call_1.registryV2Call(registryBase, endpoint, accept, username, password, options);
|
|
15273
15275
|
const contentType = manifestResponse.headers["content-type"];
|
|
15276
|
+
let indexDigest;
|
|
15277
|
+
let manifestDigest;
|
|
15274
15278
|
if (contentType === contentTypes.MANIFEST_LIST_V2) {
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15279
|
+
indexDigest = computeDigest(manifestResponse.body);
|
|
15280
|
+
manifestDigest = getManifestDigestByPlatform(manifestResponse, platform);
|
|
15281
|
+
// need to call again with actual manifest (and not a list of manifest-lists)
|
|
15282
|
+
const endpoint = `/${repo}/manifests/${manifestDigest}`;
|
|
15283
|
+
manifestResponse = await registry_call_1.registryV2Call(registryBase, endpoint, accept, username, password, options);
|
|
15284
|
+
}
|
|
15285
|
+
const dockerContentDigest = manifestResponse.headers["Docker-Content-Digest"];
|
|
15286
|
+
switch (true) {
|
|
15287
|
+
case manifestDigest != undefined:
|
|
15288
|
+
break;
|
|
15289
|
+
case isManifestDigest(imageReference):
|
|
15290
|
+
manifestDigest = imageReference;
|
|
15291
|
+
break;
|
|
15292
|
+
case isManifestDigest(dockerContentDigest):
|
|
15293
|
+
manifestDigest = dockerContentDigest;
|
|
15294
|
+
break;
|
|
15295
|
+
default:
|
|
15296
|
+
manifestDigest = computeDigest(manifestResponse.body);
|
|
15278
15297
|
}
|
|
15279
|
-
|
|
15298
|
+
const parsedBody = needle_1.parseResponseBody(manifestResponse);
|
|
15299
|
+
return Object.assign(Object.assign({}, parsedBody), { indexDigest, manifestDigest });
|
|
15280
15300
|
}
|
|
15281
15301
|
exports.getManifest = getManifest;
|
|
15302
|
+
function isManifestDigest(imageReference) {
|
|
15303
|
+
return digestRegex.test(imageReference);
|
|
15304
|
+
}
|
|
15305
|
+
function computeDigest(body) {
|
|
15306
|
+
if (!body) {
|
|
15307
|
+
return undefined;
|
|
15308
|
+
}
|
|
15309
|
+
if (typeof body !== "string") {
|
|
15310
|
+
body = JSON.stringify(body);
|
|
15311
|
+
}
|
|
15312
|
+
const hexDigest = crypto_1.createHash("sha256")
|
|
15313
|
+
.update(body)
|
|
15314
|
+
.digest("hex")
|
|
15315
|
+
.toLowerCase();
|
|
15316
|
+
return `sha256:${hexDigest}`;
|
|
15317
|
+
}
|
|
15318
|
+
exports.computeDigest = computeDigest;
|
|
15282
15319
|
function getManifestDigestByPlatform(manifestResponse, platform) {
|
|
15283
15320
|
const defaultPlatform = {
|
|
15284
15321
|
os: "linux",
|
|
@@ -15471,7 +15508,7 @@ class NeedleWrapperException extends Error {
|
|
|
15471
15508
|
|
|
15472
15509
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
15473
15510
|
exports.buildUnauthenticatedV2RequestConfig = exports.parseChallengeHeaders = exports.getToken = exports.paginatedV2Call = exports.registryCall = exports.registryV2Call = void 0;
|
|
15474
|
-
const parseLink = __webpack_require__(
|
|
15511
|
+
const parseLink = __webpack_require__(54336);
|
|
15475
15512
|
const url = __webpack_require__(78835);
|
|
15476
15513
|
const needle_1 = __webpack_require__(48360);
|
|
15477
15514
|
const BEARER_REALM = "Bearer realm";
|
|
@@ -15721,6 +15758,86 @@ function assertFullUrl(redirectLocation, originalLocation) {
|
|
|
15721
15758
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
15722
15759
|
//# sourceMappingURL=types.js.map
|
|
15723
15760
|
|
|
15761
|
+
/***/ }),
|
|
15762
|
+
|
|
15763
|
+
/***/ 54336:
|
|
15764
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
15765
|
+
|
|
15766
|
+
"use strict";
|
|
15767
|
+
|
|
15768
|
+
|
|
15769
|
+
var qs = __webpack_require__(71191)
|
|
15770
|
+
, url = __webpack_require__(78835)
|
|
15771
|
+
, xtend = __webpack_require__(47529);
|
|
15772
|
+
|
|
15773
|
+
const PARSE_LINK_HEADER_MAXLEN = parseInt(process.env.PARSE_LINK_HEADER_MAXLEN) || 2000;
|
|
15774
|
+
const PARSE_LINK_HEADER_THROW_ON_MAXLEN_EXCEEDED = process.env.PARSE_LINK_HEADER_THROW_ON_MAXLEN_EXCEEDED != null
|
|
15775
|
+
|
|
15776
|
+
function hasRel(x) {
|
|
15777
|
+
return x && x.rel;
|
|
15778
|
+
}
|
|
15779
|
+
|
|
15780
|
+
function intoRels (acc, x) {
|
|
15781
|
+
function splitRel (rel) {
|
|
15782
|
+
acc[rel] = xtend(x, { rel: rel });
|
|
15783
|
+
}
|
|
15784
|
+
|
|
15785
|
+
x.rel.split(/\s+/).forEach(splitRel);
|
|
15786
|
+
|
|
15787
|
+
return acc;
|
|
15788
|
+
}
|
|
15789
|
+
|
|
15790
|
+
function createObjects (acc, p) {
|
|
15791
|
+
// rel="next" => 1: rel 2: next
|
|
15792
|
+
var m = p.match(/\s*(.+)\s*=\s*"?([^"]+)"?/)
|
|
15793
|
+
if (m) acc[m[1]] = m[2];
|
|
15794
|
+
return acc;
|
|
15795
|
+
}
|
|
15796
|
+
|
|
15797
|
+
function parseLink(link) {
|
|
15798
|
+
try {
|
|
15799
|
+
var m = link.match(/<?([^>]*)>(.*)/)
|
|
15800
|
+
, linkUrl = m[1]
|
|
15801
|
+
, parts = m[2].split(';')
|
|
15802
|
+
, parsedUrl = url.parse(linkUrl)
|
|
15803
|
+
, qry = qs.parse(parsedUrl.query);
|
|
15804
|
+
|
|
15805
|
+
parts.shift();
|
|
15806
|
+
|
|
15807
|
+
var info = parts
|
|
15808
|
+
.reduce(createObjects, {});
|
|
15809
|
+
|
|
15810
|
+
info = xtend(qry, info);
|
|
15811
|
+
info.url = linkUrl;
|
|
15812
|
+
return info;
|
|
15813
|
+
} catch (e) {
|
|
15814
|
+
return null;
|
|
15815
|
+
}
|
|
15816
|
+
}
|
|
15817
|
+
|
|
15818
|
+
function checkHeader(linkHeader){
|
|
15819
|
+
if (!linkHeader) return false;
|
|
15820
|
+
|
|
15821
|
+
if (linkHeader.length > PARSE_LINK_HEADER_MAXLEN) {
|
|
15822
|
+
if (PARSE_LINK_HEADER_THROW_ON_MAXLEN_EXCEEDED) {
|
|
15823
|
+
throw new Error('Input string too long, it should be under ' + PARSE_LINK_HEADER_MAXLEN + ' characters.');
|
|
15824
|
+
} else {
|
|
15825
|
+
return false;
|
|
15826
|
+
}
|
|
15827
|
+
}
|
|
15828
|
+
return true;
|
|
15829
|
+
}
|
|
15830
|
+
|
|
15831
|
+
module.exports = function (linkHeader) {
|
|
15832
|
+
if (!checkHeader(linkHeader)) return null;
|
|
15833
|
+
|
|
15834
|
+
return linkHeader.split(/,\s*</)
|
|
15835
|
+
.map(parseLink)
|
|
15836
|
+
.filter(hasRel)
|
|
15837
|
+
.reduce(intoRels, {});
|
|
15838
|
+
};
|
|
15839
|
+
|
|
15840
|
+
|
|
15724
15841
|
/***/ }),
|
|
15725
15842
|
|
|
15726
15843
|
/***/ 8381:
|
|
@@ -152247,70 +152364,6 @@ module.exports = pTry;
|
|
|
152247
152364
|
module.exports.default = pTry;
|
|
152248
152365
|
|
|
152249
152366
|
|
|
152250
|
-
/***/ }),
|
|
152251
|
-
|
|
152252
|
-
/***/ 28490:
|
|
152253
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
152254
|
-
|
|
152255
|
-
"use strict";
|
|
152256
|
-
|
|
152257
|
-
|
|
152258
|
-
var qs = __webpack_require__(71191)
|
|
152259
|
-
, url = __webpack_require__(78835)
|
|
152260
|
-
, xtend = __webpack_require__(47529);
|
|
152261
|
-
|
|
152262
|
-
function hasRel(x) {
|
|
152263
|
-
return x && x.rel;
|
|
152264
|
-
}
|
|
152265
|
-
|
|
152266
|
-
function intoRels (acc, x) {
|
|
152267
|
-
function splitRel (rel) {
|
|
152268
|
-
acc[rel] = xtend(x, { rel: rel });
|
|
152269
|
-
}
|
|
152270
|
-
|
|
152271
|
-
x.rel.split(/\s+/).forEach(splitRel);
|
|
152272
|
-
|
|
152273
|
-
return acc;
|
|
152274
|
-
}
|
|
152275
|
-
|
|
152276
|
-
function createObjects (acc, p) {
|
|
152277
|
-
// rel="next" => 1: rel 2: next
|
|
152278
|
-
var m = p.match(/\s*(.+)\s*=\s*"?([^"]+)"?/)
|
|
152279
|
-
if (m) acc[m[1]] = m[2];
|
|
152280
|
-
return acc;
|
|
152281
|
-
}
|
|
152282
|
-
|
|
152283
|
-
function parseLink(link) {
|
|
152284
|
-
try {
|
|
152285
|
-
var m = link.match(/<?([^>]*)>(.*)/)
|
|
152286
|
-
, linkUrl = m[1]
|
|
152287
|
-
, parts = m[2].split(';')
|
|
152288
|
-
, parsedUrl = url.parse(linkUrl)
|
|
152289
|
-
, qry = qs.parse(parsedUrl.query);
|
|
152290
|
-
|
|
152291
|
-
parts.shift();
|
|
152292
|
-
|
|
152293
|
-
var info = parts
|
|
152294
|
-
.reduce(createObjects, {});
|
|
152295
|
-
|
|
152296
|
-
info = xtend(qry, info);
|
|
152297
|
-
info.url = linkUrl;
|
|
152298
|
-
return info;
|
|
152299
|
-
} catch (e) {
|
|
152300
|
-
return null;
|
|
152301
|
-
}
|
|
152302
|
-
}
|
|
152303
|
-
|
|
152304
|
-
module.exports = function (linkHeader) {
|
|
152305
|
-
if (!linkHeader) return null;
|
|
152306
|
-
|
|
152307
|
-
return linkHeader.split(/,\s*</)
|
|
152308
|
-
.map(parseLink)
|
|
152309
|
-
.filter(hasRel)
|
|
152310
|
-
.reduce(intoRels, {});
|
|
152311
|
-
};
|
|
152312
|
-
|
|
152313
|
-
|
|
152314
152367
|
/***/ }),
|
|
152315
152368
|
|
|
152316
152369
|
/***/ 64095:
|
|
@@ -170890,12 +170943,9 @@ async function analyze(targetImage, dockerfileAnalysis, imageType, imagePath, gl
|
|
|
170890
170943
|
exports.analyze = analyze;
|
|
170891
170944
|
function getNestedJarsDesiredDepth(options) {
|
|
170892
170945
|
const nestedJarsOption = options["nested-jars-depth"] || options["shaded-jars-depth"];
|
|
170893
|
-
let nestedJarsDepth =
|
|
170946
|
+
let nestedJarsDepth = 1;
|
|
170894
170947
|
const depthNumber = Number(nestedJarsOption);
|
|
170895
|
-
if (isNaN(depthNumber)) {
|
|
170896
|
-
nestedJarsDepth = option_utils_1.isTrue(nestedJarsOption) ? 1 : 0;
|
|
170897
|
-
}
|
|
170898
|
-
else {
|
|
170948
|
+
if (!isNaN(depthNumber) && depthNumber >= 0) {
|
|
170899
170949
|
nestedJarsDepth = depthNumber;
|
|
170900
170950
|
}
|
|
170901
170951
|
return nestedJarsDepth;
|
|
@@ -173565,10 +173615,11 @@ async function scan(options) {
|
|
|
173565
173615
|
!option_utils_1.isTrue(options["app-vulns"])) {
|
|
173566
173616
|
throw new Error("To use --nested-jars-depth, you must also use --app-vulns");
|
|
173567
173617
|
}
|
|
173568
|
-
if (!option_utils_1.isNumber(nestedJarsDepth) &&
|
|
173618
|
+
if ((!option_utils_1.isNumber(nestedJarsDepth) &&
|
|
173569
173619
|
!option_utils_1.isTrue(nestedJarsDepth) &&
|
|
173570
|
-
typeof nestedJarsDepth !== "undefined")
|
|
173571
|
-
|
|
173620
|
+
typeof nestedJarsDepth !== "undefined") ||
|
|
173621
|
+
Number(nestedJarsDepth) < 0) {
|
|
173622
|
+
throw new Error("--nested-jars-depth accepts only numbers bigger than or equal to 0");
|
|
173572
173623
|
}
|
|
173573
173624
|
const targetImage = appendLatestTagIfMissing(options.path);
|
|
173574
173625
|
const dockerfilePath = options.file;
|