snyk 1.1118.0 → 1.1119.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.
@@ -127692,7 +127692,7 @@ module.exports = arrify;
127692
127692
  /* module decorator */ module = __webpack_require__.nmd(module);
127693
127693
 
127694
127694
  try {
127695
- process.dlopen(module, __dirname + __webpack_require__(85622).sep + __webpack_require__.p + "160330cb588043b376e80837e6664733.node");
127695
+ process.dlopen(module, __dirname + __webpack_require__(85622).sep + __webpack_require__.p + "a8f8676967c7b025b7bbc9bf05eac2de.node");
127696
127696
  } catch (error) {
127697
127697
  throw new Error('node-loader:\n' + error);
127698
127698
  }
@@ -127706,7 +127706,7 @@ try {
127706
127706
  /* module decorator */ module = __webpack_require__.nmd(module);
127707
127707
 
127708
127708
  try {
127709
- process.dlopen(module, __dirname + __webpack_require__(85622).sep + __webpack_require__.p + "d0231d5874891854e13ca7a7d010e42a.node");
127709
+ process.dlopen(module, __dirname + __webpack_require__(85622).sep + __webpack_require__.p + "0f81c7f0efca6359e87b0892f010b7e5.node");
127710
127710
  } catch (error) {
127711
127711
  throw new Error('node-loader:\n' + error);
127712
127712
  }
@@ -137080,9 +137080,8 @@ exports.isResultEmpty = isResultEmpty;
137080
137080
  "use strict";
137081
137081
 
137082
137082
  Object.defineProperty(exports, "__esModule", ({ value: true }));
137083
- exports.getUserInstructionLayersFromConfig = exports.getDetectedLayersInfoFromConfig = exports.getPlatformFromConfig = exports.getRootFsLayersFromConfig = exports.getImageIdFromManifest = exports.getManifestLayers = exports.extractArchive = void 0;
137083
+ exports.getImageIdFromManifest = exports.getManifestLayers = exports.extractArchive = void 0;
137084
137084
  const path_1 = __webpack_require__(85622);
137085
- const instruction_parser_1 = __webpack_require__(50387);
137086
137085
  const types_1 = __webpack_require__(93677);
137087
137086
  var layer_1 = __webpack_require__(71544);
137088
137087
  Object.defineProperty(exports, "extractArchive", ({ enumerable: true, get: function () { return layer_1.extractArchive; } }));
@@ -137104,49 +137103,6 @@ function getImageIdFromManifest(manifest) {
137104
137103
  }
137105
137104
  }
137106
137105
  exports.getImageIdFromManifest = getImageIdFromManifest;
137107
- function getRootFsLayersFromConfig(imageConfig) {
137108
- try {
137109
- return imageConfig.rootfs.diff_ids;
137110
- }
137111
- catch (err) {
137112
- throw new Error("Failed to extract rootfs array from image config");
137113
- }
137114
- }
137115
- exports.getRootFsLayersFromConfig = getRootFsLayersFromConfig;
137116
- function getPlatformFromConfig(imageConfig) {
137117
- return imageConfig.os && imageConfig.architecture
137118
- ? `${imageConfig.os}/${imageConfig.architecture}`
137119
- : undefined;
137120
- }
137121
- exports.getPlatformFromConfig = getPlatformFromConfig;
137122
- function getDetectedLayersInfoFromConfig(imageConfig) {
137123
- const runInstructions = getUserInstructionLayersFromConfig(imageConfig)
137124
- .filter((instruction) => !instruction.empty_layer && instruction.created_by)
137125
- .map((instruction) => instruction.created_by.replace("# buildkit", ""));
137126
- const dockerfilePackages = (0, instruction_parser_1.getPackagesFromRunInstructions)(runInstructions);
137127
- const dockerfileLayers = (0, instruction_parser_1.getLayersFromPackages)(dockerfilePackages);
137128
- return { dockerfilePackages, dockerfileLayers };
137129
- }
137130
- exports.getDetectedLayersInfoFromConfig = getDetectedLayersInfoFromConfig;
137131
- function getUserInstructionLayersFromConfig(imageConfig) {
137132
- const diffInHours = (d1, d2) => Math.abs(d1 - d2) / 1000 / (60 * 60);
137133
- const maxDiffInHours = 5;
137134
- const history = imageConfig.history;
137135
- if (!history) {
137136
- return [];
137137
- }
137138
- const lastInstructionTime = new Date(history.slice(-1)[0].created);
137139
- const userInstructionLayers = history.filter((layer) => {
137140
- return (diffInHours(new Date(layer.created), lastInstructionTime) <=
137141
- maxDiffInHours);
137142
- });
137143
- // should only happen if there are no layers created by user instructions
137144
- if (userInstructionLayers.length === history.length) {
137145
- return [];
137146
- }
137147
- return userInstructionLayers;
137148
- }
137149
- exports.getUserInstructionLayersFromConfig = getUserInstructionLayersFromConfig;
137150
137106
  //# sourceMappingURL=index.js.map
