snyk 1.1277.0 → 1.1279.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.
@@ -35940,6 +35940,343 @@ exports.execute = execute;
35940
35940
 
35941
35941
  /***/ }),
35942
35942
 
35943
+ /***/ 13173:
35944
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
35945
+
35946
+ "use strict";
35947
+
35948
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
35949
+ exports.isDigest = exports.validateDigest = void 0;
35950
+ const regexp_1 = __webpack_require__(69292);
35951
+ class InvalidDigestFormatError extends Error {
35952
+ constructor() {
35953
+ super('invalid digest format');
35954
+ this.name = 'InvalidDigestFormatError';
35955
+ }
35956
+ }
35957
+ class UnsupportedAlgorithmError extends Error {
35958
+ constructor() {
35959
+ super('unsupported digest algorithm');
35960
+ this.name = 'UnsupportedAlgorithmError';
35961
+ }
35962
+ }
35963
+ class InvalidDigestLengthError extends Error {
35964
+ constructor() {
35965
+ super('invalid checksum digest length');
35966
+ this.name = 'InvalidDigestLengthError';
35967
+ }
35968
+ }
35969
+ const algorithmsSizes = {
35970
+ sha256: 32,
35971
+ sha384: 48,
35972
+ sha512: 64,
35973
+ };
35974
+ function checkDigest(digest, handleError) {
35975
+ const indexOfColon = digest.indexOf(':');
35976
+ if (indexOfColon < 0 ||
35977
+ indexOfColon + 1 === digest.length ||
35978
+ !regexp_1.anchoredDigestRegexp.test(digest)) {
35979
+ return handleError(InvalidDigestFormatError);
35980
+ }
35981
+ const algorithm = digest.substring(0, indexOfColon);
35982
+ if (!Object.hasOwnProperty.call(algorithmsSizes, algorithm)) {
35983
+ return handleError(UnsupportedAlgorithmError);
35984
+ }
35985
+ if (algorithmsSizes[algorithm] * 2 !== (digest.length - indexOfColon - 1)) {
35986
+ return handleError(InvalidDigestLengthError);
35987
+ }
35988
+ return true;
35989
+ }
35990
+ const validateDigest = (digest) => {
35991
+ checkDigest(digest, (ErrorType) => {
35992
+ throw new ErrorType();
35993
+ });
35994
+ };
35995
+ exports.validateDigest = validateDigest;
35996
+ const isDigest = (digest) => {
35997
+ return checkDigest(digest, () => false);
35998
+ };
35999
+ exports.isDigest = isDigest;
36000
+ //# sourceMappingURL=digest.js.map
36001
+
36002
+ /***/ }),
36003
+
36004
+ /***/ 3687:
36005
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
36006
+
36007
+ "use strict";
36008
+
36009
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
36010
+ exports.parseAll = exports.parseFamiliarName = exports.parseQualifiedNameOptimized = exports.parseQualifiedName = exports.Reference = void 0;
36011
+ const reference_1 = __webpack_require__(12792);
36012
+ Object.defineProperty(exports, "Reference", ({ enumerable: true, get: function () { return reference_1.Reference; } }));
36013
+ const parsers_1 = __webpack_require__(57094);
36014
+ Object.defineProperty(exports, "parseAll", ({ enumerable: true, get: function () { return parsers_1.parseAll; } }));
36015
+ Object.defineProperty(exports, "parseFamiliarName", ({ enumerable: true, get: function () { return parsers_1.parseFamiliarName; } }));
36016
+ Object.defineProperty(exports, "parseQualifiedName", ({ enumerable: true, get: function () { return parsers_1.parseQualifiedName; } }));
36017
+ Object.defineProperty(exports, "parseQualifiedNameOptimized", ({ enumerable: true, get: function () { return parsers_1.parseQualifiedNameOptimized; } }));
36018
+ //# sourceMappingURL=index.js.map
36019
+
36020
+ /***/ }),
36021
+
36022
+ /***/ 57094:
36023
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
36024
+
36025
+ "use strict";
36026
+
36027
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
36028
+ exports.parseAll = exports.parseFamiliarName = exports.parseQualifiedName = exports.parseQualifiedNameOptimized = void 0;
36029
+ const regexp_1 = __webpack_require__(69292);
36030
+ const digest_1 = __webpack_require__(13173);
36031
+ const reference_1 = __webpack_require__(12792);
36032
+ const NAME_MAX_LENGTH = 255;
36033
+ class InvalidReferenceFormatError extends Error {
36034
+ constructor() {
36035
+ super("invalid reference format");
36036
+ this.name = "InvalidReferenceFormatError";
36037
+ }
36038
+ }
36039
+ class NameContainsUppercaseError extends Error {
36040
+ constructor() {
36041
+ super("repository name must be lowercase");
36042
+ this.name = "NameContainsUppercaseError";
36043
+ }
36044
+ }
36045
+ class EmptyNameError extends Error {
36046
+ constructor() {
36047
+ super("repository name must have at least one component");
36048
+ this.name = "EmptyNameError";
36049
+ }
36050
+ }
36051
+ class NameTooLongError extends Error {
36052
+ constructor() {
36053
+ super(`repository name must not be more than ${NAME_MAX_LENGTH} characters`);
36054
+ this.name = "NameTooLongError";
36055
+ }
36056
+ }
36057
+ const DEFAULT_DOMAIN = "docker.io";
36058
+ const LEGACY_DEFAULT_DOMAIN = "index.docker.io";
36059
+ const OFFICIAL_REPOSITORY_NAME = "library";
36060
+ function _parseQualifiedName(regexp, name) {
36061
+ const matches = regexp.exec(name);
36062
+ if (!matches) {
36063
+ if (name === "") {
36064
+ throw new EmptyNameError();
36065
+ }
36066
+ if (regexp.test(name.toLowerCase())) {
36067
+ throw new NameContainsUppercaseError();
36068
+ }
36069
+ throw new InvalidReferenceFormatError();
36070
+ }
36071
+ if (matches[1].length > NAME_MAX_LENGTH) {
36072
+ throw new NameTooLongError();
36073
+ }
36074
+ let reference;
36075
+ const nameMatch = regexp_1.anchoredNameRegexp.exec(matches[1]);
36076
+ if (nameMatch && nameMatch.length === 3) {
36077
+ reference = {
36078
+ domain: nameMatch[1],
36079
+ repository: nameMatch[2],
36080
+ };
36081
+ }
36082
+ else {
36083
+ reference = {
36084
+ domain: "",
36085
+ repository: matches[1],
36086
+ };
36087
+ }
36088
+ reference.tag = matches[2];
36089
+ if (matches[3]) {
36090
+ (0, digest_1.validateDigest)(matches[3]);
36091
+ reference.digest = matches[3];
36092
+ }
36093
+ return new reference_1.Reference(reference);
36094
+ }
36095
+ const parseQualifiedNameOptimized = (name) => {
36096
+ return _parseQualifiedName(new RegExp(regexp_1.referenceRegexp), name);
36097
+ };
36098
+ exports.parseQualifiedNameOptimized = parseQualifiedNameOptimized;
36099
+ const parseQualifiedName = (name) => {
36100
+ return _parseQualifiedName(regexp_1.referenceRegexp, name);
36101
+ };
36102
+ exports.parseQualifiedName = parseQualifiedName;
36103
+ function splitDockerDomain(name) {
36104
+ let domain;
36105
+ let reminder;
36106
+ const indexOfSlash = name.indexOf("/");
36107
+ if (indexOfSlash === -1 ||
36108
+ !(name.lastIndexOf(".", indexOfSlash) !== -1 ||
36109
+ name.lastIndexOf(":", indexOfSlash) !== -1 ||
36110
+ name.startsWith("localhost/"))) {
36111
+ domain = DEFAULT_DOMAIN;
36112
+ reminder = name;
36113
+ }
36114
+ else {
36115
+ domain = name.substring(0, indexOfSlash);
36116
+ reminder = name.substring(indexOfSlash + 1);
36117
+ }
36118
+ if (domain === LEGACY_DEFAULT_DOMAIN) {
36119
+ domain = DEFAULT_DOMAIN;
36120
+ }
36121
+ if (domain === DEFAULT_DOMAIN && !reminder.includes("/")) {
36122
+ reminder = `${OFFICIAL_REPOSITORY_NAME}/${reminder}`;
36123
+ }
36124
+ return [domain, reminder];
36125
+ }
36126
+ const parseFamiliarName = (name, parseQualifiedNameFunc) => {
36127
+ if (regexp_1.anchoredIdentifierRegexp.test(name)) {
36128
+ throw new TypeError(`invalid repository name (${name}),` +
36129
+ `cannot specify 64-byte hexadecimal strings`);
36130
+ }
36131
+ const [domain, remainder] = splitDockerDomain(name);
36132
+ let remoteName;
36133
+ const tagSeparatorIndex = remainder.indexOf(":");
36134
+ if (tagSeparatorIndex > -1) {
36135
+ remoteName = remainder.substring(0, tagSeparatorIndex);
36136
+ }
36137
+ else {
36138
+ remoteName = remainder;
36139
+ }
36140
+ if (remoteName.toLowerCase() !== remoteName) {
36141
+ throw new TypeError(`invalid reference format: repository name must be lowercase`);
36142
+ }
36143
+ if (parseQualifiedNameFunc) {
36144
+ return parseQualifiedNameFunc(`${domain}/${remainder}`);
36145
+ }
36146
+ return parseQualifiedName(`${domain}/${remainder}`);
36147
+ };
36148
+ exports.parseFamiliarName = parseFamiliarName;
36149
+ const parseAll = (name) => {
36150
+ if (regexp_1.anchoredIdentifierRegexp.test(name)) {
36151
+ return new reference_1.Reference({ digest: `sha256:${name}` });
36152
+ }
36153
+ if ((0, digest_1.isDigest)(name)) {
36154
+ return new reference_1.Reference({ digest: name });
36155
+ }
36156
+ return parseFamiliarName(name);
36157
+ };
36158
+ exports.parseAll = parseAll;
36159
+ //# sourceMappingURL=parsers.js.map
36160
+
36161
+ /***/ }),
36162
+
36163
+ /***/ 12792:
36164
+ /***/ ((__unused_webpack_module, exports) => {
36165
+
36166
+ "use strict";
36167
+
36168
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
36169
+ exports.Reference = void 0;
36170
+ const typesTemplates = {
36171
+ 'digest': (ref) => `${ref.digest}`,
36172
+ 'canonical': (ref) => `${ref.repositoryUrl}@${ref.digest}`,
36173
+ 'repository': (ref) => `${ref.repositoryUrl}`,
36174
+ 'tagged': (ref) => `${ref.repositoryUrl}:${ref.tag}`,
36175
+ 'dual': (ref) => `${ref.repositoryUrl}:${ref.tag}@${ref.digest}`
36176
+ };
36177
+ class Reference {
36178
+ get tag() {
36179
+ return this._tag;
36180
+ }
36181
+ get digest() {
36182
+ return this._digest;
36183
+ }
36184
+ get repository() {
36185
+ return this._repository;
36186
+ }
36187
+ get domain() {
36188
+ return this._domain;
36189
+ }
36190
+ get type() {
36191
+ return this._type;
36192
+ }
36193
+ constructor(options) {
36194
+ var _a, _b, _c, _d, _e, _f;
36195
+ if (!options.repository && !options.domain) {
36196
+ if (options.digest) {
36197
+ this._digest = options.digest;
36198
+ this._type = 'digest';
36199
+ }
36200
+ else {
36201
+ throw new TypeError('Empty Reference');
36202
+ }
36203
+ }
36204
+ else if (!options.tag) {
36205
+ this._domain = (_a = options.domain) !== null && _a !== void 0 ? _a : '';
36206
+ this._repository = (_b = options.repository) !== null && _b !== void 0 ? _b : '';
36207
+ if (options.digest) {
36208
+ this._digest = options.digest;
36209
+ this._type = 'canonical';
36210
+ }
36211
+ else {
36212
+ this._type = 'repository';
36213
+ }
36214
+ }
36215
+ else if (!options.digest) {
36216
+ this._domain = (_c = options.domain) !== null && _c !== void 0 ? _c : '';
36217
+ this._repository = (_d = options.repository) !== null && _d !== void 0 ? _d : '';
36218
+ this._tag = options.tag;
36219
+ this._type = 'tagged';
36220
+ }
36221
+ else {
36222
+ this._domain = (_e = options.domain) !== null && _e !== void 0 ? _e : '';
36223
+ this._repository = (_f = options.repository) !== null && _f !== void 0 ? _f : '';
36224
+ this._tag = options.tag;
36225
+ this._digest = options.digest;
36226
+ this._type = 'dual';
36227
+ }
36228
+ }
36229
+ toString() {
36230
+ return typesTemplates[this._type](this);
36231
+ }
36232
+ get repositoryUrl() {
36233
+ if (this._domain && this._repository) {
36234
+ return `${this._domain}/${this._repository}`;
36235
+ }
36236
+ return '';
36237
+ }
36238
+ }
36239
+ exports.Reference = Reference;
36240
+ //# sourceMappingURL=reference.js.map
36241
+
36242
+ /***/ }),
36243
+
36244
+ /***/ 69292:
36245
+ /***/ ((__unused_webpack_module, exports) => {
36246
+
36247
+ "use strict";
36248
+
36249
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
36250
+ exports.anchoredIdentifierRegexp = exports.anchoredDigestRegexp = exports.anchoredNameRegexp = exports.referenceRegexp = void 0;
36251
+ const expression = (...regexps) => new RegExp(regexps
36252
+ .map(re => re.source)
36253
+ .join(''));
36254
+ const group = (...regexps) => new RegExp(`(?:${expression(...regexps).source})`);
36255
+ const optional = (...regexps) => new RegExp(`${group(...regexps).source}?`);
36256
+ const repeated = (...regexps) => new RegExp(`${group(...regexps).source}+`);
36257
+ const anchored = (...regexps) => new RegExp(`^${expression(...regexps).source}$`);
36258
+ const capture = (...regexps) => new RegExp(`(${expression(...regexps).source})`);
36259
+ const alphaNumericRegexp = /[a-z0-9]+/;
36260
+ const separatorRegexp = /(?:[._]|__|[-]*)/;
36261
+ const nameComponentRegexp = expression(alphaNumericRegexp, optional(repeated(separatorRegexp, alphaNumericRegexp)));
36262
+ const domainComponentRegexp = /(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/;
36263
+ const domainRegexp = expression(domainComponentRegexp, optional(repeated(/\./, domainComponentRegexp)), optional(/:/, /[0-9]+/));
36264
+ const tagRegexp = /[\w][\w.-]{0,127}/;
36265
+ const digestRegexp = /[a-zA-Z][a-zA-Z0-9]*(?:[-_+.][a-zA-Z][a-zA-Z0-9]*)*[:][a-fA-F0-9]{32,}/;
36266
+ const anchoredDigestRegexp = anchored(digestRegexp);
36267
+ exports.anchoredDigestRegexp = anchoredDigestRegexp;
36268
+ const nameRegexp = expression(optional(domainRegexp, /\//), nameComponentRegexp, optional(repeated(/\//, nameComponentRegexp)));
36269
+ const anchoredNameRegexp = anchored(optional(capture(domainRegexp), /\//), capture(nameComponentRegexp, optional(repeated(/\//, nameComponentRegexp))));
36270
+ exports.anchoredNameRegexp = anchoredNameRegexp;
36271
+ const referenceRegexp = anchored(capture(nameRegexp), optional(/:/, capture(tagRegexp)), optional(/@/, capture(digestRegexp)));
36272
+ exports.referenceRegexp = referenceRegexp;
36273
+ const identifierRegexp = /[a-f0-9]{64}/;
36274
+ const anchoredIdentifierRegexp = anchored(identifierRegexp);
36275
+ exports.anchoredIdentifierRegexp = anchoredIdentifierRegexp;
36276
+ //# sourceMappingURL=regexp.js.map
36277
+
36278
+ /***/ }),
36279
+
35943
36280
  /***/ 60081:
35944
36281
  /***/ ((module, exports, __webpack_require__) => {
35945
36282
 
@@ -189443,6 +189780,13 @@ function extractHostnameFromTargetImage(targetImage) {
189443
189780
  if (!isImagePartOfURL(targetImage)) {
189444
189781
  return { hostname: defaultHostname, remainder: targetImage };
189445
189782
  }
189783
+ const dockerFriendlyRegistryHostname = "docker.io/";
189784
+ if (targetImage.startsWith(dockerFriendlyRegistryHostname)) {
189785
+ return {
189786
+ hostname: defaultHostname,
189787
+ remainder: targetImage.substring(dockerFriendlyRegistryHostname.length),
189788
+ };
189789
+ }
189446
189790
  const i = targetImage.indexOf("/");
189447
189791
  return {
189448
189792
  hostname: targetImage.substring(0, i),
@@ -191806,6 +192150,72 @@ function isMainIndexFile(name) {
191806
192150
 
191807
192151
  /***/ }),
191808
192152
 
192153
+ /***/ 19103:
192154
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
192155
+
192156
+ "use strict";
192157
+
192158
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
192159
+ exports.constructOCIDisributionMetadata = void 0;
192160
+ const docker_reference_1 = __webpack_require__(3687);
192161
+ function constructOCIDisributionMetadata({ imageName, manifestDigest, indexDigest, }) {
192162
+ try {
192163
+ const ref = (0, docker_reference_1.parseAll)(imageName);
192164
+ if (!ref.domain || !ref.repository) {
192165
+ return;
192166
+ }
192167
+ const metadata = {
192168
+ registryHost: ref.domain,
192169
+ repository: ref.repository,
192170
+ manifestDigest,
192171
+ indexDigest,
192172
+ imageTag: ref.tag,
192173
+ };
192174
+ if (!ociDistributionMetadataIsValid(metadata)) {
192175
+ return;
192176
+ }
192177
+ return metadata;
192178
+ }
192179
+ catch (_a) {
192180
+ return;
192181
+ }
192182
+ }
192183
+ exports.constructOCIDisributionMetadata = constructOCIDisributionMetadata;
192184
+ function ociDistributionMetadataIsValid(data) {
192185
+ // 255 byte limit is enforced by RFC 1035.
192186
+ if (Buffer.byteLength(data.registryHost) > 255) {
192187
+ return false;
192188
+ }
192189
+ // 2048 byte limit is enforced by Snyk for platform stability.
192190
+ // Longer strings may be valid, but nothing close to this limit has been observed by Snyk at time of writing.
192191
+ if (Buffer.byteLength(data.repository) > 2048 ||
192192
+ !repositoryNameIsValid(data.repository)) {
192193
+ return false;
192194
+ }
192195
+ if (!digestIsValid(data.manifestDigest)) {
192196
+ return false;
192197
+ }
192198
+ if (data.indexDigest && !digestIsValid(data.indexDigest)) {
192199
+ return false;
192200
+ }
192201
+ if (data.imageTag && !tagIsValid(data.imageTag)) {
192202
+ return false;
192203
+ }
192204
+ return true;
192205
+ }
192206
+ // Regular Expression Source: OCI Distribution Spec V1
192207
+ // https://github.com/opencontainers/distribution-spec/blob/570d0262abe8ec5e59d8e3fbbd7be4bd784b200e/spec.md?plain=1#L141
192208
+ const repositoryNameIsValid = (name) => /^[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(\/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*$/.test(name);
192209
+ // Regular Expression Source: OCI Image Spec V1
192210
+ // https://github.com/opencontainers/image-spec/blob/d60099175f88c47cd379c4738d158884749ed235/descriptor.md?plain=1#L143
192211
+ const digestIsValid = (digest) => /^sha256:[a-f0-9]{64}$/.test(digest);
192212
+ // Regular Expression Source: OCI Image Spec V1
192213
+ // https://github.com/opencontainers/distribution-spec/blob/3940529fe6c0a068290b27fb3cd797cf0528bed6/spec.md?plain=1#L160
192214
+ const tagIsValid = (tag) => /^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$/.test(tag);
192215
+ //# sourceMappingURL=oci-distribution-metadata.js.map
192216
+
192217
+ /***/ }),
192218
+
191809
192219
  /***/ 86666:
191810
192220
  /***/ ((__unused_webpack_module, exports) => {
191811
192221
 
@@ -193456,7 +193866,7 @@ const dep_graph_1 = __webpack_require__(71479);
193456
193866
  // Module that provides functions to collect and build response after all
193457
193867
  // analyses' are done.
193458
193868
  const dockerfile_1 = __webpack_require__(79652);
193459
- async function buildResponse(depsAnalysis, dockerfileAnalysis, excludeBaseImageVulns, names) {
193869
+ async function buildResponse(depsAnalysis, dockerfileAnalysis, excludeBaseImageVulns, names, ociDistributionMetadata) {
193460
193870
  var _a, _b;
193461
193871
  const deps = depsAnalysis.depTree.dependencies;
193462
193872
  const dockerfilePkgs = collectDockerfilePkgs(dockerfileAnalysis, deps);
@@ -193580,6 +193990,13 @@ async function buildResponse(depsAnalysis, dockerfileAnalysis, excludeBaseImageV
193580
193990
  additionalFacts.push(imageNamesFact);
193581
193991
  }
193582
193992
  }
193993
+ if (ociDistributionMetadata) {
193994
+ const metadataFact = {
193995
+ type: "ociDistributionMetadata",
193996
+ data: ociDistributionMetadata,
193997
+ };
193998
+ additionalFacts.push(metadataFact);
193999
+ }
193583
194000
  const scanResults = [
193584
194001
  {
193585
194002
  facts: [depGraphFact, ...additionalFacts],
@@ -193794,10 +194211,12 @@ exports.analyzeStatically = void 0;
193794
194211
  const analyzer = __webpack_require__(55269);
193795
194212
  const dependency_tree_1 = __webpack_require__(95997);
193796
194213
  const image_1 = __webpack_require__(92748);
194214
+ const oci_distribution_metadata_1 = __webpack_require__(19103);
193797
194215
  const option_utils_1 = __webpack_require__(48587);
193798
194216
  const parser_1 = __webpack_require__(45062);
193799
194217
  const response_builder_1 = __webpack_require__(75319);
193800
194218
  async function analyzeStatically(targetImage, dockerfileAnalysis, imageType, imagePath, globsToFind, options, imageName) {
194219
+ var _a;
193801
194220
  const staticAnalysis = await analyzer.analyzeStatically(targetImage, dockerfileAnalysis, imageType, imagePath, globsToFind, options);
193802
194221
  const parsedAnalysisResult = (0, parser_1.parseAnalysisResults)(targetImage, staticAnalysis);
193803
194222
  /** @deprecated Should try to build a dependency graph instead. */
@@ -193805,7 +194224,15 @@ async function analyzeStatically(targetImage, dockerfileAnalysis, imageType, ima
193805
194224
  const analysis = Object.assign(Object.assign({}, staticAnalysis), { depTree: dependenciesTree, imageId: parsedAnalysisResult.imageId, imageLayers: parsedAnalysisResult.imageLayers, packageFormat: parsedAnalysisResult.packageFormat });
193806
194225
  const excludeBaseImageVulns = (0, option_utils_1.isTrue)(options["exclude-base-image-vulns"]);
193807
194226
  const names = (0, image_1.getImageNames)(options, imageName);
193808
- return (0, response_builder_1.buildResponse)(analysis, dockerfileAnalysis, excludeBaseImageVulns, names);
194227
+ let ociDistributionMetadata;
194228
+ if (options.imageNameAndTag && ((_a = options.digests) === null || _a === void 0 ? void 0 : _a.manifest)) {
194229
+ ociDistributionMetadata = (0, oci_distribution_metadata_1.constructOCIDisributionMetadata)({
194230
+ imageName: options.imageNameAndTag,
194231
+ manifestDigest: options.digests.manifest,
194232
+ indexDigest: options.digests.index,
194233
+ });
194234
+ }
194235
+ return (0, response_builder_1.buildResponse)(analysis, dockerfileAnalysis, excludeBaseImageVulns, names, ociDistributionMetadata);
193809
194236
  }
193810
194237
  exports.analyzeStatically = analyzeStatically;
193811
194238
  //# sourceMappingURL=static.js.map
@@ -232396,6 +232823,7 @@ exports.inspect = inspect;
232396
232823
  Object.defineProperty(exports, "__esModule", ({ value: true }));
232397
232824
  exports.publish = exports.run = exports.restore = exports.validate = void 0;
232398
232825
  const debugModule = __webpack_require__(15158);
232826
+ const errors = __webpack_require__(62153);
232399
232827
  const errors_1 = __webpack_require__(62153);
232400
232828
  const path = __webpack_require__(71017);
232401
232829
  const subprocess = __webpack_require__(24862);
@@ -232432,9 +232860,21 @@ async function validate() {
232432
232860
  exports.validate = validate;
232433
232861
  async function restore(projectPath) {
232434
232862
  const command = 'dotnet';
232435
- const args = ['restore', '--no-cache', projectPath];
232436
- await handle('restore', command, args);
232437
- return;
232863
+ const args = ['restore', '--no-cache', '--verbosity', 'normal', projectPath];
232864
+ const result = await handle('restore', command, args);
232865
+ // A customer can define a <BaseOutPutPath> that redirects where `dotnet` saves the assets file. This will
232866
+ // get picked up by the dotnet tool and reported in the output logs.
232867
+ const regex = /Path:\s+(\S+project.assets.json)/g;
232868
+ const matches = result.stdout.matchAll(regex);
232869
+ const manifestFiles = [];
232870
+ for (const match of matches) {
232871
+ manifestFiles.push(match[1]);
232872
+ }
232873
+ if (manifestFiles.length === 0) {
232874
+ throw new errors.FileNotProcessableError('found no information in stdout about the whereabouts of the assets file');
232875
+ }
232876
+ // Return the last element in the log, as it might be mentioning local asset files in reverse order.
232877
+ return manifestFiles[manifestFiles.length - 1];
232438
232878
  }
232439
232879
  exports.restore = restore;
232440
232880
  async function run(projectPath, options) {
@@ -232806,7 +233246,6 @@ async function buildDepGraphFromFiles(root, targetFile, manifestType, useProject
232806
233246
  const safeTargetFile = targetFile || '.';
232807
233247
  const fileContentPath = path.resolve(safeRoot, safeTargetFile);
232808
233248
  const fileContent = getFileContents(fileContentPath);
232809
- const projectRootFolder = path.resolve(fileContentPath, '../../');
232810
233249
  const parser = PARSERS['dotnet-core-v2'];
232811
233250
  const projectAssets = await parser.fileContentParser.parse(fileContent);
232812
233251
  if (!((_a = projectAssets.project) === null || _a === void 0 ? void 0 : _a.frameworks)) {
@@ -232816,14 +233255,14 @@ async function buildDepGraphFromFiles(root, targetFile, manifestType, useProject
232816
233255
  // otherwise the raw key name, as it's not guaranteed that all framework objects contains a targetAlias.
232817
233256
  const targetFrameworks = Object.entries(projectAssets.project.frameworks).map(([key, value]) => ('targetAlias' in value ? value.targetAlias : key));
232818
233257
  if (targetFrameworks.length <= 0) {
232819
- throw new errors_1.FileNotProcessableError(`unable to detect a target framework in ${projectRootFolder}, a valid one is needed to continue down this path.`);
233258
+ throw new errors_1.FileNotProcessableError(`unable to detect a target framework in ${safeTargetFile}, a valid one is needed to continue down this path.`);
232820
233259
  }
232821
233260
  if (targetFramework && !targetFrameworks.includes(targetFramework)) {
232822
233261
  console.log(`\x1b[33m⚠ WARNING\x1b[0m: Supplied targetframework \x1b[1m${targetFramework}\x1b[0m was not detected in the supplied
232823
233262
  manifest file. Available targetFrameworks detected was \x1b[1m${targetFrameworks.join(',')}\x1b[0m.
232824
233263
  Will attempt to build dependency graph anyway, but the operation might fail.`);
232825
233264
  }
232826
- let resolvedProjectName = getRootName(root, projectRootFolder, projectNamePrefix);
233265
+ let resolvedProjectName = getRootName(root, safeRoot, projectNamePrefix);
232827
233266
  const projectNameFromManifestFile = (_c = (_b = projectAssets === null || projectAssets === void 0 ? void 0 : projectAssets.project) === null || _b === void 0 ? void 0 : _b.restore) === null || _c === void 0 ? void 0 : _c.projectName;
232828
233267
  if (manifestType === types_1.ManifestType.DOTNET_CORE &&
232829
233268
  useProjectNameFromAssetsFile) {
@@ -232847,12 +233286,12 @@ Will attempt to build dependency graph anyway, but the operation might fail.`);
232847
233286
  if (decidedTargetFrameworks.length == 0) {
232848
233287
  throw new errors_1.InvalidManifestError(`Was not able to find any supported TargetFrameworks to scan, aborting`);
232849
233288
  }
233289
+ // Ensure `dotnet` is installed on the system or fail trying.
233290
+ await dotnet.validate();
232850
233291
  const results = [];
232851
233292
  for (const decidedTargetFramework of decidedTargetFrameworks) {
232852
- // Ensure `dotnet` is installed on the system or fail trying.
232853
- await dotnet.validate();
232854
233293
  // Run `dotnet publish` to create a self-contained publishable binary with included .dlls for assembly version inspection.
232855
- const publishDir = await dotnet.publish(projectRootFolder, decidedTargetFramework);
233294
+ const publishDir = await dotnet.publish(safeRoot, decidedTargetFramework);
232856
233295
  // Then inspect the dependency graph for the runtimepackage's assembly versions.
232857
233296
  const depsFilePath = path.resolve(publishDir, `${projectNameFromManifestFile}.deps.json`);
232858
233297
  const depsFile = fs.readFileSync(depsFilePath);
@@ -233715,6 +234154,7 @@ const parseXML = __webpack_require__(5055);
233715
234154
  const debugModule = __webpack_require__(15158);
233716
234155
  const depsParser = __webpack_require__(91885);
233717
234156
  const framework_1 = __webpack_require__(93935);
234157
+ const errors_1 = __webpack_require__(62153);
233718
234158
  const debug = debugModule('snyk');
233719
234159
  function fromPackagesConfigEntry(manifest) {
233720
234160
  debug('Extracting by packages.config entry:' +
@@ -233736,13 +234176,14 @@ function parse(fileContent) {
233736
234176
  if (err) {
233737
234177
  throw err;
233738
234178
  }
233739
- else {
233740
- const packages = result.packages.package || [];
233741
- packages.forEach(function scanPackagesConfigNode(node) {
233742
- const installedDependency = fromPackagesConfigEntry(node);
233743
- installedPackages.push(installedDependency);
233744
- });
234179
+ if (!('packages' in result)) {
234180
+ throw new errors_1.InvalidManifestError(`Could not find a <packages> tag in your packages.config file. Please read this guide \x1b[4mhttps://learn.microsoft.com/en-us/nuget/reference/packages-config#schema\x1b[0m.`);
233745
234181
  }
234182
+ const packages = result.packages.package || [];
234183
+ packages.forEach(function scanPackagesConfigNode(node) {
234184
+ const installedDependency = fromPackagesConfigEntry(node);
234185
+ installedPackages.push(installedDependency);
234186
+ });
233746
234187
  });
233747
234188
  return installedPackages;
233748
234189
  }