snyk 1.851.0 → 1.852.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.
@@ -142855,7 +142855,7 @@ exports.spawn = spawn;
142855
142855
  "use strict";
142856
142856
 
142857
142857
  Object.defineProperty(exports, "__esModule", ({ value: true }));
142858
- exports.isSupportedSize = exports.EXTRACTED_DIR_SUFFIX = exports.DEFAULT_DECOMPRESSING_DEPTH = exports.DECOMPRESSING_CONCURRENCY_LEVEL = exports.HASHING_CONCURRENCY_LEVEL = exports.MAX_SUPPORTED_FILE_SIZE = exports.isWindowsOS = void 0;
142858
+ exports.isSupportedSize = exports.DECOMPRESSING_IGNORE_DIR = exports.DECOMPRESSING_WORKSPACE_DIR = exports.DECOMPRESSING_CONCURRENCY_LEVEL = exports.HASHING_CONCURRENCY_LEVEL = exports.MAX_SUPPORTED_FILE_SIZE = exports.isWindowsOS = void 0;
142859
142859
  const os = __webpack_require__(12087);
142860
142860
  const osName = __webpack_require__(7719);
142861
142861
  exports.isWindowsOS = () => osName()
@@ -142864,8 +142864,8 @@ exports.isWindowsOS = () => osName()
142864
142864
  exports.MAX_SUPPORTED_FILE_SIZE = 2 * 1024 * 1024 * 1024 - 1;
142865
142865
  exports.HASHING_CONCURRENCY_LEVEL = os.cpus().length;
142866
142866
  exports.DECOMPRESSING_CONCURRENCY_LEVEL = os.cpus().length * 8;
142867
- exports.DEFAULT_DECOMPRESSING_DEPTH = 1;
142868
- exports.EXTRACTED_DIR_SUFFIX = '.extracted';
142867
+ exports.DECOMPRESSING_WORKSPACE_DIR = 'workspace';
142868
+ exports.DECOMPRESSING_IGNORE_DIR = 'ignore';
142869
142869
  exports.isSupportedSize = (size) => 0 < size && size < exports.MAX_SUPPORTED_FILE_SIZE;
142870
142870
  //# sourceMappingURL=common.js.map
142871
142871
 
@@ -143121,25 +143121,33 @@ exports.display = display;
143121
143121
  "use strict";
143122
143122
 
143123
143123
  Object.defineProperty(exports, "__esModule", ({ value: true }));
143124
- exports.filterArchives = exports.isArchive = exports.isZip = exports.isTar = exports.extract = void 0;
143124
+ exports.isArchive = exports.isZip = exports.isTar = exports.extract = void 0;
143125
143125
  const fs_1 = __webpack_require__(35747);
143126
143126
  const path_1 = __webpack_require__(85622);
143127
+ const uuid_1 = __webpack_require__(42277);
143127
143128
  const common_1 = __webpack_require__(51469);
143128
143129
  const debug_1 = __webpack_require__(36583);
143129
143130
  const pMap = __webpack_require__(81334);
143130
143131
  const AdmZip = __webpack_require__(55285);
143131
143132
  const tar = __webpack_require__(97998);
143132
- const { mkdir } = fs_1.promises;
143133
+ const { mkdir, rename } = fs_1.promises;
143133
143134
  const zipFormats = ['.zip', '.zipx'];
143134
143135
  const tarFormats = ['.tar', '.gz', '.tgz'];
