@coana-tech/cli 14.9.19 → 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 +151 -63
  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.19";
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) {
@@ -215677,22 +215677,36 @@ async function scanForVulnerabilitiesSocketMode(dependencyTree) {
215677
215677
  let simplePurlForComponent = simplePurl(c3.purl_type, c3.namespace, c3.name, c3.version);
215678
215678
  if (!(simplePurlForComponent in purlStringsToIdentifier))
215679
215679
  simplePurlForComponent = simplePurl(c3.purl_type, c3.namespace, c3.name, null);
215680
- const dependencyIdentifier = purlStringsToIdentifier[simplePurlForComponent];
215681
- dependencyIdentifiersNotFound.delete(dependencyIdentifier);
215682
- const dependencyTreeNode = dependencyTree.transitiveDependencies[dependencyIdentifier];
215683
- if (!dependencyTreeNode)
215684
- throw new Error(`Dependency tree does not contain dependency ${simplePurlForComponent}`);
215685
- dependencyTreeNode.purl = c3.purl;
215686
- for (const vulnerability of c3.vulnerabilities) {
215687
- vulnerabilities.push({
215688
- url: vulnerability.ghsaId,
215689
- range: vulnerability.range,
215690
- name: dependencyTreeNode.packageName,
215691
- dependency: dependencyTreeNode.packageName,
215692
- vulnChainDetails: computeVulnChainDetails(dependencyTree, dependencyIdentifier, parentsMap),
215693
- vulnerabilityAccessPaths: vulnerability.reachabilityData?.pattern,
215694
- ecosystem: dependencyTree.ecosystem
215695
- });
215680
+ const dependencyIdentifiers = purlStringsToIdentifier[simplePurlForComponent];
215681
+ for (const dependencyIdentifier of dependencyIdentifiers) {
215682
+ dependencyIdentifiersNotFound.delete(dependencyIdentifier);
215683
+ const dependencyTreeNode = dependencyTree.transitiveDependencies[dependencyIdentifier];
215684
+ if (!dependencyTreeNode)
215685
+ throw new Error(`Dependency tree does not contain dependency ${simplePurlForComponent}`);
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
+ };
215697
+ for (const vulnerability of c3.vulnerabilities) {
215698
+ vulnerabilities.push({
215699
+ url: vulnerability.ghsaId,
215700
+ purl: c3.purl,
215701
+ purlType: c3.purl_type,
215702
+ range: vulnerability.range,
215703
+ name: dependencyTreeNode.packageName,
215704
+ dependency: dependencyTreeNode.packageName,
215705
+ vulnChainDetails: computeVulnChainDetails(dependencyTree, dependencyIdentifier, parentsMap),
215706
+ vulnerabilityAccessPaths: vulnerability.reachabilityData?.pattern,
215707
+ ecosystem: dependencyTree.ecosystem
215708
+ });
215709
+ }
215696
215710
  }
215697
215711
  }
215698
215712
  for (const dependencyIdentifier of dependencyIdentifiersNotFound) {
@@ -215707,7 +215721,9 @@ function getPurlStrings(dependencyTree) {
215707
215721
  const { namespace: namespace2, name } = getNamespaceAndName(dependencyTree.ecosystem, node.packageName);
215708
215722
  const version3 = node.version;
215709
215723
  const purl = simplePurl(type, namespace2, name, version3);
215710
- res[purl] = depId;
215724
+ if (!res[purl])
215725
+ res[purl] = /* @__PURE__ */ new Set();
215726
+ res[purl].add(depId);
215711
215727
  }
215712
215728
  return res;
215713
215729
  }
@@ -215753,19 +215769,19 @@ function transformToVulnChainNode(dependencyTree) {
215753
215769
  function getPurlType(ecosystem) {
215754
215770
  switch (ecosystem) {
215755
215771
  case "NPM":
215756
- return PURL_Type.NPM;
215772
+ return "npm" /* NPM */;
215757
215773
  case "MAVEN":
215758
- return PURL_Type.MAVEN;
215774
+ return "maven" /* MAVEN */;
215759
215775
  case "PIP":
215760
- return PURL_Type.PYPI;
215776
+ return "pypi" /* PYPI */;
215761
215777
  case "NUGET":
215762
- return PURL_Type.NUGET;
215778
+ return "nuget" /* NUGET */;
215763
215779
  case "GO":
215764
- return PURL_Type.GOLANG;
215780
+ return "golang" /* GOLANG */;
215765
215781
  case "RUST":
215766
- return PURL_Type.CARGO;
215782
+ return "cargo" /* CARGO */;
215767
215783
  case "RUBYGEMS":
215768
- return PURL_Type.GEM;
215784
+ return "gem" /* GEM */;
215769
215785
  default:
215770
215786
  throw new Error(`Unsupported ecosystem: ${ecosystem}`);
215771
215787
  }
@@ -215794,39 +215810,112 @@ function getNamespaceAndName(ecosystem, packageName) {
215794
215810
  }
215795
215811
  return { namespace: namespace2, name };
215796
215812
  }
215797
- var PURL_Type;
215798
- (function(PURL_Type2) {
215799
- PURL_Type2["ALPM"] = "alpm";
215800
- PURL_Type2["APK"] = "apk";
215801
- PURL_Type2["BITBUCKET"] = "bitbucket";
215802
- PURL_Type2["COCOAPODS"] = "cocoapods";
215803
- PURL_Type2["CARGO"] = "cargo";
215804
- PURL_Type2["COMPOSER"] = "composer";
215805
- PURL_Type2["CONAN"] = "conan";
215806
- PURL_Type2["CONDA"] = "conda";
215807
- PURL_Type2["CRAN"] = "cran";
215808
- PURL_Type2["DEB"] = "deb";
215809
- PURL_Type2["DOCKER"] = "docker";
215810
- PURL_Type2["GEM"] = "gem";
215811
- PURL_Type2["GENERIC"] = "generic";
215812
- PURL_Type2["GITHUB"] = "github";
215813
- PURL_Type2["GOLANG"] = "golang";
215814
- PURL_Type2["HACKAGE"] = "hackage";
215815
- PURL_Type2["HEX"] = "hex";
215816
- PURL_Type2["HUGGINGFACE"] = "huggingface";
215817
- PURL_Type2["MAVEN"] = "maven";
215818
- PURL_Type2["MLFLOW"] = "mlflow";
215819
- PURL_Type2["NPM"] = "npm";
215820
- PURL_Type2["NUGET"] = "nuget";
215821
- PURL_Type2["QPKG"] = "qpkg";
215822
- PURL_Type2["OCI"] = "oci";
215823
- PURL_Type2["PUB"] = "pub";
215824
- PURL_Type2["PYPI"] = "pypi";
215825
- PURL_Type2["RPM"] = "rpm";
215826
- PURL_Type2["SWID"] = "swid";
215827
- PURL_Type2["SWIFT"] = "swift";
215828
- PURL_Type2["UNKNOWN"] = "unknown";
215829
- })(PURL_Type || (PURL_Type = {}));
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
+ }
215830
215919
 
215831
215920
  // dist/cli-core.js
215832
215921
  var { omit, partition, pick } = import_lodash15.default;
@@ -215963,10 +216052,7 @@ var CliCore = class {
215963
216052
  if (!this.reportDependencyTrees) {
215964
216053
  throw new Error("Dependency trees should be available when using --socket-mode");
215965
216054
  }
215966
- const socketReport = {
215967
- ...report,
215968
- dependencyTrees: this.reportDependencyTrees
215969
- };
216055
+ const socketReport = toSocketFacts(report, this.reportDependencyTrees);
215970
216056
  const outputFile = resolve24(this.options.socketMode);
215971
216057
  await writeFile10(outputFile, JSON.stringify(socketReport, null, 2));
215972
216058
  logger.info(kleur_default.green(`Socket report written to: ${outputFile}`));
@@ -216305,7 +216391,9 @@ var CliCore = class {
216305
216391
  packageVersion: vulnerableNode.version ?? "",
216306
216392
  ecosystem: v.ecosystem ?? "NPM",
216307
216393
  dependencyType,
216308
- reachability
216394
+ reachability,
216395
+ purl: v.purl,
216396
+ purlType: v.purlType
216309
216397
  };
216310
216398
  });
216311
216399
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.9.19",
3
+ "version": "14.9.21",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {