@coana-tech/cli 14.11.5 → 14.11.6

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-wrapper.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  import { fileURLToPath } from 'url';
2
3
  import { dirname, join } from 'path';
3
4
 
package/cli.mjs CHANGED
@@ -207671,6 +207671,9 @@ var OtherModulesCommunicator = class {
207671
207671
  if (this.options.socketMode) {
207672
207672
  env.SOCKET_MODE = "true";
207673
207673
  }
207674
+ if (this.options.disableAnalyticsSharing) {
207675
+ env.DISABLE_ANALYTICS_SHARING = "true";
207676
+ }
207674
207677
  return Spinner.instance().wrap(
207675
207678
  this.getSpinnerTextForReachabilityAnalyzerCommand(commandName, ecosystem, subprojectPath, workspacePath),
207676
207679
  async () => {
@@ -209627,12 +209630,17 @@ var DashboardAPI = class {
209627
209630
  socketMode;
209628
209631
  coanaAPI;
209629
209632
  socketAPI;
209630
- constructor(socketMode) {
209633
+ disableAnalyticsSharing;
209634
+ constructor(socketMode, disableAnalyticsSharing) {
209631
209635
  this.socketMode = socketMode;
209636
+ this.disableAnalyticsSharing = disableAnalyticsSharing;
209632
209637
  this.coanaAPI = getCoanaAPI();
209633
209638
  this.socketAPI = getSocketAPI();
209634
209639
  }
209635
209640
  async createReport(repoUrl, projectName, cliVersion, commitSha, branchName, cliOptions, apiKey, cliRunEnv) {
209641
+ if (this.disableAnalyticsSharing) {
209642
+ return;
209643
+ }
209636
209644
  if (this.socketMode) {
209637
209645
  return (await this.socketAPI.createSocketTier1Scan(cliOptions, cliVersion)).tier1_reachability_scan_id;
209638
209646
  } else {
@@ -209649,6 +209657,9 @@ var DashboardAPI = class {
209649
209657
  }
209650
209658
  }
209651
209659
  async sendErrorReport(apiKey, stackTrace, shouldLogSharing, reportId, repoUrl, projectName, logContent) {
209660
+ if (this.disableAnalyticsSharing) {
209661
+ return;
209662
+ }
209652
209663
  if (this.socketMode) {
209653
209664
  await this.socketAPI.sendErrorReportToSocketDashboard(stackTrace, shouldLogSharing, reportId, logContent);
209654
209665
  } else {
@@ -209664,6 +209675,9 @@ var DashboardAPI = class {
209664
209675
  }
209665
209676
  }
209666
209677
  async registerSubprojects(subprojects, reportId, apiKey) {
209678
+ if (this.disableAnalyticsSharing) {
209679
+ return;
209680
+ }
209667
209681
  if (this.socketMode) {
209668
209682
  await this.socketAPI.registerSubprojectsSocket(subprojects, reportId);
209669
209683
  } else {
@@ -209671,6 +209685,9 @@ var DashboardAPI = class {
209671
209685
  }
209672
209686
  }
209673
209687
  async registerCLIProgress(cliProgressEvent, isStartEvent, reportId, apiKey) {
209688
+ if (this.disableAnalyticsSharing) {
209689
+ return;
209690
+ }
209674
209691
  if (this.socketMode) {
209675
209692
  await this.socketAPI.registerCLIProgressSocket(isStartEvent, cliProgressEvent, reportId);
209676
209693
  } else {
@@ -209678,6 +209695,9 @@ var DashboardAPI = class {
209678
209695
  }
209679
209696
  }
209680
209697
  async registerAnalysisMetadata(subprojectPath, workspacePath, ecosystem, analysisMetadata, reportId, apiKey) {
209698
+ if (this.disableAnalyticsSharing) {
209699
+ return;
209700
+ }
209681
209701
  if (this.socketMode) {
209682
209702
  await this.socketAPI.registerAnalysisMetadataSocket(
209683
209703
  subprojectPath,
@@ -225295,7 +225315,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
225295
225315
  }
225296
225316
 
225297
225317
  // dist/version.js
225298
- var version2 = "14.11.5";
225318
+ var version2 = "14.11.6";
225299
225319
 
225300
225320
  // dist/cli-core.js
225301
225321
  var { mapValues, omit, partition, pick } = import_lodash15.default;
@@ -225328,7 +225348,7 @@ var CliCore = class {
225328
225348
  this.rootWorkingDirectory = resolve25(rootWorkingDirectory);
225329
225349
  this.spinner = Spinner.instance({ text: "Running Coana CLI", isSilent: this.options.silent });
225330
225350
  this.shareWithDashboard = !this.options.socketMode && !!(this.options.apiKey && !this.options.disableReportSubmission && (this.options.repoUrl ?? this.options.projectName));
225331
- this.dashboardAPI = new DashboardAPI(!!this.options.socketMode);
225351
+ this.dashboardAPI = new DashboardAPI(Boolean(this.options.socketMode), Boolean(this.options.disableAnalyticsSharing));
225332
225352
  }
225333
225353
  verifyApiKey(key) {
225334
225354
  const checkIfApiKeyIsEmptyMessage = "You may be trying to provide the API key through an environment variable or CI secret which is either undefined or empty.";
@@ -225409,7 +225429,8 @@ var CliCore = class {
225409
225429
  silent: this.options.silent,
225410
225430
  coanaLogPath: this.coanaLogPath,
225411
225431
  reportId: this.reportId,
225412
- socketMode: !!this.options.socketMode
225432
+ socketMode: Boolean(this.options.socketMode),
225433
+ disableAnalyticsSharing: Boolean(this.options.disableAnalyticsSharing)
225413
225434
  }, this.apiKey);
225414
225435
  if (this.options.manifestsTarHash) {
225415
225436
  await this.computeAndOutputReportSocketMode(otherModulesCommunicator);
@@ -226211,7 +226232,7 @@ function computeSBOMTaskArtifacts(dependencyTrees) {
226211
226232
  // dist/index.js
226212
226233
  var program2 = new Command();
226213
226234
  var run2 = new Command();
226214
- run2.name("run").argument("<path>", "File system path to folder containing the project").option("-o, --output-dir <path>", "Write json report to <path>/coana-report.json").option("-d, --debug", "Enable debug logging", false).option("-s, --silent", "Silence all debug/warning output", false).option("-p, --print-report", "Print the report to the console", false).option("--offline-database <path>", "Path to a coana-offline-db.json file for running the CLI without internet connectivity", void 0).option("-t, --timeout <timeout>", "Set API <timeout> in milliseconds to Coana backend.", "300000").option("-a, --analysis-timeout <timeout>", "Set <timeout> in seconds for each reachability analysis run").option("--memory-limit <memoryInMB>", "Set memory limit for analysis to <memoryInMB> megabytes of memory.", "8192").option("-c, --concurrency <concurrency>", "Set the maximum number of concurrent reachability analysis runs. It's recommended to choose a concurrency level that ensures that each analysis run has at least the --memory-limit amount of memory available.", "1").option("--api-key <key>", "Set the Coana dashboard API key. By setting you also enable the dashboard integration.").addOption(new Option("--write-report-to-file", "Write the report dashboard-compatible report to dashboard-report.json. This report may help the Coana team debug issues with the report insertion mechanism.").default(false).hideHelp()).option("--project-name <repoName>", "Set the name of the repository. Used for dashboard integration.").option("--repo-url <repoUrl>", "Set the URL of the repository. Used for dashboard integration.").option("--include-dirs <relativeDirs...>", "globs for directories to include from the detection of subprojects (space-separated)(use relative paths from the project root). Notice, projects that are not included may still be scanned if they are referenced from included projects.").option("--exclude-dirs <relativeDirs...>", "globs for directories to exclude from the detection of subprojects (space-separated)(use relative paths from the project root). Notice, excluded projects may still be scanned if they are referenced from non-excluded projects.").option("--disable-analysis-splitting", "Limits Coana to at most 1 reachability analysis run per workspace").option("--print-analysis-log-file", "Store log output from the JavaScript/TypeScript reachability analysis in the file js-analysis.log file in the root of each workspace", false).option("--entry-points <entryPoints...>", "List of files to analyze for root workspace. The reachability analysis automatically analyzes all files used by the entry points. If not provided, all JavaScript and TypeScript files are considered entry points. For non-root workspaces, all JavaScript and TypeScript files are analyzed as well.").option("--include-projects-with-no-reachability-support", "Also runs Coana on projects where we support traditional SCA, but does not yet support reachability analysis.", false).option("--ecosystems <ecosystems...>", "List of ecosystems to analyze (space-separated). Currently NPM, PIP, MAVEN, NUGET and GO are supported. Default is all supported ecosystems.").option("--changed-files <files...>", "List of files that have changed. If provided, Coana only analyzes workspaces and modules that contain changed files.").option("--disable-report-submission", "Disable the submission of the report to the Coana dashboard. Used by the pipeline blocking feature.", false).option("--provider-project <path>", "File system path to folder containing the provider project (Only supported for Maven, Gradle, and SBT)").option("--provider-workspaces <dirs...>", "List of workspaces that build the provided runtime environment (Only supported for Maven, Gradle, and SBT)", (paths) => paths.split(" ")).option("--lightweight-reachability", "Runs Coana in lightweight mode. This increases analysis speed but also raises the risk of Coana misclassifying the reachability of certain complex vulnerabilities. Recommended only for use with Coana Guardrail mode.", false).addOption(new Option("--run-without-docker", "Run package managers and reachability analyzers without using docker").default(process.env.RUN_WITHOUT_DOCKER === "true").hideHelp()).addOption(new Option("--run-env <env>", "Specifies the environment in which the CLI is run. So far only MANAGED_SCAN and UNKNOWN are supported.").default("UNKNOWN").choices(["UNKNOWN", "MANAGED_SCAN"]).hideHelp()).addOption(new Option("--guardrail-mode", "Run Coana in guardrail mode. This mode is used to prevent new reachable vulnerabilities from being introduced into the codebase. Usually run as a CI check when pushing new commits to a pull request.")).option("--ignore-failing-workspaces", "Continue processing when a workspace fails instead of exiting. Failed workspaces will be logged at termination.", false).addOption(new Option("--socket-mode <output-file>", "Run Coana in socket mode and write report to <output-file>").hideHelp()).addOption(new Option("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket. If provided, Socket will be used for computing dependency trees.").hideHelp()).version(version2).configureHelp({ sortOptions: true }).action(async (path2, options) => {
226235
+ run2.name("run").argument("<path>", "File system path to folder containing the project").option("-o, --output-dir <path>", "Write json report to <path>/coana-report.json").option("-d, --debug", "Enable debug logging", false).option("-s, --silent", "Silence all debug/warning output", false).option("-p, --print-report", "Print the report to the console", false).option("--offline-database <path>", "Path to a coana-offline-db.json file for running the CLI without internet connectivity", void 0).option("-t, --timeout <timeout>", "Set API <timeout> in milliseconds to Coana backend.", "300000").option("-a, --analysis-timeout <timeout>", "Set <timeout> in seconds for each reachability analysis run").option("--memory-limit <memoryInMB>", "Set memory limit for analysis to <memoryInMB> megabytes of memory.", "8192").option("-c, --concurrency <concurrency>", "Set the maximum number of concurrent reachability analysis runs. It's recommended to choose a concurrency level that ensures that each analysis run has at least the --memory-limit amount of memory available.", "1").option("--api-key <key>", "Set the Coana dashboard API key. By setting you also enable the dashboard integration.").addOption(new Option("--write-report-to-file", "Write the report dashboard-compatible report to dashboard-report.json. This report may help the Coana team debug issues with the report insertion mechanism.").default(false).hideHelp()).option("--project-name <repoName>", "Set the name of the repository. Used for dashboard integration.").option("--repo-url <repoUrl>", "Set the URL of the repository. Used for dashboard integration.").option("--include-dirs <relativeDirs...>", "globs for directories to include from the detection of subprojects (space-separated)(use relative paths from the project root). Notice, projects that are not included may still be scanned if they are referenced from included projects.").option("--exclude-dirs <relativeDirs...>", "globs for directories to exclude from the detection of subprojects (space-separated)(use relative paths from the project root). Notice, excluded projects may still be scanned if they are referenced from non-excluded projects.").option("--disable-analysis-splitting", "Limits Coana to at most 1 reachability analysis run per workspace").option("--print-analysis-log-file", "Store log output from the JavaScript/TypeScript reachability analysis in the file js-analysis.log file in the root of each workspace", false).option("--entry-points <entryPoints...>", "List of files to analyze for root workspace. The reachability analysis automatically analyzes all files used by the entry points. If not provided, all JavaScript and TypeScript files are considered entry points. For non-root workspaces, all JavaScript and TypeScript files are analyzed as well.").option("--include-projects-with-no-reachability-support", "Also runs Coana on projects where we support traditional SCA, but does not yet support reachability analysis.", false).option("--ecosystems <ecosystems...>", "List of ecosystems to analyze (space-separated). Currently NPM, PIP, MAVEN, NUGET and GO are supported. Default is all supported ecosystems.").option("--changed-files <files...>", "List of files that have changed. If provided, Coana only analyzes workspaces and modules that contain changed files.").option("--disable-report-submission", "Disable the submission of the report to the Coana dashboard. Used by the pipeline blocking feature.", false).option("--disable-analytics-sharing", "Disable analytics sharing.", false).option("--provider-project <path>", "File system path to folder containing the provider project (Only supported for Maven, Gradle, and SBT)").option("--provider-workspaces <dirs...>", "List of workspaces that build the provided runtime environment (Only supported for Maven, Gradle, and SBT)", (paths) => paths.split(" ")).option("--lightweight-reachability", "Runs Coana in lightweight mode. This increases analysis speed but also raises the risk of Coana misclassifying the reachability of certain complex vulnerabilities. Recommended only for use with Coana Guardrail mode.", false).addOption(new Option("--run-without-docker", "Run package managers and reachability analyzers without using docker").default(process.env.RUN_WITHOUT_DOCKER === "true").hideHelp()).addOption(new Option("--run-env <env>", "Specifies the environment in which the CLI is run. So far only MANAGED_SCAN and UNKNOWN are supported.").default("UNKNOWN").choices(["UNKNOWN", "MANAGED_SCAN"]).hideHelp()).addOption(new Option("--guardrail-mode", "Run Coana in guardrail mode. This mode is used to prevent new reachable vulnerabilities from being introduced into the codebase. Usually run as a CI check when pushing new commits to a pull request.")).option("--ignore-failing-workspaces", "Continue processing when a workspace fails instead of exiting. Failed workspaces will be logged at termination.", false).addOption(new Option("--socket-mode <output-file>", "Run Coana in socket mode and write report to <output-file>").hideHelp()).addOption(new Option("--manifests-tar-hash <hash>", "Hash of the tarball containing all manifest files already uploaded to Socket. If provided, Socket will be used for computing dependency trees.").hideHelp()).version(version2).configureHelp({ sortOptions: true }).action(async (path2, options) => {
226215
226236
  process.env.DOCKER_IMAGE_TAG ??= version2;
226216
226237
  options.ecosystems = options.ecosystems?.map((e) => e.toUpperCase());
226217
226238
  await new CliCore(path2, options).main();
@@ -226268,7 +226289,8 @@ var defaultCliOptions = {
226268
226289
  lightweightReachability: false,
226269
226290
  runEnv: "UNKNOWN",
226270
226291
  guardrailMode: false,
226271
- ignoreFailingWorkspaces: false
226292
+ ignoreFailingWorkspaces: false,
226293
+ disableAnalyticsSharing: false
226272
226294
  };
226273
226295
  export {
226274
226296
  defaultCliOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.11.5",
3
+ "version": "14.11.6",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -70711,12 +70711,17 @@ var DashboardAPI = class {
70711
70711
  socketMode;
70712
70712
  coanaAPI;
70713
70713
  socketAPI;
70714
- constructor(socketMode) {
70714
+ disableAnalyticsSharing;
70715
+ constructor(socketMode, disableAnalyticsSharing) {
70715
70716
  this.socketMode = socketMode;
70717
+ this.disableAnalyticsSharing = disableAnalyticsSharing;
70716
70718
  this.coanaAPI = getCoanaAPI();
70717
70719
  this.socketAPI = getSocketAPI();
70718
70720
  }
70719
70721
  async createReport(repoUrl, projectName, cliVersion, commitSha, branchName, cliOptions, apiKey3, cliRunEnv) {
70722
+ if (this.disableAnalyticsSharing) {
70723
+ return;
70724
+ }
70720
70725
  if (this.socketMode) {
70721
70726
  return (await this.socketAPI.createSocketTier1Scan(cliOptions, cliVersion)).tier1_reachability_scan_id;
70722
70727
  } else {
@@ -70733,6 +70738,9 @@ var DashboardAPI = class {
70733
70738
  }
70734
70739
  }
70735
70740
  async sendErrorReport(apiKey3, stackTrace, shouldLogSharing, reportId, repoUrl, projectName, logContent) {
70741
+ if (this.disableAnalyticsSharing) {
70742
+ return;
70743
+ }
70736
70744
  if (this.socketMode) {
70737
70745
  await this.socketAPI.sendErrorReportToSocketDashboard(stackTrace, shouldLogSharing, reportId, logContent);
70738
70746
  } else {
@@ -70748,6 +70756,9 @@ var DashboardAPI = class {
70748
70756
  }
70749
70757
  }
70750
70758
  async registerSubprojects(subprojects, reportId, apiKey3) {
70759
+ if (this.disableAnalyticsSharing) {
70760
+ return;
70761
+ }
70751
70762
  if (this.socketMode) {
70752
70763
  await this.socketAPI.registerSubprojectsSocket(subprojects, reportId);
70753
70764
  } else {
@@ -70755,6 +70766,9 @@ var DashboardAPI = class {
70755
70766
  }
70756
70767
  }
70757
70768
  async registerCLIProgress(cliProgressEvent, isStartEvent, reportId, apiKey3) {
70769
+ if (this.disableAnalyticsSharing) {
70770
+ return;
70771
+ }
70758
70772
  if (this.socketMode) {
70759
70773
  await this.socketAPI.registerCLIProgressSocket(isStartEvent, cliProgressEvent, reportId);
70760
70774
  } else {
@@ -70762,6 +70776,9 @@ var DashboardAPI = class {
70762
70776
  }
70763
70777
  }
70764
70778
  async registerAnalysisMetadata(subprojectPath, workspacePath, ecosystem, analysisMetadata, reportId, apiKey3) {
70779
+ if (this.disableAnalyticsSharing) {
70780
+ return;
70781
+ }
70765
70782
  if (this.socketMode) {
70766
70783
  await this.socketAPI.registerAnalysisMetadataSocket(
70767
70784
  subprojectPath,
@@ -93793,7 +93810,7 @@ var ecosystemAnalyzer = {
93793
93810
  RUST: RustAnalyzer
93794
93811
  };
93795
93812
  var apiKey2 = COANA_API_KEY ? { type: "present", value: COANA_API_KEY } : { type: "missing" };
93796
- var dashboardAPI = new DashboardAPI(process.env.SOCKET_MODE === "true");
93813
+ var dashboardAPI = new DashboardAPI(process.env.SOCKET_MODE === "true", process.env.DISABLE_ANALYTICS_SHARING === "true");
93797
93814
  async function runReachabilityAnalysis(state) {
93798
93815
  const projectDir = resolve16(state.subprojectDir, state.workspacePath);
93799
93816
  const ecosystem = state.workspaceData.data.type;