@coana-tech/cli 14.12.36 → 14.12.37

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
@@ -212328,18 +212328,26 @@ async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash,
212328
212328
  break;
212329
212329
  }
212330
212330
  }
212331
- let manifestAndWorkspace = manifestFiles.map((manifestFile) => [
212332
- manifestFile,
212333
- inferWorkspaceFromManifestPath(ecosystem, manifestFile, properPythonProjects)
212334
- ]).filter(([, workspace]) => workspace !== void 0);
212335
- if (manifestAndWorkspace.length === 0) {
212336
- manifestAndWorkspace = manifestFiles.map((manifestFile) => [manifestFile, inferProjectFromManifestPath(ecosystem, manifestFile)]).filter(([, workspace]) => workspace !== void 0);
212337
- }
212338
- if (manifestAndWorkspace.length === 0 && artifact.vulnerabilities && artifact.vulnerabilities.length > 0) {
212331
+ const workspaceToManifestFiles = {};
212332
+ manifestFiles.forEach((manifestFile) => {
212333
+ const workspace = inferWorkspaceFromManifestPath(ecosystem, manifestFile, properPythonProjects);
212334
+ if (!workspace)
212335
+ return;
212336
+ (workspaceToManifestFiles[workspace] ??= []).push(manifestFile);
212337
+ });
212338
+ if (Object.keys(workspaceToManifestFiles).length === 0) {
212339
+ manifestFiles.forEach((manifestFile) => {
212340
+ const workspace = inferProjectFromManifestPath(ecosystem, manifestFile);
212341
+ if (!workspace)
212342
+ return;
212343
+ (workspaceToManifestFiles[workspace] ??= []).push(manifestFile);
212344
+ });
212345
+ }
212346
+ if (Object.keys(workspaceToManifestFiles).length === 0 && artifact.vulnerabilities && artifact.vulnerabilities.length > 0) {
212339
212347
  const purl = new import_packageurl_js.PackageURL(artifact.type, artifact.namespace, artifact.name, artifact.version, artifact.qualifiers).toString();
212340
212348
  purlsFailedToFindWorkspace.add(purl);
212341
212349
  }
212342
- for (const [manifestFile, workspace] of manifestAndWorkspace) {
212350
+ for (const [workspace, manifestFiles2] of Object.entries(workspaceToManifestFiles)) {
212343
212351
  if (!ecosystemToWorkspaceToAnalysisData[ecosystem]) {
212344
212352
  ecosystemToWorkspaceToAnalysisData[ecosystem] = {};
212345
212353
  }
@@ -212348,21 +212356,18 @@ async function fetchArtifactsFromSocket(rootWorkingDirectory, manifestsTarHash,
212348
212356
  type: "socket",
212349
212357
  data: {
212350
212358
  type: ecosystem,
212351
- manifestFiles: [],
212359
+ manifestFiles: manifestFiles2,
212352
212360
  artifacts: []
212353
212361
  }
212354
212362
  };
212355
212363
  }
212356
212364
  const workspaceData = ecosystemToWorkspaceToAnalysisData[ecosystem][workspace];
212357
212365
  if (workspaceData.type === "socket") {
212358
- if (!workspaceData.data.manifestFiles.includes(manifestFile)) {
212359
- workspaceData.data.manifestFiles.push(manifestFile);
212360
- }
212361
212366
  workspaceData.data.artifacts.push(artifact);
212362
212367
  }
212363
212368
  }
212364
212369
  if (artifact.vulnerabilities && artifact.vulnerabilities.length > 0) {
212365
- for (const workspace of i5(manifestAndWorkspace.map(([, workspace2]) => workspace2))) {
212370
+ for (const workspace of Object.keys(workspaceToManifestFiles)) {
212366
212371
  for (const vuln of artifact.vulnerabilities) {
212367
212372
  const vulnerability = {
212368
212373
  url: vuln.ghsaId,
@@ -227512,7 +227517,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
227512
227517
  }
227513
227518
 
227514
227519
  // dist/version.js
227515
- var version2 = "14.12.36";
227520
+ var version2 = "14.12.37";
227516
227521
 
227517
227522
  // dist/cli-core.js
227518
227523
  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.36",
3
+ "version": "14.12.37",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -74735,8 +74735,6 @@ var DotnetCodeAwareVulnerabilityScanner = class _DotnetCodeAwareVulnerabilitySca
74735
74735
  if (!vulnerablePathsForClass)
74736
74736
  continue;
74737
74737
  classStacks.push(...vulnerablePathsForClass.map((vulnPath) => {
74738
- if (vulnPath.length < 2)
74739
- throw new Error("The path should always have length at least two.");
74740
74738
  return vulnPath.map(({ fullyQualifiedName, confidence, packageId }) => ({
74741
74739
  package: appPackageIds.has(packageId) ? "<app>" : prettyPrintNugetDependency(parsePackageUrlToNugetDependency(packageId)),
74742
74740
  class: fullyQualifiedName,
@@ -88595,8 +88593,6 @@ var JavaCodeAwareVulnerabilityScanner = class _JavaCodeAwareVulnerabilityScanner
88595
88593
  if (!vulnerablePathsForClass)
88596
88594
  continue;
88597
88595
  classStacks.push(...vulnerablePathsForClass.map((vulnPath) => {
88598
- if (vulnPath.length < 2)
88599
- throw new Error("The path should always have length at least two.");
88600
88596
  return vulnPath.map(({ fullyQualifiedName, confidence, packageId }) => ({
88601
88597
  package: appPackageIds.has(packageId) ? "<app>" : prettyPrintMavenDependency(parsePackageUrlToMavenDependency(packageId)),
88602
88598
  class: fullyQualifiedName,
@@ -88630,25 +88626,24 @@ function inferWorkspaceFromManifestPath(manifestFile) {
88630
88626
  }
88631
88627
  async function convertDependencyChain2(dependencyChain, tmpDir) {
88632
88628
  async function downloadMavenArtifacts(groupId, artifactId, version3) {
88633
- const artifactPaths = [];
88634
88629
  const packageDir = getPathToPackage(tmpDir, groupId, artifactId, version3);
88635
88630
  await mkdir2(packageDir, { recursive: true });
88636
88631
  const repositories = await findRepositoriesForMavenPackageAndVersion(groupId, artifactId, version3);
88637
- if (!repositories?.length)
88638
- throw Error("No repository found for package");
88639
- for (const repository of repositories) {
88632
+ for (const repository of repositories ?? []) {
88640
88633
  const packageUrl = getUrlForPackage2(repository, groupId, artifactId, version3);
88641
88634
  const artifacts = await findArtifactsForPackageInRemoteRepository(repository, groupId, artifactId, version3);
88642
88635
  if (!artifacts)
88643
88636
  continue;
88644
- await asyncForEach(artifacts, async (artifact) => {
88637
+ const artifactPaths = await asyncMap(artifacts, async (artifact) => {
88645
88638
  const artifactUrl = `${packageUrl.endsWith("/") ? packageUrl.slice(0, -1) : packageUrl}/${artifact}`;
88646
88639
  const artifactFile = join14(packageDir, artifact);
88647
- await downloadFile(artifactUrl, artifactFile);
88648
- artifactPaths.push(artifactFile);
88640
+ const success = await downloadFile(artifactUrl, artifactFile);
88641
+ return success ? artifactFile : void 0;
88649
88642
  }, 4);
88643
+ if (artifactPaths.every((f2) => f2 !== void 0))
88644
+ return artifactPaths;
88650
88645
  }
88651
- return artifactPaths;
88646
+ return void 0;
88652
88647
  }
88653
88648
  const mavenDependencyChain = await asyncMap(dependencyChain, async (dep) => {
88654
88649
  const [groupId, artifactId] = dep.packageName.split(":");
@@ -88664,8 +88659,10 @@ async function convertSocketArtifacts2(artifacts, tmpDir) {
88664
88659
  const artifactFile = getPathToArtifact(tmpDir, groupId, artifactId, type, classifier, version3);
88665
88660
  await mkdir2(dirname4(artifactFile), { recursive: true });
88666
88661
  const repositories = await findRepositoriesForMavenPackageAndVersion(groupId, artifactId, version3);
88667
- if (!repositories?.length)
88668
- throw Error("No repository found for package");
88662
+ if (!repositories?.length) {
88663
+ logger.warn(`Failed to find repository for maven package ${[groupId, artifactId, type, classifier, version3].filter(Boolean).join(":")}`);
88664
+ return void 0;
88665
+ }
88669
88666
  for (const repository of repositories) {
88670
88667
  const artifactUrl = getUrlForArtifact(repository, groupId, artifactId, type, classifier, version3);
88671
88668
  if (!artifactUrl)
@@ -88674,6 +88671,7 @@ async function convertSocketArtifacts2(artifacts, tmpDir) {
88674
88671
  if (succeeded)
88675
88672
  return [artifactFile];
88676
88673
  }
88674
+ logger.warn(`Failed to download maven package ${[groupId, artifactId, type, classifier, version3].filter(Boolean).join(":")}, repositories tried: ${repositories}`);
88677
88675
  return void 0;
88678
88676
  }
88679
88677
  const deps = {};
@@ -96279,8 +96277,6 @@ var RustCodeAwareVulnerabilityScanner = class _RustCodeAwareVulnerabilityScanner
96279
96277
  if (!vulnerablePathsForClass)
96280
96278
  continue;
96281
96279
  classStacks.push(...vulnerablePathsForClass.map((vulnPath) => {
96282
- if (vulnPath.length < 2)
96283
- throw new Error("The path should always have length at least two.");
96284
96280
  return vulnPath.map(({ fullyQualifiedName, confidence, packageId }) => ({
96285
96281
  package: appPackageIds.has(packageId) ? "<app>" : prettyPrintRustDependency(parsePackageUrlToRustDependency(packageId)),
96286
96282
  class: fullyQualifiedName,
@@ -96328,14 +96324,19 @@ async function convertSocketArtifacts3(artifacts, tmpDir) {
96328
96324
  const packageFile = join19(tmpDir, `${packageName.toLocaleLowerCase()}-${version3.toLocaleLowerCase()}.crate`);
96329
96325
  const success = await downloadFile(packageUrl, packageFile);
96330
96326
  if (!success) {
96331
- logger.error(`Could not download crate ${packageName}@${version3} from crates.io`);
96332
- throw Error("Failed to download crate");
96327
+ logger.warn(`Could not download crate ${packageName}@${version3} from crates.io`);
96328
+ return void 0;
96329
+ }
96330
+ try {
96331
+ await execAndLogOnFailure(["tar", "-xzf", packageFile], tmpDir);
96332
+ const packageDir = join19(tmpDir, `${packageName.toLocaleLowerCase()}-${version3.toLocaleLowerCase()}`);
96333
+ const cargoTomlPath = join19(packageDir, "Cargo.toml");
96334
+ const depCrateInfo = await getCrateInfo(cargoTomlPath);
96335
+ return [depCrateInfo.lib];
96336
+ } catch (e) {
96337
+ logger.warn(`Error extracting crate ${packageName}@${version3}: ${e.message ?? "Unknown error"}`);
96338
+ return void 0;
96333
96339
  }
96334
- await execAndLogOnFailure(["tar", "-xzf", packageFile], tmpDir);
96335
- const packageDir = join19(tmpDir, `${packageName.toLocaleLowerCase()}-${version3.toLocaleLowerCase()}`);
96336
- const cargoTomlPath = join19(packageDir, "Cargo.toml");
96337
- const depCrateInfo = await getCrateInfo(cargoTomlPath);
96338
- return [depCrateInfo.lib];
96339
96340
  }
96340
96341
  const deps = {};
96341
96342
  await asyncForEach(artifacts, async (artifact) => {