snyk 1.893.0 → 1.896.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.
@@ -5603,14 +5603,11 @@ async function analyzeBundle(options) {
5603
5603
  }
5604
5604
  exports.analyzeBundle = analyzeBundle;
5605
5605
  function normalizeResultFiles(files, baseDir) {
5606
- if (baseDir) {
5607
- return Object.entries(files).reduce((obj, [path, positions]) => {
5608
- const filePath = (0, files_1.resolveBundleFilePath)(baseDir, path);
5609
- obj[filePath] = positions;
5610
- return obj;
5611
- }, {});
5612
- }
5613
- return files;
5606
+ return Object.entries(files).reduce((obj, [path, positions]) => {
5607
+ const filePath = (0, files_1.resolveBundleFilePath)(baseDir, path);
5608
+ obj[filePath] = positions;
5609
+ return obj;
5610
+ }, {});
5614
5611
  }
5615
5612
  async function analyzeFolders(options) {
5616
5613
  if (!options.connection.requestId) {
@@ -5940,6 +5937,7 @@ async function createBundleFromFolders(options) {
5940
5937
  ]);
5941
5938
  emitter_1.emitter.scanFilesProgress(0);
5942
5939
  const bundleFiles = [];
5940
+ const skippedOversizedFiles = [];
5943
5941
  let totalFiles = 0;
5944
5942
  const bundleFileCollector = (0, files_1.collectBundleFiles)({
5945
5943
  ...(0, lodash_pick_1.default)(options, ['paths', 'symlinksEnabled']),
@@ -5948,7 +5946,7 @@ async function createBundleFromFolders(options) {
5948
5946
  supportedFiles,
5949
5947
  });
5950
5948
  for await (const f of bundleFileCollector) {
5951
- bundleFiles.push(f);
5949
+ typeof f == 'string' ? skippedOversizedFiles.push(f) : bundleFiles.push(f);
5952
5950
  totalFiles += 1;
5953
5951
  emitter_1.emitter.scanFilesProgress(totalFiles);
5954
5952
  }
@@ -5968,6 +5966,7 @@ async function createBundleFromFolders(options) {
5968
5966
  baseDir,
5969
5967
  supportedFiles,
5970
5968
  fileIgnores,
5969
+ skippedOversizedFiles,
5971
5970
  };
5972
5971
  }
5973
5972
  exports.createBundleFromFolders = createBundleFromFolders;
@@ -6399,6 +6398,7 @@ async function* searchFiles(patterns, cwd, symlinksEnabled, ignores) {
6399
6398
  }
6400
6399
  /**
6401
6400
  * Returns bundle files from requested paths
6401
+ * If a file exceeds the maximum file size, it returns a string with its path
6402
6402
  * */
6403
6403
  async function* collectBundleFiles({ symlinksEnabled = false, baseDir, fileIgnores, paths, supportedFiles, }) {
6404
6404
  const cache = new cache_1.Cache(constants_1.CACHE_KEY, baseDir);
@@ -6411,8 +6411,8 @@ async function* collectBundleFiles({ symlinksEnabled = false, baseDir, fileIgnor
6411
6411
  // Check if symlink and exclude if requested
6412
6412
  if (!fileStats || (fileStats.isSymbolicLink() && !symlinksEnabled))
6413
6413
  continue;
6414
- if (fileStats.isFile() && fileStats.size <= constants_1.MAX_FILE_SIZE) {
6415
- files.push(path);
6414
+ if (fileStats.isFile()) {
6415
+ fileStats.size <= constants_1.MAX_FILE_SIZE ? files.push(path) : yield path;
6416
6416
  }
6417
6417
  else if (fileStats.isDirectory()) {
6418
6418
  dirs.push(path);
@@ -6426,8 +6426,8 @@ async function* collectBundleFiles({ symlinksEnabled = false, baseDir, fileIgnor
6426
6426
  for await (const filePath of searcher) {
6427
6427
  const fileInfo = await getFileInfo(filePath.toString(), baseDir, false, cache);
6428
6428
  // dc ignore AttrAccessOnNull: false positive, there is a precondition with &&
6429
- if (fileInfo && fileInfo.size <= constants_1.MAX_FILE_SIZE) {
6430
- yield fileInfo;
6429
+ if (fileInfo) {
6430
+ fileInfo.size <= constants_1.MAX_FILE_SIZE ? yield fileInfo : yield fileInfo.bundlePath;
6431
6431
  }
6432
6432
  }
6433
6433
  }
@@ -6437,8 +6437,8 @@ async function* collectBundleFiles({ symlinksEnabled = false, baseDir, fileIgnor
6437
6437
  for await (const filePath of searcher) {
6438
6438
  const fileInfo = await getFileInfo(filePath.toString(), baseDir, false, cache);
6439
6439
  // dc ignore AttrAccessOnNull: false positive, there is a precondition with &&
6440
- if (fileInfo && fileInfo.size <= constants_1.MAX_FILE_SIZE) {
6441
- yield fileInfo;
6440
+ if (fileInfo) {
6441
+ fileInfo.size <= constants_1.MAX_FILE_SIZE ? yield fileInfo : yield fileInfo.bundlePath;
6442
6442
  }
6443
6443
  }
6444
6444
  }
@@ -6556,7 +6556,10 @@ function resolveBundleFilePath(baseDir, bundleFilePath) {
6556
6556
  if (isWindows) {
6557
6557
  relPath = relPath.replace(/\//g, '\\');
6558
6558
  }
6559
- return nodePath.resolve(baseDir, decodeURI(relPath));
6559
+ if (baseDir) {
6560
+ return nodePath.resolve(baseDir, decodeURI(relPath));
6561
+ }
6562
+ return decodeURI(relPath);
6560
6563
  }
6561
6564
  exports.resolveBundleFilePath = resolveBundleFilePath;
6562
6565
  function* composeFilePayloads(files, bucketSize = constants_1.MAX_PAYLOAD) {
@@ -6860,7 +6863,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
6860
6863
  return result;
6861
6864
  };
6862
6865
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6863
- exports.getIpFamily = exports.checkSession = exports.startSession = exports.getAnalysis = exports.AnalysisSeverity = exports.constants = exports.emitter = exports.extendAnalysis = exports.createBundleFromFolders = exports.analyzeFolders = exports.getGlobPatterns = void 0;
6866
+ exports.getIpFamily = exports.checkSession = exports.startSession = exports.getAnalysis = exports.AnalysisSeverity = exports.constants = exports.MAX_FILE_SIZE = exports.emitter = exports.extendAnalysis = exports.createBundleFromFolders = exports.analyzeFolders = exports.getGlobPatterns = void 0;
6864
6867
  const analysis_1 = __webpack_require__(54151);
6865
6868
  Object.defineProperty(exports, "analyzeFolders", ({ enumerable: true, get: function () { return analysis_1.analyzeFolders; } }));
6866
6869
  Object.defineProperty(exports, "extendAnalysis", ({ enumerable: true, get: function () { return analysis_1.extendAnalysis; } }));
@@ -6873,6 +6876,8 @@ Object.defineProperty(exports, "startSession", ({ enumerable: true, get: functio
6873
6876
  Object.defineProperty(exports, "checkSession", ({ enumerable: true, get: function () { return http_1.checkSession; } }));
6874
6877
  Object.defineProperty(exports, "getAnalysis", ({ enumerable: true, get: function () { return http_1.getAnalysis; } }));
6875
6878
  Object.defineProperty(exports, "getIpFamily", ({ enumerable: true, get: function () { return http_1.getIpFamily; } }));
6879
+ const constants_1 = __webpack_require__(65765);
6880
+ Object.defineProperty(exports, "MAX_FILE_SIZE", ({ enumerable: true, get: function () { return constants_1.MAX_FILE_SIZE; } }));
6876
6881
  const constants = __importStar(__webpack_require__(65765));
6877
6882
  exports.constants = constants;
6878
6883
  const files_1 = __webpack_require__(32083);
@@ -154685,15 +154690,24 @@ async function scan(options) {
154685
154690
  }
154686
154691
  exports.scan = scan;
154687
154692
  function getExcludedPatterns(projectRoot, policyFilePath = path_1.join(projectRoot, invariants_1.DEFAULT_SNYK_POLICY_FILE)) {
154688
- var _a;
154693
+ var _a, _b;
154689
154694
  if (!dotSnyk.exists(policyFilePath)) {
154690
154695
  return [];
154691
154696
  }
154692
154697
  const config = dotSnyk.parse(policyFilePath);
154693
- return [
154694
- policyFilePath,
154695
- ...dotSnyk.toAbsolutePaths(projectRoot, (_a = config === null || config === void 0 ? void 0 : config.exclude) === null || _a === void 0 ? void 0 : _a.global),
154696
- ];
154698
+ const paths = (_b = (_a = config === null || config === void 0 ? void 0 : config.exclude) === null || _a === void 0 ? void 0 : _a.global) === null || _b === void 0 ? void 0 : _b.filter((item) => {
154699
+ if (typeof item === 'object') {
154700
+ const key = Object.keys(item)[0];
154701
+ return !key ? false : !dotSnyk.hasExpired(item[key].expires);
154702
+ }
154703
+ return true;
154704
+ }).map((item) => {
154705
+ if (typeof item === 'object') {
154706
+ return Object.keys(item)[0];
154707
+ }
154708
+ return item;
154709
+ });
154710
+ return [policyFilePath, ...dotSnyk.toAbsolutePaths(projectRoot, paths)];
154697
154711
  }
154698
154712
  exports.getExcludedPatterns = getExcludedPatterns;
154699
154713
  //# sourceMappingURL=scan.js.map
@@ -154744,7 +154758,7 @@ exports.isBinary = isBinary;
154744
154758
  "use strict";
154745
154759
 
154746
154760
  Object.defineProperty(exports, "__esModule", ({ value: true }));
154747
- exports.toAbsolutePaths = exports.parse = exports.exists = void 0;
154761
+ exports.hasExpired = exports.toAbsolutePaths = exports.parse = exports.exists = void 0;
154748
154762
  const fs_1 = __webpack_require__(35747);
154749
154763
  const yaml_1 = __webpack_require__(6792);
154750
154764
  const path_1 = __webpack_require__(85622);
@@ -154776,6 +154790,21 @@ function toAbsolutePaths(basedir, paths = []) {
154776
154790
  return paths.map((p) => path_1.resolve(basedir, p));
154777
154791
  }
154778
154792
  exports.toAbsolutePaths = toAbsolutePaths;
154793
+ /**
154794
+ * Resolves an array of paths relative to the basedir
154795
+ * @param {string} expires - date string
154796
+ * @returns {boolean} - whether or not the provided date has expired
154797
+ */
154798
+ function hasExpired(expires) {
154799
+ if (expires === null || expires === undefined) {
154800
+ return false;
154801
+ }
154802
+ if (isNaN(Date.parse(expires))) {
154803
+ throw `Invalid date format provided dates should be formatted as "yyyy-MM-ddTHH:mm:ss.fffZ"`;
154804
+ }
154805
+ return new Date() > new Date(expires);
154806
+ }
154807
+ exports.hasExpired = hasExpired;
154779
154808
  //# sourceMappingURL=index.js.map
154780
154809
 
154781
154810
  /***/ }),