137151
137107
 
137152
137108
  /***/ }),
@@ -137163,6 +137119,7 @@ const fs_1 = __webpack_require__(35747);
137163
137119
  const gunzip = __webpack_require__(65923);
137164
137120
  const path_1 = __webpack_require__(85622);
137165
137121
  const tar_stream_1 = __webpack_require__(53871);
137122
+ const __1 = __webpack_require__(18141);
137166
137123
  const stream_utils_1 = __webpack_require__(54540);
137167
137124
  const layer_1 = __webpack_require__(56423);
137168
137125
  const debug = Debug("snyk");
@@ -137207,7 +137164,7 @@ async function extractArchive(dockerArchiveFilesystemPath, extractActions) {
137207
137164
  }
137208
137165
  catch (error) {
137209
137166
  debug(`Error getting layers and manifest content from docker archive: ${error}`);
137210
- reject(new Error("Invalid Docker archive"));
137167
+ reject(new __1.InvalidArchiveError("Invalid Docker archive"));
137211
137168
  }
137212
137169
  });
137213
137170
  tarExtractor.on("error", (error) => reject(error));
@@ -137397,10 +137354,38 @@ exports.getImageNames = getImageNames;
137397
137354
  "use strict";
137398
137355
 
137399
137356
  Object.defineProperty(exports, "__esModule", ({ value: true }));
137400
- exports.getContentAsString = exports.getContentAsBuffer = exports.isDeletedFile = exports.extractImageContent = void 0;
137357
+ exports.getContentAsString = exports.getContentAsBuffer = exports.isDeletedFile = exports.getUserInstructionLayersFromConfig = exports.getDetectedLayersInfoFromConfig = exports.getPlatformFromConfig = exports.getRootFsLayersFromConfig = exports.extractImageContent = exports.InvalidArchiveError = void 0;
137358
+ const instruction_parser_1 = __webpack_require__(50387);
137401
137359
  const types_1 = __webpack_require__(93677);
137402
137360
  const dockerExtractor = __webpack_require__(40637);
137403
137361
  const ociExtractor = __webpack_require__(27044);
137362
+ class InvalidArchiveError extends Error {
137363
+ constructor(message) {
137364
+ super();
137365
+ this.name = "InvalidArchiveError";
137366
+ this.message = message;
137367
+ }
137368
+ }
137369
+ exports.InvalidArchiveError = InvalidArchiveError;
137370
+ class ArchiveExtractor {
137371
+ constructor(extractor, path, actions) {
137372
+ this.fileSystemPath = path;
137373
+ this.extractActions = actions;
137374
+ this.extractor = extractor;
137375
+ }
137376
+ getExtractor() {
137377
+ return this.extractor;
137378
+ }
137379
+ async getLayersAndManifest() {
137380
+ return await this.extractor.extractArchive(this.fileSystemPath, this.extractActions);
137381
+ }
137382
+ getImageIdFromManifest(manifest) {
137383
+ return this.extractor.getImageIdFromManifest(manifest);
137384
+ }
137385
+ getManifestLayers(manifest) {
137386
+ return this.extractor.getManifestLayers(manifest);
137387
+ }
137388
+ }
137404
137389
  /**
137405
137390
  * Given a path on the file system to a image archive, open it up to inspect the layers
137406
137391
  * and look for specific files. File content can be transformed with a custom callback function if needed.
@@ -137409,33 +137394,98 @@ const ociExtractor = __webpack_require__(27044);
137409
137394
  * By default the file is returned raw if no processing is desired.
137410
137395
  */
