@coana-tech/cli 14.9.20 → 14.9.21

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.
Files changed (2) hide show
  1. package/cli.mjs +122 -7
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -212320,7 +212320,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
212320
212320
  }
212321
212321
 
212322
212322
  // dist/version.js
212323
- var version2 = "14.9.20";
212323
+ var version2 = "14.9.21";
212324
212324
 
212325
212325
  // ../../node_modules/.pnpm/axios@1.9.0/node_modules/axios/lib/helpers/bind.js
212326
212326
  function bind2(fn2, thisArg) {
@@ -215683,7 +215683,17 @@ async function scanForVulnerabilitiesSocketMode(dependencyTree) {
215683
215683
  const dependencyTreeNode = dependencyTree.transitiveDependencies[dependencyIdentifier];
215684
215684
  if (!dependencyTreeNode)
215685
215685
  throw new Error(`Dependency tree does not contain dependency ${simplePurlForComponent}`);
215686
- dependencyTreeNode.purl = c3.purl;
215686
+ dependencyTreeNode.purlObj = {
215687
+ type: c3.purl_type,
215688
+ namespace: c3.namespace ?? void 0,
215689
+ name: c3.name,
215690
+ version: c3.version ?? void 0,
215691
+ subpath: c3.subpath ?? void 0,
215692
+ artifactId: c3.artifactId ?? void 0,
215693
+ artifact_id: c3.artifact_id ?? void 0,
215694
+ qualifiers: c3.qualifiers ?? void 0,
215695
+ purlString: c3.purl
215696
+ };
215687
215697
  for (const vulnerability of c3.vulnerabilities) {
215688
215698
  vulnerabilities.push({
215689
215699
  url: vulnerability.ghsaId,
@@ -215801,6 +215811,112 @@ function getNamespaceAndName(ecosystem, packageName) {
215801
215811
  return { namespace: namespace2, name };
215802
215812
  }
215803
215813
 
215814
+ // dist/internal/socket-report.js
215815
+ function toSocketFacts(report, dependencyTrees) {
215816
+ const components = [];
215817
+ const purlToIndex = /* @__PURE__ */ new Map();
215818
+ for (const dependencyTree of dependencyTrees) {
215819
+ const depIdentifierToPurl = Object.fromEntries(Object.entries(dependencyTree.dependencyTree.transitiveDependencies).map(([depIdentifier, dep]) => {
215820
+ const purl = dep.purlObj.purlString;
215821
+ if (purl && !purlToIndex.has(purl)) {
215822
+ purlToIndex.set(purl, components.length);
215823
+ const depTreeNode = dependencyTree.dependencyTree.transitiveDependencies[depIdentifier];
215824
+ components[purlToIndex.get(purl)] = {
215825
+ id: purlToIndex.get(purl).toString(),
215826
+ type: depTreeNode.purlObj.type,
215827
+ name: depTreeNode.purlObj.name,
215828
+ version: depTreeNode.purlObj.version,
215829
+ namespace: depTreeNode.purlObj.namespace,
215830
+ subpath: depTreeNode.purlObj.subpath,
215831
+ artifact_id: depTreeNode.purlObj.artifact_id,
215832
+ artifactId: depTreeNode.purlObj.artifactId,
215833
+ qualifiers: depTreeNode.purlObj.qualifiers,
215834
+ // direct: false, // TODO: add direct flag
215835
+ // dev: false, // TODO: add dev flag
215836
+ dependencies: []
215837
+ };
215838
+ }
215839
+ return [depIdentifier, purl];
215840
+ }));
215841
+ for (const [depIdentifier, purl] of Object.entries(depIdentifierToPurl)) {
215842
+ const depTreeNode = dependencyTree.dependencyTree.transitiveDependencies[depIdentifier];
215843
+ const component = components[purlToIndex.get(purl)];
215844
+ depTreeNode.dependencies?.forEach((dep) => {
215845
+ const depPurl = depIdentifierToPurl[dep];
215846
+ const depIndex = purlToIndex.get(depPurl);
215847
+ if (!component.dependencies?.includes(depIndex.toString())) {
215848
+ component.dependencies.push(depIndex.toString());
215849
+ }
215850
+ });
215851
+ }
215852
+ }
215853
+ for (const vulnerability of report.vulnerabilities) {
215854
+ const component = components[purlToIndex.get(vulnerability.purl)];
215855
+ if (!component) {
215856
+ throw new Error(`Component not found for vulnerability ${vulnerability.purl}`);
215857
+ }
215858
+ if (!component.reachability) {
215859
+ component.reachability = [];
215860
+ }
215861
+ let reachabilityForGHSA = component.reachability?.find((r2) => r2.ghsa_id === vulnerability.vulnerabilityUrl.replace("https://github.com/advisories/", ""));
215862
+ if (!reachabilityForGHSA) {
215863
+ reachabilityForGHSA = {
215864
+ ghsa_id: vulnerability.vulnerabilityUrl.replace("https://github.com/advisories/", ""),
215865
+ reachability: []
215866
+ };
215867
+ component.reachability.push(reachabilityForGHSA);
215868
+ }
215869
+ reachabilityForGHSA.reachability.push({
215870
+ ...toSocketReachabilitySchema(vulnerability),
215871
+ workspacePath: vulnerability.workspacePath,
215872
+ subprojectPath: vulnerability.subprojectPath
215873
+ });
215874
+ }
215875
+ return {
215876
+ components
215877
+ };
215878
+ }
215879
+ function toSocketReachabilitySchema(vulnerability) {
215880
+ if (vulnerability.codeAwareScanResult.type === "missingVulnerabilityPattern") {
215881
+ return { type: "missing_support" };
215882
+ }
215883
+ if (vulnerability.codeAwareScanResult.type === "noAnalysisCheck") {
215884
+ return { type: "undeterminable_reachability" };
215885
+ }
215886
+ if (vulnerability.codeAwareScanResult.type === "analysisError") {
215887
+ return { type: "error", error: vulnerability.codeAwareScanResult.message };
215888
+ }
215889
+ if (vulnerability.codeAwareScanResult.type === "otherError") {
215890
+ return { type: "error", error: vulnerability.codeAwareScanResult.message };
215891
+ }
215892
+ if (vulnerability.codeAwareScanResult.type === "success") {
215893
+ if (Array.isArray(vulnerability.codeAwareScanResult.detectedOccurrences)) {
215894
+ if (vulnerability.codeAwareScanResult.detectedOccurrences.length === 0) {
215895
+ return { type: "unreachable" };
215896
+ }
215897
+ throw new Error("Detected occurrences is an array with elements. This is a bug.");
215898
+ }
215899
+ const detOccWithStacks = vulnerability.codeAwareScanResult.detectedOccurrences;
215900
+ if (detOccWithStacks.stacks.length === 0) {
215901
+ return { type: "unreachable" };
215902
+ }
215903
+ if (detOccWithStacks.analysisLevel === "function-level") {
215904
+ return {
215905
+ type: "reachable",
215906
+ analysisLevel: detOccWithStacks.analysisLevel,
215907
+ matches: detOccWithStacks.stacks
215908
+ };
215909
+ } else if (detOccWithStacks.analysisLevel === "class-level") {
215910
+ return {
215911
+ type: "reachable",
215912
+ analysisLevel: detOccWithStacks.analysisLevel,
215913
+ matches: detOccWithStacks.stacks
215914
+ };
215915
+ }
215916
+ }
215917
+ throw new Error("Unknown codeAwareScanResult type");
215918
+ }
215919
+
215804
215920
  // dist/cli-core.js
215805
215921
  var { omit, partition, pick } = import_lodash15.default;
215806
215922
  var CliCore = class {
@@ -215936,10 +216052,7 @@ var CliCore = class {
215936
216052
  if (!this.reportDependencyTrees) {
215937
216053
  throw new Error("Dependency trees should be available when using --socket-mode");
215938
216054
  }
215939
- const socketReport = {
215940
- ...report,
215941
- dependencyTrees: this.reportDependencyTrees
215942
- };
216055
+ const socketReport = toSocketFacts(report, this.reportDependencyTrees);
215943
216056
  const outputFile = resolve24(this.options.socketMode);
215944
216057
  await writeFile10(outputFile, JSON.stringify(socketReport, null, 2));
215945
216058
  logger.info(kleur_default.green(`Socket report written to: ${outputFile}`));
@@ -216278,7 +216391,9 @@ var CliCore = class {
216278
216391
  packageVersion: vulnerableNode.version ?? "",
216279
216392
  ecosystem: v.ecosystem ?? "NPM",
216280
216393
  dependencyType,
216281
- reachability
216394
+ reachability,
216395
+ purl: v.purl,
216396
+ purlType: v.purlType
216282
216397
  };
216283
216398
  });
216284
216399
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.9.20",
3
+ "version": "14.9.21",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {