@coana-tech/cli 14.12.117 → 14.12.119

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.12.117",
3
+ "version": "14.12.119",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -110326,34 +110326,13 @@ function convertToArtifactForInstallation(dep) {
110326
110326
  }
110327
110327
 
110328
110328
  // dist/whole-program-code-aware-vulnerability-scanner/js/heuristics.js
110329
+ var largeIndirectionBoundOptions = {
110330
+ maxIndirections: 1024
110331
+ };
110329
110332
  var AllPackagesHeuristic = {
110330
110333
  // Analyzing all packages disregarding what vulnerabilities affect the project being analyzed
110331
110334
  name: "ALL_PACKAGES",
110332
- getOptions: getAllPackagesHeuristicOptions,
110333
- splitAnalysisInBuckets: false
110334
- };
110335
- var DefaultOptionsHeuristic = {
110336
- // Analyzing all packages disregarding what vulnerabilities affect the project being analyzed
110337
- name: "DEFAULT_OPTIONS",
110338
- getOptions: () => ({}),
110339
- splitAnalysisInBuckets: false
110340
- };
110341
- var MaxRounds2Heuristic = {
110342
- // Analyzing all packages disregarding what vulnerabilities affect the project being analyzed and limiting the number of rounds to 3
110343
- name: "MAX_ROUNDS_2",
110344
- getOptions: () => getMaxRoundsHeuristicOptions(2),
110345
- splitAnalysisInBuckets: false
110346
- };
110347
- var MaxRounds3Heuristic = {
110348
- // Analyzing all packages disregarding what vulnerabilities affect the project being analyzed and limiting the number of rounds to 3
110349
- name: "MAX_ROUNDS_3",
110350
- getOptions: () => getMaxRoundsHeuristicOptions(3),
110351
- splitAnalysisInBuckets: false
110352
- };
110353
- var MaxRounds5Heuristic = {
110354
- // Analyzing all packages disregarding what vulnerabilities affect the project being analyzed and limiting the number of rounds to 5
110355
- name: "MAX_ROUNDS_5",
110356
- getOptions: () => getMaxRoundsHeuristicOptions(5),
110335
+ getOptions: () => largeIndirectionBoundOptions,
110357
110336
  splitAnalysisInBuckets: false
110358
110337
  };