137411
137396
  async function extractImageContent(imageType, fileSystemPath, extractActions) {
137412
- switch (imageType) {
137413
- case types_1.ImageType.OciArchive:
137414
- const ociArchive = await ociExtractor.extractArchive(fileSystemPath, extractActions);
137415
- return {
137416
- imageId: ociExtractor.getImageIdFromManifest(ociArchive.manifest),
137417
- manifestLayers: ociExtractor.getManifestLayers(ociArchive.manifest),
137418
- extractedLayers: layersWithLatestFileModifications(ociArchive.layers),
137419
- rootFsLayers: dockerExtractor.getRootFsLayersFromConfig(ociArchive.imageConfig),
137420
- autoDetectedUserInstructions: dockerExtractor.getDetectedLayersInfoFromConfig(ociArchive.imageConfig),
137421
- platform: dockerExtractor.getPlatformFromConfig(ociArchive.imageConfig),
137422
- imageLabels: ociArchive.imageConfig.config.Labels,
137423
- };
137424
- default:
137425
- const dockerArchive = await dockerExtractor.extractArchive(fileSystemPath, extractActions);
137426
- return {
137427
- imageId: dockerExtractor.getImageIdFromManifest(dockerArchive.manifest),
137428
- manifestLayers: dockerExtractor.getManifestLayers(dockerArchive.manifest),
137429
- extractedLayers: layersWithLatestFileModifications(dockerArchive.layers),
137430
- rootFsLayers: dockerExtractor.getRootFsLayersFromConfig(dockerArchive.imageConfig),
137431
- autoDetectedUserInstructions: dockerExtractor.getDetectedLayersInfoFromConfig(dockerArchive.imageConfig),
137432
- platform: dockerExtractor.getPlatformFromConfig(dockerArchive.imageConfig),
137433
- imageLabels: dockerArchive.imageConfig.config.Labels,
137434
- imageCreationTime: dockerArchive.imageConfig.created,
137435
- };
137397
+ const extractors = new Map([
137398
+ [
137399
+ types_1.ImageType.DockerArchive,
137400
+ new ArchiveExtractor(dockerExtractor, fileSystemPath, extractActions),
137401
+ ],
137402
+ [
137403
+ types_1.ImageType.OciArchive,
137404
+ new ArchiveExtractor(ociExtractor, fileSystemPath, extractActions),
137405
+ ],
137406
+ ]);
137407
+ let extractor;
137408
+ let archiveContent;
137409
+ if (extractors.has(imageType)) {
137410
+ extractor = extractors.get(imageType);
137411
+ archiveContent = await extractor.getLayersAndManifest();
137412
+ }
137413
+ else {
137414
+ // At this stage we do not know the format of the image so we will attempt
137415
+ // to extract the archive using the dockerExtractor but fall back to use the
137416
+ // ociExtractor if we encounter an invalid format.
137417
+ // This will happen on images pulled by the docker binary when using
137418
+ // containerd under the hood
137419
+ // @see https://snyksec.atlassian.net/browse/LUM-147
137420
+ try {
137421
+ extractor = extractors.get(types_1.ImageType.DockerArchive);
137422
+ archiveContent = await extractor.getLayersAndManifest();
137423
+ }
137424
+ catch (err) {
137425
+ if (err instanceof InvalidArchiveError) {
137426
+ extractor = extractors.get(types_1.ImageType.OciArchive);
137427
+ archiveContent = await extractor.getLayersAndManifest();
137428
+ }
137429
+ else {
137430
+ throw err;
137431
+ }
137432
+ }
137436
137433
  }
137434
+ return {
137435
+ imageId: extractor.getImageIdFromManifest(archiveContent.manifest),
137436
+ manifestLayers: extractor.getManifestLayers(archiveContent.manifest),
137437
+ imageCreationTime: archiveContent.imageConfig.created,
137438
+ extractedLayers: layersWithLatestFileModifications(archiveContent.layers),
137439
+ rootFsLayers: getRootFsLayersFromConfig(archiveContent.imageConfig),
137440
+ autoDetectedUserInstructions: getDetectedLayersInfoFromConfig(archiveContent.imageConfig),
137441
+ platform: getPlatformFromConfig(archiveContent.imageConfig),
137442
+ imageLabels: archiveContent.imageConfig.config.Labels,
137443
+ };
137437
137444
  }
137438
137445
  exports.extractImageContent = extractImageContent;
137446
+ function getRootFsLayersFromConfig(imageConfig) {
137447
+ try {
137448
+ return imageConfig.rootfs.diff_ids;
137449
+ }
137450
+ catch (err) {
137451
+ throw new Error("Failed to extract rootfs array from image config");
137452
+ }
137453
+ }
137454
+ exports.getRootFsLayersFromConfig = getRootFsLayersFromConfig;
137455
+ function getPlatformFromConfig(imageConfig) {
137456
+ return imageConfig.os && imageConfig.architecture
137457
+ ? `${imageConfig.os}/${imageConfig.architecture}`
137458
+ : undefined;
137459
+ }
137460
+ exports.getPlatformFromConfig = getPlatformFromConfig;
137461
+ function getDetectedLayersInfoFromConfig(imageConfig) {
137462
+ const runInstructions = getUserInstructionLayersFromConfig(imageConfig)
137463
+ .filter((instruction) => !instruction.empty_layer && instruction.created_by)
137464
+ .map((instruction) => instruction.created_by.replace("# buildkit", ""));
137465
+ const dockerfilePackages = (0, instruction_parser_1.getPackagesFromRunInstructions)(runInstructions);
137466
+ const dockerfileLayers = (0, instruction_parser_1.getLayersFromPackages)(dockerfilePackages);
137467
+ return { dockerfilePackages, dockerfileLayers };
137468
+ }
137469
+ exports.getDetectedLayersInfoFromConfig = getDetectedLayersInfoFromConfig;
137470
+ function getUserInstructionLayersFromConfig(imageConfig) {
137471
+ const diffInHours = (d1, d2) => Math.abs(d1 - d2) / 1000 / (60 * 60);
137472
+ const maxDiffInHours = 5;
137473
+ const history = imageConfig.history;
137474
+ if (!history) {
137475
+ return [];
137476
+ }
137477
+ const lastInstructionTime = new Date(history.slice(-1)[0].created);
137478
+ const userInstructionLayers = history.filter((layer) => {
137479
+ return (diffInHours(new Date(layer.created), lastInstructionTime) <=
137480
+ maxDiffInHours);
137481
+ });
137482
+ // should only happen if there are no layers created by user instructions
137483
+ if (userInstructionLayers.length === history.length) {
137484
+ return [];
137485
+ }
137486
+ return userInstructionLayers;
137487
+ }
137488
+ exports.getUserInstructionLayersFromConfig = getUserInstructionLayersFromConfig;
137439
137489
  function layersWithLatestFileModifications(layers) {
137440
137490
  const extractedLayers = {};
137441
137491
  const removedFilesToIgnore = new Set();
@@ -137592,9 +137642,14 @@ const gunzip = __webpack_require__(65923);
137592
137642
  const path_1 = __webpack_require__(85622);
137593
137643
  const stream_1 = __webpack_require__(92413);
137594
137644
  const tar_stream_1 = __webpack_require__(53871);
137645
+ const __1 = __webpack_require__(18141);
137595
137646
  const stream_utils_1 = __webpack_require__(54540);
137596
137647
  const layer_1 = __webpack_require__(56423);
137597
137648
  const debug = Debug("snyk");
137649
+ const MEDIATYPE_DOCKER_MANIFEST_V2 = "application/vnd.docker.distribution.manifest.v2+json";
137650
+ const MEDIATYPE_DOCKER_MANIFEST_LIST_V2 = "application/vnd.docker.distribution.manifest.list.v2+json";
137651
+ const MEDIATYPE_OCI_MANIFEST_V1 = "application/vnd.oci.image.manifest.v1+json";
137652
+ const MEDIATYPE_OCI_MANIFEST_LIST_V1 = "application/vnd.oci.image.index.v1+json";
137598
137653
  /**
137599
137654
  * Retrieve the products of files content from the specified oci-archive.
137600
137655
  * @param ociArchiveFilesystemPath Path to image file saved in oci-archive format.
@@ -137654,7 +137709,7 @@ async function extractArchive(ociArchiveFilesystemPath, extractActions) {
137654
137709
  }
137655
137710
  catch (error) {
137656
137711
  debug(`Error getting layers and manifest content from oci archive: '${error}'`);
137657
- reject(new Error("Invalid OCI archive"));
137712
+ reject(new __1.InvalidArchiveError("Invalid OCI archive"));
137658
137713
  }
137659
137714
  });
137660
137715
  tarExtractor.on("error", (error) => {
@@ -137704,11 +137759,13 @@ function getManifest(imageIndex, manifestCollection, indexFiles) {
137704
137759
  function getAllManifestsIndexItems(imageIndex, indexFiles) {
137705
137760
  const allManifestsInfo = [];
137706
137761
  for (const manifest of imageIndex.manifests) {
137707
- if (manifest.mediaType === "application/vnd.oci.image.manifest.v1+json") {
137762
+ if (manifest.mediaType === MEDIATYPE_OCI_MANIFEST_V1 ||
137763
+ manifest.mediaType === MEDIATYPE_DOCKER_MANIFEST_V2) {
137708
137764
  // an archive manifest file
137709
137765
  allManifestsInfo.push(manifest);
137710
137766
  }
137711
- else if (manifest.mediaType === "application/vnd.oci.image.index.v1+json") {
137767
+ else if (manifest.mediaType === MEDIATYPE_OCI_MANIFEST_LIST_V1 ||
137768
+ manifest.mediaType === MEDIATYPE_DOCKER_MANIFEST_LIST_V2) {
137712
137769
  // nested index
137713
137770
  const index = indexFiles[manifest.digest];
137714
137771
  allManifestsInfo.push(...getAllManifestsIndexItems(index, indexFiles));
@@ -137723,7 +137780,8 @@ function isImageConfigFile(json) {
137723
137780
  return json !== undefined && json.architecture && json.rootfs;
137724
137781
  }
137725
137782
  function isImageIndexFile(json) {
137726
- return ((json === null || json === void 0 ? void 0 : json.mediaType) === "application/vnd.oci.image.index.v1+json" &&
137783
+ return (((json === null || json === void 0 ? void 0 : json.mediaType) === MEDIATYPE_OCI_MANIFEST_LIST_V1 ||
137784
+ (json === null || json === void 0 ? void 0 : json.mediaType) === MEDIATYPE_DOCKER_MANIFEST_LIST_V2) &&
137727
137785
  Array.isArray(json === null || json === void 0 ? void 0 : json.manifests));
137728
137786
  }
137729
137787
  function isMainIndexFile(name) {
@@ -137866,11 +137924,20 @@ function extractModuleInformation(binary) {
137866
137924
  }
137867
137925
  const modules = [];
137868
137926
  versionsLines.forEach((versionLine) => {
137869
- const [, name, ver] = versionLine.split("\t");
137927
+ const [depType, name, ver] = versionLine.split("\t");
137870
137928
  if (!name || !ver) {
137871
137929
  return;
137872
137930
  }
137873
- modules.push(new go_module_1.GoModule(name, ver));
137931
+ if (depType === "dep") {
137932
+ modules.push(new go_module_1.GoModule(name, ver));
137933
+ }
137934
+ else if (depType === "=>") {
137935
+ // we've found a replace directive. These are always for the previous
137936
+ // line/ module, so we simply need to replace the last module we added.
137937
+ const last = modules.length - 1;
137938
+ modules[last].name = name;
137939
+ modules[last].version = ver;
137940
+ }
137874
137941
  });
137875
137942
  return [name, modules];
137876
137943
  }
@@ -138341,8 +138408,16 @@ class LineTable {
138341
138408
  this.binary = bigEndian;
138342
138409
  this.version = pclnVersion.v118;
138343
138410
  }
138411
+ else if (beMagic === LineTable.go120magic) {
138412
+ this.binary = bigEndian;
138413
+ this.version = pclnVersion.v120;
138414
+ }
138415
+ else if (leMagic === LineTable.go120magic) {
138416
+ this.binary = littleEndian;
138417
+ this.version = pclnVersion.v118;
138418
+ }
138344
138419
  else {
138345
- throw new Error("unknown / unsupported Go version");
138420
+ throw new Error(`unknown / unsupported Go version`);
138346
138421
  }
138347
138422
  this.ptrsize = b[7];
138348
138423
  const uintptr = (b) => {
@@ -138359,6 +138434,7 @@ class LineTable {
138359
138434
  };
138360
138435
  switch (this.version) {
138361
138436
  case pclnVersion.v118:
138437
+ case pclnVersion.v120:
138362
138438
  this.nfiletab = Number(offset(1));
138363
138439
  this.filetab = data(5);
138364
138440
  this.funcdata = data(7);
@@ -138450,6 +138526,7 @@ exports.LineTable = LineTable;
138450
138526
  LineTable.go12magic = 0xfffffffb;
138451
138527
  LineTable.go116magic = 0xfffffffa;
138452
138528
  LineTable.go118magic = 0xfffffff0;
138529
+ LineTable.go120magic = 0xfffffff1;
138453
138530
  var pclnVersion;
138454
138531
  (function (pclnVersion) {
138455
138532
  pclnVersion[pclnVersion["unknown"] = 0] = "unknown";
@@ -138457,6 +138534,7 @@ var pclnVersion;
138457
138534
  pclnVersion[pclnVersion["v12"] = 2] = "v12";
138458
138535
  pclnVersion[pclnVersion["v116"] = 3] = "v116";
138459
138536
  pclnVersion[pclnVersion["v118"] = 4] = "v118";
138537
+ pclnVersion[pclnVersion["v120"] = 5] = "v120";
138460
138538
  })(pclnVersion || (pclnVersion = {}));
138461
138539
  const bigEndian = {
138462
138540
  Uint32(b) {