@coana-tech/cli 14.12.50 → 14.12.51

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/cli.mjs CHANGED
@@ -219383,30 +219383,32 @@ function toSocketFacts(report, dependencyTrees, subPjToWsPathToDirectDependencie
219383
219383
  };
219384
219384
  }
219385
219385
  function toSocketReachabilitySchema(vulnerability) {
219386
- if (vulnerability.codeAwareScanResult.type === "missingVulnerabilityPattern") {
219386
+ const codeAwareScanResult = vulnerability.codeAwareScanResult;
219387
+ if (codeAwareScanResult.type === "missingVulnerabilityPattern") {
219387
219388
  return { type: "missing_support" };
219388
219389
  }
219389
- if (vulnerability.codeAwareScanResult.type === "noAnalysisCheck") {
219390
+ if (codeAwareScanResult.type === "noAnalysisCheck") {
219390
219391
  return { type: "undeterminable_reachability" };
219391
219392
  }
219392
- if (vulnerability.codeAwareScanResult.type === "analysisError") {
219393
- return { type: "error", error: vulnerability.codeAwareScanResult.message };
219393
+ if (codeAwareScanResult.type === "analysisError") {
219394
+ return { type: "error", error: codeAwareScanResult.message };
219394
219395
  }
219395
- if (vulnerability.codeAwareScanResult.type === "otherError") {
219396
- if (vulnerability.codeAwareScanResult.message.includes("Reachability analysis for languages using"))
219396
+ if (codeAwareScanResult.type === "otherError") {
219397
+ if (codeAwareScanResult.message.includes("Reachability analysis for languages using"))
219397
219398
  return { type: "unknown" };
219398
- return { type: "error", error: vulnerability.codeAwareScanResult.message };
219399
+ return { type: "error", error: codeAwareScanResult.message };
219399
219400
  }
219400
- if (vulnerability.codeAwareScanResult.type === "success") {
219401
- if (Array.isArray(vulnerability.codeAwareScanResult.detectedOccurrences)) {
219402
- if (vulnerability.codeAwareScanResult.detectedOccurrences.length === 0) {
219403
- return { type: "unreachable" };
219401
+ if (codeAwareScanResult.type === "success") {
219402
+ const affectedPurls = codeAwareScanResult.affectedPurls;
219403
+ if (Array.isArray(codeAwareScanResult.detectedOccurrences)) {
219404
+ if (codeAwareScanResult.detectedOccurrences.length === 0) {
219405
+ return { type: "unreachable", affectedPurls };
219404
219406
  }
219405
219407
  throw new Error("Detected occurrences is an array with elements. This is a bug.");
219406
219408
  }
219407
- const detOccWithStacks = vulnerability.codeAwareScanResult.detectedOccurrences;
219409
+ const detOccWithStacks = codeAwareScanResult.detectedOccurrences;
219408
219410
  if (detOccWithStacks.stacks.length === 0) {
219409
- return { type: "unreachable" };
219411
+ return { type: "unreachable", affectedPurls };
219410
219412
  }
219411
219413
  const shouldTruncate = detOccWithStacks.stacks.length > MAX_STACKS_TO_SEND;
219412
219414
  if (shouldTruncate) {
@@ -234350,7 +234352,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
234350
234352
  }
234351
234353
 
234352
234354
  // dist/version.js
234353
- var version2 = "14.12.50";
234355
+ var version2 = "14.12.51";
234354
234356
 
234355
234357
  // dist/cli-core.js
234356
234358
  var { mapValues, omit, partition, pick } = import_lodash15.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.12.50",
3
+ "version": "14.12.51",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -76734,6 +76734,37 @@ function getPurlType(ecosystem) {
76734
76734
  throw Error(`Unsupported ecosystem: ${ecosystem}`);
76735
76735
  }
76736
76736
  }
76737
+ function getNamespaceAndName(ecosystem, packageName) {
76738
+ let namespace2 = "";
76739
+ let name2 = "";
76740
+ switch (ecosystem) {
76741
+ case "NPM":
76742
+ if (packageName.includes("/")) [namespace2, name2] = packageName.split("/", 2);
76743
+ else name2 = packageName;
76744
+ break;
76745
+ case "MAVEN":
76746
+ if (packageName.includes(":")) [namespace2, name2] = packageName.split(":", 2);
76747
+ else name2 = packageName;
76748
+ break;
76749
+ case "PIP":
76750
+ name2 = packageName;
76751
+ break;
76752
+ default:
76753
+ name2 = packageName;
76754
+ }
76755
+ return { namespace: namespace2, name: name2 };
76756
+ }
76757
+ function affectedJSPackagesToPurl(packages) {
76758
+ return packages.map((pkg) => {
76759
+ const { namespace: namespace2, name: name2 } = getNamespaceAndName("NPM", pkg.name);
76760
+ return {
76761
+ type: "npm" /* NPM */,
76762
+ ...namespace2 && { namespace: namespace2 },
76763
+ name: name2,
76764
+ version: pkg.version
76765
+ };
76766
+ });
76767
+ }
76737
76768
 
76738
76769
  // ../utils/src/dashboard-api/socket-api.ts
76739
76770
  var axios2 = getAxiosClient();
@@ -104044,6 +104075,7 @@ async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reac
104044
104075
  const diagnosticsFile = resolve11(tmpFolder, "diagnostics.json");
104045
104076
  const matchesFile = resolve11(tmpFolder, "matches.json");
104046
104077
  const callStackFile = resolve11(tmpFolder, "call-stacks.json");
104078
+ const affectedPackagesFile = resolve11(tmpFolder, "affected-packages.json");
104047
104079
  const logFile = reachabilityAnalysisOptions.analysisLogFile ?? (reachabilityAnalysisOptions.printLogFile && resolve11(projectRoot, "js-analysis.log"));
104048
104080
  await writeFile5(vulnerabilitiesFile, JSON.stringify(vulnerabilitiesInJellyFormat));
104049
104081
  let excludeEntries;
@@ -104062,6 +104094,8 @@ async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reac
104062
104094
  "" + (reachabilityAnalysisOptions.timeoutInSeconds ?? 60),
104063
104095
  "--vulnerabilities",
104064
104096
  vulnerabilitiesFile,
104097
+ "--reachable-packages-file",
104098
+ affectedPackagesFile,
104065
104099
  ...excludeEntries ? ["--exclude-entries", ...excludeEntries] : [],
104066
104100
  "--diagnostics-json",
104067
104101
  diagnosticsFile,
@@ -104102,9 +104136,12 @@ async function runJellyAnalysis(mainProjectRoot, projectRoot, jellyOptions, reac
104102
104136
  } else
104103
104137
  matches[vulnerability.osv.url] = transformedStacks;
104104
104138
  }
104139
+ const affectedPackages = JSON.parse(await readFile7(affectedPackagesFile, "utf-8"));
104140
+ const affectedPurls = affectedJSPackagesToPurl(affectedPackages);
104105
104141
  return {
104106
104142
  matches,
104107
- analysisDiagnostics
104143
+ analysisDiagnostics,
104144
+ affectedPurls
104108
104145
  };
104109
104146
  } finally {
104110
104147
  await rm2(tmpFolder, { recursive: true });
@@ -104178,6 +104215,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
104178
104215
  diagnostics,
104179
104216
  terminatedEarly: diagnostics.aborted || diagnostics.timeout,
104180
104217
  reachedDependencies: diagnostics.packages > 0,
104218
+ affectedPurls: analysisRes.affectedPurls,
104181
104219
  computeDetectedOccurrences: ({ url: url2 }) => transformSourceLocations3(matches[url2] ?? [])
104182
104220
  };
104183
104221
  } catch (e) {
@@ -106696,6 +106734,7 @@ function augmentVulnsWithDetectedOccurrences(vulns, codeAwareScanner, heuristic,
106696
106734
  type: "success",
106697
106735
  terminatedEarly: result.terminatedEarly,
106698
106736
  heuristicName: heuristic.name,
106737
+ affectedPurls: result.affectedPurls,
106699
106738
  detectedOccurrences
106700
106739
  };
106701
106740
  }