110359
110338
  var OnlyVulnPathPackagesExceptVulnerablePackageHeuristic = {
@@ -110362,37 +110341,10 @@ var OnlyVulnPathPackagesExceptVulnerablePackageHeuristic = {
110362
110341
  getOptions: getOnlyPackagesInVulnPathsWithoutLeafPackagesHeuristicOptions,
110363
110342
  splitAnalysisInBuckets: true
110364
110343
  };
110365
- var OnlyVulnPathPackagesExceptVulnerablePackageAndMaxRounds2Heuristic = {
110366
- // Analyzing only packages that are in the path of the vulnerabilities being analyzed and limiting the number of rounds to 2
110367
- name: "ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE_AND_MAX_ROUNDS_2",
110368
- getOptions: (vulnerabilities) => ({
110369
- ...getOnlyPackagesInVulnPathsWithoutLeafPackagesHeuristicOptions(vulnerabilities),
110370
- ...getMaxRoundsHeuristicOptions(2)
110371
- }),
110372
- splitAnalysisInBuckets: true
110373
- };
110374
- var OnlyVulnPathPackagesExceptVulnerablePackageAndMaxRounds3Heuristic = {
110375
- // Analyzing only packages that are in the path of the vulnerabilities being analyzed and limiting the number of rounds to 3
110376
- name: "ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE_AND_MAX_ROUNDS_3",
110377
- getOptions: (vulnerabilities) => ({
110378
- ...getOnlyPackagesInVulnPathsWithoutLeafPackagesHeuristicOptions(vulnerabilities),
110379
- ...getMaxRoundsHeuristicOptions(3)
110380
- }),
110381
- splitAnalysisInBuckets: true
110382
- };
110383
- var OnlyVulnPathPackagesExceptVulnerablePackageAndMaxRounds8Heuristic = {
110384
- // Analyzing only packages that are in the path of the vulnerabilities being analyzed and limiting the number of rounds to 8
110385
- name: "ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE_AND_MAX_ROUNDS_8",
110386
- getOptions: (vulnerabilities) => ({
110387
- ...getOnlyPackagesInVulnPathsWithoutLeafPackagesHeuristicOptions(vulnerabilities),
110388
- ...getMaxRoundsHeuristicOptions(8)
110389
- }),
110390
- splitAnalysisInBuckets: true
110391
- };
110392
- var IgnoreDependenciesAndMaxRounds3Heuristic = {
110344
+ var IgnoreDependenciesAndMaxIndirections3Heuristic = {
110393
110345
  name: "IGNORE_DEPENDENCIES_AND_MAX_ROUNDS_3",
110394
- getOptions: () => ({ includePackages: ["some_non_existing_package"], ...getMaxRoundsHeuristicOptions(3) }),
110395
110346
  // This heuristic will ignore all dependencies, but we need to provide a package name to have a value for the --include-packages option
110347
+ getOptions: () => ({ includePackages: ["some_non_existing_package"], ...getMaxIndirectionsHeuristicOptions(3) }),
110396
110348
  splitAnalysisInBuckets: false
110397
110349
  };
110398
110350
  var ImportReachabilityHeuristic = {
@@ -110403,33 +110355,22 @@ var ImportReachabilityHeuristic = {
110403
110355
  };
110404
110356
  var heuristics = {
110405
110357
  ALL_PACKAGES: AllPackagesHeuristic,
110406
- DEFAULT_OPTIONS: DefaultOptionsHeuristic,
110407
- MAX_ROUNDS_2: MaxRounds2Heuristic,
110408
- MAX_ROUNDS_3: MaxRounds3Heuristic,
110409
- MAX_ROUNDS_5: MaxRounds5Heuristic,
110410
110358
  ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE: OnlyVulnPathPackagesExceptVulnerablePackageHeuristic,
110411
- ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE_AND_MAX_ROUNDS_2: OnlyVulnPathPackagesExceptVulnerablePackageAndMaxRounds2Heuristic,
110412
- ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE_AND_MAX_ROUNDS_3: OnlyVulnPathPackagesExceptVulnerablePackageAndMaxRounds3Heuristic,
110413
- ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE_AND_MAX_ROUNDS_8: OnlyVulnPathPackagesExceptVulnerablePackageAndMaxRounds8Heuristic,
110414
110359
  createIncludePackagesHeuristic: (packageNames, options) => ({
110415
110360
  // Create a heuristic for only analyzing the packages in the packageNames array
110416
110361
  name: `INCLUDE_PACKAGES_${packageNames.join("_")}`,
110417
110362
  getOptions: () => ({ ...options, includePackages: packageNames }),
110418
110363
  splitAnalysisInBuckets: true
110419
110364
  }),
110420
- IGNORE_DEPENDENCIES_AND_MAX_ROUNDS_3: IgnoreDependenciesAndMaxRounds3Heuristic,
110365
+ IGNORE_DEPENDENCIES_AND_MAX_ROUNDS_3: IgnoreDependenciesAndMaxIndirections3Heuristic,
110421
110366
  IMPORT_REACHABILITY: ImportReachabilityHeuristic
110422
110367
  };
110423
- function getAllPackagesHeuristicOptions() {
110424
- return {};
110425
- }
110426
- function getMaxRoundsHeuristicOptions(maxRounds) {
110427
- return {
110428
- maxIndirections: maxRounds
110429
- };
110368
+ function getMaxIndirectionsHeuristicOptions(maxIndirections) {
110369
+ return { maxIndirections };
110430
110370
  }
110431
110371
  function getOnlyPackagesInVulnPathsWithoutLeafPackagesHeuristicOptions(vulnerabilities) {
110432
110372
  return {
110373
+ ...largeIndirectionBoundOptions,
110433
110374
  includePackages: computePackagesOnVulnPath(vulnerabilities)
110434
110375
  };
110435
110376
  }
@@ -110640,7 +110581,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
110640
110581
  }) ?? []
110641
110582
  };
110642
110583
  }
110643
- static async runOnAlreadyDownloadedPackages(packages, vulnerability, reachabilityAnalysisOptions, baseHeuristic = heuristics.DEFAULT_OPTIONS) {
110584
+ static async runOnAlreadyDownloadedPackages(packages, vulnerability, reachabilityAnalysisOptions, baseHeuristic = heuristics.ALL_PACKAGES) {
110644
110585
  return await withTmpDirectory("runOnAlreadyDownloadedPackagesNpm", async (tmpDir) => {
110645
110586
  const nodeModulesDir = join14(tmpDir, "node_modules");
110646
110587
  await mkdir8(nodeModulesDir);
@@ -110682,7 +110623,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
110682
110623
  };
110683
110624
  });
110684
110625
  }
110685
- static async runOnDependencyChain(dependencyChain, vulnerability, reachabilityAnalysisOptions, baseHeuristic = heuristics.DEFAULT_OPTIONS) {
110626
+ static async runOnDependencyChain(dependencyChain, vulnerability, reachabilityAnalysisOptions, baseHeuristic = heuristics.ALL_PACKAGES) {
110686
110627
  const [first2, ...rest] = dependencyChain;
110687
110628
  const packageJSONContent = buildPackageJSONForDependencyChain(first2, rest);
110688
110629
  const tmpDir = mkdtempSync(join14(tmpdir3(), "run-on-dependency-chain"));
@@ -111618,7 +111559,7 @@ async function analyzeAlreadyInstalledPackages(ecosystem, packages, vulnerabilit
111618
111559
  return { analysis: { name: analysisName, version: await getCurrentCommitHash(analysisName.toLowerCase()) }, result };
111619
111560
  }
111620
111561
  async function runWithJSHeuristics(cb) {
111621
- const orderedHeuristics = [heuristics.DEFAULT_OPTIONS, heuristics.MAX_ROUNDS_3, heuristics.MAX_ROUNDS_2];
111562
+ const orderedHeuristics = [heuristics.ALL_PACKAGES];
111622
111563
  let result;
111623
111564
  for (const heuristic of orderedHeuristics) {
111624
111565
  result = await cb(heuristic);
@@ -112485,6 +112426,11 @@ async function analyzeWithHeuristics(state, vulns, heuristicsInOrder, doNotRecom
112485
112426
  heuristicName: bucket.heuristicName,
112486
112427
  vulnUrls: bucket.vulnUrls.filter((vulnUrl) => vulnUrls.includes(vulnUrl))
112487
112428
  })).filter((bucket) => bucket.vulnUrls.length > 0);
112429
+ for (const { heuristicName } of newBuckets)
112430
+ if (!getHeuristicFromName(state, heuristicName, ecosystem)) {
112431
+ logger.warn(`Could not find heuristic with name ${heuristicName} - ignoring cached buckets.`);
112432
+ return void 0;
112433
+ }
112488
112434
  const vulnUrlToPackageName = Object.fromEntries(vulnerabilities.map((v) => [v.url, v.dependency]));
112489
112435
  const vulnsNotInBucket = vulnerabilities.filter((v) => !newBuckets.some((b) => b.vulnUrls.includes(v.url)));
112490
112436
  for (const newVuln of vulnsNotInBucket) {
@@ -112915,11 +112861,7 @@ var NpmAnalyzer = class {
112915
112861
  }
112916
112862
  }
112917
112863
  async runReachabilityAnalysis(vulns, analysisMetadataCollector, statusUpdater) {
112918
- const heuristicsInOrder = this.state.otherAnalysisOptions.lightweightReachability ? [heuristics.IGNORE_DEPENDENCIES_AND_MAX_ROUNDS_3] : [
112919
- heuristics.ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE,
112920
- heuristics.ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE_AND_MAX_ROUNDS_3,
112921
- heuristics.ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE_AND_MAX_ROUNDS_2
112922
- ];
112864
+ const heuristicsInOrder = this.state.otherAnalysisOptions.lightweightReachability ? [heuristics.IGNORE_DEPENDENCIES_AND_MAX_ROUNDS_3] : [heuristics.ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE];
112923
112865
  const nodeModulesAlreadyExisted = existsSync13(resolve21(this.state.subprojectDir, "node_modules"));
112924
112866
  this.preinstalledDependencies = nodeModulesAlreadyExisted ? "YES" : "NO";
112925
112867
  const wrappedCollector = (metadata) => {