@coana-tech/cli 15.0.3 → 15.0.4

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
@@ -234861,7 +234861,7 @@ async function computeFixesAndUpgradePurls(path9, options, logFile) {
234861
234861
  }
234862
234862
  if (upgrades.size === 0) {
234863
234863
  if (autofixRunId) {
234864
- await getSocketAPI().finalizeAutofixRun(autofixRunId, "fixed-none");
234864
+ await getSocketAPI().finalizeAutofixRun(autofixRunId, "fixed-none", void 0, await logger.getLogContent(logFile));
234865
234865
  }
234866
234866
  throw new Error(`Unable to compute fixes for any of the requested vulnerabilities: ${prettyApplyFixesTo(options.applyFixesTo)}`);
234867
234867
  }
@@ -234879,7 +234879,7 @@ async function computeFixesAndUpgradePurls(path9, options, logFile) {
234879
234879
  }, autofixRunId) ?? "fixed-all";
234880
234880
  if (autofixRunId) {
234881
234881
  const allGhsasFailed = fixesFound.length === 0;
234882
- await getSocketAPI().finalizeAutofixRun(autofixRunId, ghsasWithFailedArtifacts.length === 0 && applyFixesStatus === "fixed-all" ? "fixed-all" : allGhsasFailed || applyFixesStatus === "fixed-none" ? "fixed-none" : "fixed-some");
234882
+ await getSocketAPI().finalizeAutofixRun(autofixRunId, ghsasWithFailedArtifacts.length === 0 && applyFixesStatus === "fixed-all" ? "fixed-all" : allGhsasFailed || applyFixesStatus === "fixed-none" ? "fixed-none" : "fixed-some", void 0, await logger.getLogContent(logFile));
234883
234883
  }
234884
234884
  return {
234885
234885
  type: "applied-fixes",
@@ -251822,7 +251822,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
251822
251822
  }
251823
251823
 
251824
251824
  // dist/version.js
251825
- var version3 = "15.0.3";
251825
+ var version3 = "15.0.4";
251826
251826
 
251827
251827
  // dist/cli-core.js
251828
251828
  var { mapValues, omit, partition, pickBy: pickBy2 } = import_lodash15.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "15.0.3",
3
+ "version": "15.0.4",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -110925,7 +110925,7 @@ function tarjanAndCondensation(packageMetadatas) {
110925
110925
 
110926
110926
  // dist/whole-program-code-aware-vulnerability-scanner/js/dependency-preparation.js
110927
110927
  async function prepareNpmDependencies(subprojectDir, workspaceDir, artifactIdToArtifact, directDependencies, packageNamesToInstall, preinstallDir) {
110928
- if (existsSync11(resolve12(subprojectDir, "node_modules")))
110928
+ if (existsSync11(resolve12(subprojectDir, "node_modules")) || existsSync11(resolve12(workspaceDir, "node_modules")))
110929
110929
  return { failedPackages: [], installedPackages: [] };
110930
110930
  const artifactToOriginal = /* @__PURE__ */ new Map();
110931
110931
  const transitiveDependenciesToInstall = Object.fromEntries(Object.entries(artifactIdToArtifact).filter(([_, dep]) => packageNamesToInstall.includes(getPackageName(dep))).map(([depId, dep]) => {
@@ -111905,6 +111905,7 @@ var SparJSAnalysisEngine = class extends JSAnalysisEngine {
111905
111905
  ${/* XXX: Requires Node 22+ */
111906
111906
  approx && "--approx"}
111907
111907
  --callstacks-json ${callStackFile}
111908
+ --escape-patch-resolved-reads
111908
111909
  --unresolved-non-vulnerable
111909
111910
  ${parseShellArgs(process.env.COANA_SPARJS_ADDITIONAL_FLAGS ?? "")}
111910
111911
  ${filesToAnalyze}
@@ -111950,12 +111951,14 @@ var SparJSAnalysisEngine = class extends JSAnalysisEngine {
111950
111951
  for (const match2 of Object.values(matches))
111951
111952
  match2.affectedPackages = uniq5(match2.stacks.flatMap((stack) => map3(stack, "package")));
111952
111953
  const affectedPackages = JSON.parse(await readFile11(affectedPackagesFile, "utf-8")).packages;
111954
+ const aborted = analysisDiagnostics.solver.aborted;
111953
111955
  return {
111954
111956
  matches,
111955
111957
  analysisDiagnostics: {
111956
111958
  ...analysisDiagnostics,
111957
- aborted: analysisDiagnostics.solver.aborted,
111958
- timeout: analysisDiagnostics.totalTime / 1e6 >= timeoutInSeconds,
111959
+ aborted: !!aborted,
111960
+ timeout: aborted === "timeout",
111961
+ lowmemory: aborted === "out_of_memory",
111959
111962
  timings: {
111960
111963
  analysisTime: (analysisDiagnostics.totalTime - analysisDiagnostics.patternMatchingTime) / 1e3,
111961
111964
  patternMatchingTime: analysisDiagnostics.patternMatchingTime / 1e3,
@@ -112071,7 +112074,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
112071
112074
  ...new Set(state.vulnerabilities.flatMap((v) => Object.values(v.vulnChainDetails?.transitiveDependencies ?? {}).filter((d) => d.vulnerable === true).map((d) => d.packageName)))
112072
112075
  ];
112073
112076
  const packagesToInstall = !includePackages ? state.workspaceData.type === "coana" ? Object.values(state.workspaceData.data.dependencyTree.transitiveDependencies).map((dep) => getPackageName(dep)) : state.workspaceData.data.artifacts.map((dep) => getPackageName(dep)) : [.../* @__PURE__ */ new Set([...includePackages, ...vulnerablePackageNames])];
112074
- const { failedPackages } = await prepareNpmDependencies(state.rootWorkingDir, this.projectDir, state.workspaceData.type === "coana" ? state.workspaceData.data.dependencyTree.transitiveDependencies : Object.fromEntries(state.workspaceData.data.artifacts.map((d) => [d.id, d])), state.workspaceData.type === "coana" ? state.workspaceData.data.dependencyTree.dependencies ?? [] : state.workspaceData.data.artifacts.filter((a2) => a2.direct).map((a2) => a2.id), packagesToInstall, state.preinstallDir);
112077
+ const { failedPackages } = await prepareNpmDependencies(state.subprojectDir, this.projectDir, state.workspaceData.type === "coana" ? state.workspaceData.data.dependencyTree.transitiveDependencies : Object.fromEntries(state.workspaceData.data.artifacts.map((d) => [d.id, d])), state.workspaceData.type === "coana" ? state.workspaceData.data.dependencyTree.dependencies ?? [] : state.workspaceData.data.artifacts.filter((a2) => a2.direct).map((a2) => a2.id), packagesToInstall, state.preinstallDir);
112075
112078
  this.packagesExcludedUnrelatedToHeuristic = failedPackages.map((p) => getPackageName(p));
112076
112079
  }
112077
112080
  async runAnalysis(vulnerabilities, heuristic, timeoutInSeconds, experiment, telemetryHandler, analyzerTelemetryHandler) {
@@ -112080,7 +112083,7 @@ var JSCodeAwareVulnerabilityScanner = class _JSCodeAwareVulnerabilityScanner {
112080
112083
  analysisOptionsFromHeuristic.approx = process.env.JELLY_APPROX === "true" || experiment === "JELLY_APPROX";
112081
112084
  const analysisRes = await this.resolveEngine(experiment).runAnalysis(this.mainProjectDir, this.projectDir, analysisOptionsFromHeuristic, this.options, timeoutInSeconds, vulnerabilities, experiment, telemetryHandler, analyzerTelemetryHandler);
112082
112085
  const { analysisDiagnostics: diagnostics, matches } = analysisRes;
112083
- const terminatedEarly = diagnostics.lowmemory ?? diagnostics.rangeError ?? (diagnostics.aborted || diagnostics.timeout);
112086
+ const terminatedEarly = diagnostics.rangeError ?? (diagnostics.aborted || diagnostics.timeout || diagnostics.lowmemory);
112084
112087
  return {
112085
112088
  type: "success",
112086
112089
  diagnostics,
@@ -114899,8 +114902,9 @@ var NpmAnalyzer = class {
114899
114902
  }
114900
114903
  async runReachabilityAnalysis(vulns, analysisMetadataCollector, statusUpdater) {
114901
114904
  const heuristicsInOrder = this.state.otherAnalysisOptions.lightweightReachability ? [heuristics.IGNORE_DEPENDENCIES_AND_MAX_ROUNDS_3] : [heuristics.ONLY_VULN_PATH_PACKAGES_EXCEPT_VULNERABLE_PACKAGE];
114902
- const nodeModulesAlreadyExisted = existsSync20(resolve25(this.state.subprojectDir, "node_modules"));
114903
- this.preinstalledDependencies = nodeModulesAlreadyExisted ? "YES" : "NO";
114905
+ const nodeModulesAlreadyExistedInSubprojectDir = existsSync20(resolve25(this.state.subprojectDir, "node_modules"));
114906
+ const nodeModulesAlreadyExistedInProjectDir = existsSync20(resolve25(this.projectDir, "node_modules"));
114907
+ this.preinstalledDependencies = nodeModulesAlreadyExistedInSubprojectDir || nodeModulesAlreadyExistedInProjectDir ? "YES" : "NO";
114904
114908
  const wrappedCollector = (metadata) => {
114905
114909
  const jellyDiagnostics = metadata.analysisDiagnostics;
114906
114910
  if (jellyDiagnostics?.modules !== void 0) {
@@ -115025,11 +115029,11 @@ ${e.stack}` : String(e),
115025
115029
  return res;
115026
115030
  } finally {
115027
115031
  await Promise.all([this.engine.cleanup(), vulnerabilityScanner.cleanup()]);
115028
- if (!nodeModulesAlreadyExisted) {
115029
- if (existsSync20(resolve25(this.state.subprojectDir, "node_modules")))
115030
- await rm11(resolve25(this.state.subprojectDir, "node_modules"), { recursive: true });
115031
- if (existsSync20(resolve25(this.projectDir, "node_modules")))
115032
- await rm11(resolve25(this.projectDir, "node_modules"), { recursive: true });
115032
+ if (!nodeModulesAlreadyExistedInSubprojectDir) {
115033
+ await rm11(resolve25(this.state.subprojectDir, "node_modules"), { recursive: true, force: true });
115034
+ }
115035
+ if (!nodeModulesAlreadyExistedInProjectDir) {
115036
+ await rm11(resolve25(this.projectDir, "node_modules"), { recursive: true, force: true });
115033
115037
  }
115034
115038
  }
115035
115039
  }