143135
- async function handleExtraction(path, temporaryDir, childArchiveHandler) {
143136
- const extractionTarget = path_1.join(temporaryDir, path.includes(temporaryDir)
143137
- ? path_1.relative(temporaryDir, `${path}${common_1.EXTRACTED_DIR_SUFFIX}`)
143136
+ async function handleExtraction(path, temporaryDir, keepArchive, childArchiveHandler) {
143137
+ const extractionSource = keepArchive
143138
+ ? path
143139
+ : path_1.join(temporaryDir, common_1.DECOMPRESSING_IGNORE_DIR, `${uuid_1.v4()}-${path_1.basename(path)}`);
143140
+ if (!keepArchive) {
143141
+ await mkdir(path_1.dirname(extractionSource), { recursive: true });
143142
+ await rename(path, extractionSource);
143143
+ }
143144
+ const extractionTarget = path_1.join(temporaryDir, common_1.DECOMPRESSING_WORKSPACE_DIR, path.includes(temporaryDir)
143145
+ ? path_1.relative(path_1.join(temporaryDir, common_1.DECOMPRESSING_WORKSPACE_DIR), path)
143138
143146
  : path_1.basename(path));
143139
143147
  await mkdir(extractionTarget, { recursive: true });
143140
- if (isTar(path)) {
143148
+ if (isTar(extractionSource)) {
143141
143149
  await tar.x({
143142
- file: path,
143150
+ file: extractionSource,
143143
143151
  cwd: extractionTarget,
143144
143152
  sync: true,
143145
143153
  onentry: (entry) => {
@@ -143150,8 +143158,8 @@ async function handleExtraction(path, temporaryDir, childArchiveHandler) {
143150
143158
  },
143151
143159
  });
143152
143160
  }
143153
- else if (isZip(path)) {
143154
- const zip = new AdmZip(path);
143161
+ else if (isZip(extractionSource)) {
143162
+ const zip = new AdmZip(extractionSource);
143155
143163
  await pMap(zip.getEntries(), (entry) => {
143156
143164
  const childAbsolutePath = path_1.join(extractionTarget, entry.entryName);
143157
143165
  zip.extractEntryTo(entry.entryName, extractionTarget, true, true);
@@ -143168,7 +143176,8 @@ async function extract(archives, temporaryDir, depthLimit, depth = 0) {
143168
143176
  const childArchives = [];
143169
143177
  for (const archive of archives) {
143170
143178
  try {
143171
- await handleExtraction(archive, temporaryDir, (childArchive) => childArchives.push(childArchive));
143179
+ const keepArchive = 0 === depth;
143180
+ await handleExtraction(archive, temporaryDir, keepArchive, (childArchive) => childArchives.push(childArchive));
143172
143181
  }
143173
143182
  catch (err) {
143174
143183
  debug_1.debug(`Could not extract archive: ${archive} ${err}`);
@@ -143191,10 +143200,6 @@ function isArchive(path) {
143191
143200
  return isTar(path) || isZip(path);
143192
143201
  }
143193
143202
  exports.isArchive = isArchive;
143194
- function filterArchives(paths) {
143195
- return paths.filter((path) => isArchive(path));
143196
- }
143197
- exports.filterArchives = filterArchives;
143198
143203
  //# sourceMappingURL=extract.js.map
143199
143204
 
143200
143205
  /***/ }),
@@ -143210,16 +143215,22 @@ const fs_1 = __webpack_require__(35747);
143210
143215
  const path_1 = __webpack_require__(85622);
143211
143216
  const common_1 = __webpack_require__(51469);
143212
143217
  const debug_1 = __webpack_require__(36583);
143218
+ const extract_1 = __webpack_require__(18293);
143213
143219
  exports.readdir = fs_1.promises.readdir, exports.lstat = fs_1.promises.lstat;
143214
143220
  async function find(src) {
143215
- const result = [];
143221
+ const fileResults = [];
143222
+ const archiveResults = [];
143216
143223
  await traverse(src, async (path, stats) => {
143217
143224
  if (!common_1.isSupportedSize(stats.size)) {
143218
143225
  return;
143219
143226
  }
143220
- result.push(path);
143227
+ if (extract_1.isArchive(path)) {
143228
+ archiveResults.push(path);
143229
+ return;
143230
+ }
143231
+ fileResults.push(path);
143221
143232
  });
143222
- return result;
143233
+ return [fileResults, archiveResults];
143223
143234
  }
143224
143235
  exports.find = find;
143225
143236
  async function traverse(src, handle) {
@@ -143358,23 +143369,22 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
143358
143369
  exports.scan = void 0;
143359
143370
  const fs = __webpack_require__(35747);
143360
143371
  const path = __webpack_require__(85622);
143372
+ const path_1 = __webpack_require__(85622);
143361
143373
  const debug_1 = __webpack_require__(36583);
143362
143374
  const find_1 = __webpack_require__(75933);
143363
143375
  const hosted_git_info_1 = __webpack_require__(95238);
143364
143376
  const signatures_1 = __webpack_require__(47670);
143365
143377
  const git_1 = __webpack_require__(68361);
143366
143378
  const extract_1 = __webpack_require__(18293);
143367
- const common_1 = __webpack_require__(51469);
143368
143379
  const fs_1 = __webpack_require__(93689);
143380
+ const common_1 = __webpack_require__(51469);
143369
143381
  async function scan(options) {
143370
143382
  try {
143371
143383
  debug_1.debug.enabled = !!(options === null || options === void 0 ? void 0 : options.debug);
143372
143384
  debug_1.debug('options %o \n', options);
143373
- const extractionDepthLimit = options['--max-depth'] !== undefined
143374
- ? options['--max-depth']
143375
- : common_1.DEFAULT_DECOMPRESSING_DEPTH;
143385
+ const extractionDepthLimit = options['max-depth'] || 0;
143376
143386
  if (extractionDepthLimit < 0) {
143377
- throw 'invalid options: --max-depth should be a positive number.';
143387
+ throw 'invalid options: --max-depth should be greater than or equal to 0.';
143378
143388
  }
143379
143389
  if (!options.path) {
143380
143390
  throw 'invalid options: no path provided.';
@@ -143383,25 +143393,25 @@ async function scan(options) {
143383
143393
  throw `'${options.path}' does not exist.`;
143384
143394
  }
143385
143395
  const start = Date.now();
143386
- const paths = await find_1.find(options.path);
143387
- const archives = extract_1.filterArchives(paths);
143388
- let temporaryDir = null;
143389
- if (archives.length > 0) {
143390
- temporaryDir = await fs_1.createTemporaryDir();
143391
- await extract_1.extract(archives, temporaryDir, extractionDepthLimit);
143392
- paths.push(...(await find_1.find(temporaryDir)));
143393
- }
143394
- debug_1.debug('%d files found \n', paths.length);
143395
- const signatures = await signatures_1.computeSignaturesConcurrently(paths);
143396
+ const [filePaths, archivePaths] = await find_1.find(options.path);
143397
+ let extractionWorkspace = null;
143398
+ if (0 < extractionDepthLimit && 0 < archivePaths.length) {
143399
+ const temporaryDir = await fs_1.createTemporaryDir();
143400
+ extractionWorkspace = path_1.join(temporaryDir, common_1.DECOMPRESSING_WORKSPACE_DIR);
143401
+ await extract_1.extract(archivePaths, temporaryDir, extractionDepthLimit);
143402
+ const [newFilePaths, newArchivePaths] = await find_1.find(extractionWorkspace);
143403
+ filePaths.push(...newFilePaths, ...newArchivePaths);
143404
+ }
143405
+ else {
143406
+ filePaths.push(...archivePaths);
143407
+ }
143408
+ debug_1.debug('%d files found \n', filePaths.length);
143409
+ const signatures = await signatures_1.computeSignaturesConcurrently(filePaths);
143396
143410
  signatures.forEach((s) => {
143397
- if (temporaryDir && s.path.includes(temporaryDir)) {
143398
- s.path = path
143399
- .relative(temporaryDir, s.path)
143400
- .replace(new RegExp(common_1.EXTRACTED_DIR_SUFFIX, 'g'), '');
143401
- }
143402
- else {
143403
- s.path = path.relative(options.path, s.path);
143404
- }
143411
+ const src = extractionWorkspace && s.path.includes(extractionWorkspace)
143412
+ ? extractionWorkspace
143413
+ : options.path;
143414
+ s.path = path.relative(src, s.path);
143405
143415
  });
143406
143416
  const end = Date.now();
143407
143417
  const totalMilliseconds = end - start;