@coana-tech/cli 13.19.3 → 13.19.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.
Files changed (2) hide show
  1. package/cli.js +42 -17
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -95630,7 +95630,9 @@ var init_constants3 = __esm({
95630
95630
  "REACHABILITY_ANALYZERS_SCRIPT_PATH",
95631
95631
  "JAVA_HOME",
95632
95632
  "GRADLE_HOME",
95633
- "SBT_HOME"
95633
+ "SBT_HOME",
95634
+ "HOME",
95635
+ "USER"
95634
95636
  ];
95635
95637
  }
95636
95638
  });
@@ -95800,7 +95802,7 @@ var init_other_modules_communicator = __esm({
95800
95802
  }
95801
95803
  async runInDocker(image, entryPoint, commandName, args2, subprojectPath, tmpDir, env = process.env) {
95802
95804
  const envArgs = Object.keys(env).filter((key) => !DOCKER_ENV_VARS_BLACKLIST.includes(key)).flatMap((key) => ["-e", key]);
95803
- const cmd = cmdt`docker run --pull always -v ${this.rootWorkingDir}:/project -v ${tmpDir}:${tmpDir}
95805
+ const cmd = cmdt`docker run --pull always --rm -v ${this.rootWorkingDir}:/project -v ${tmpDir}:${tmpDir}
95804
95806
  -v=${this.options.coanaLogPath}:${this.options.coanaLogPath}
95805
95807
  ${envArgs} ${image} ${entryPoint} ${commandName} ${args2}`;
95806
95808
  return await execPipeAndLogOnFailure(cmd, subprojectPath, { env });
@@ -130103,6 +130105,7 @@ __export(dashboard_integration_exports, {
130103
130105
  sendCLIProgressToDashboard: () => sendCLIProgressToDashboard,
130104
130106
  sendDependencyTreesToDashboard: () => sendDependencyTreesToDashboard,
130105
130107
  sendErrorReportToDashboard: () => sendErrorReportToDashboard,
130108
+ sendLogToDashboard: () => sendLogToDashboard,
130106
130109
  sendRegressionsToDashboard: () => sendRegressionsToDashboard,
130107
130110
  sendToDashboard: () => sendToDashboard,
130108
130111
  sendWarningToDashboard: () => sendWarningToDashboard,
@@ -130302,6 +130305,17 @@ async function sendErrorReportToDashboard(apiKey, stackTrace, shouldLogSharing,
130302
130305
  console.log("Error submitting crash report to dashboard:", e);
130303
130306
  }
130304
130307
  }
130308
+ async function sendLogToDashboard(logContent, reportId, apiKey) {
130309
+ if (!logContent) return;
130310
+ logger.info("Sending log to Coana");
130311
+ try {
130312
+ await sendPostRequest(coanaAPIUrls.SEND_LOG.replace(":reportId", reportId), apiKey, { reportId }, {
130313
+ logContent
130314
+ });
130315
+ } catch (error) {
130316
+ logger.warn("Unable to send log to dashboard:", error.message);
130317
+ }
130318
+ }
130305
130319
  async function sendPostRequest(url2, apiKey, params, data2) {
130306
130320
  const axiosConfig = {
130307
130321
  headers: {
@@ -130327,6 +130341,7 @@ var init_dashboard_integration = __esm({
130327
130341
  CREATE_ANALYSIS_METADATA: `${coanaAPI}/reports/:reportId/analysis-metadata`,
130328
130342
  REPORT_CLI_PROGRESS: `${coanaAPI}/reports/:reportId/cli-progress`,
130329
130343
  CREATE_REGRESSIONS: `${coanaAPI}/reports/:reportId/regressions`,
130344
+ SEND_LOG: `${coanaAPI}/reports/:reportId/log`,
130330
130345
  GET_LATEST_BUCKETS: `${coanaAPI}/latest-buckets`,
130331
130346
  GET_LATEST_RESULTS: `${coanaAPI}/latest-results`,
130332
130347
  GET_EXPERIMENT_NAME: `${coanaAPI}/experiment-name`,
@@ -190115,7 +190130,7 @@ var require_version = __commonJS({
190115
190130
  "use strict";
190116
190131
  Object.defineProperty(exports2, "__esModule", { value: true });
190117
190132
  exports2.version = void 0;
190118
- exports2.version = "13.19.3";
190133
+ exports2.version = "13.19.4";
190119
190134
  }
190120
190135
  });
190121
190136
 
@@ -190210,24 +190225,31 @@ var require_cli_core = __commonJS({
190210
190225
  } catch (e) {
190211
190226
  await this.spinner.fail();
190212
190227
  logger_singleton_1.logger.error("CLI failed with error:", e);
190213
- await this.shareLogWithDashboard(e, true);
190228
+ await this.shareErrorLogWithDashboard(e, true);
190214
190229
  throw e;
190215
190230
  }
190216
190231
  }
190217
- async shareLogWithDashboard(e, shouldLogSharing) {
190232
+ async getLogContent() {
190233
+ await logger_singleton_1.logger.finish();
190234
+ let logContent;
190235
+ try {
190236
+ logContent = await (0, promises_12.readFile)(this.coanaLogPath, "utf-8");
190237
+ } catch (e) {
190238
+ this.spinner.suspend(() => {
190239
+ console.error("Error reading log file", e);
190240
+ });
190241
+ }
190242
+ return logContent;
190243
+ }
190244
+ async shareErrorLogWithDashboard(e, shouldLogSharing) {
190218
190245
  if (this.options.apiKey) {
190219
- await logger_singleton_1.logger.finish();
190220
- let logContent;
190221
- try {
190222
- logContent = await (0, promises_12.readFile)(this.coanaLogPath, "utf-8");
190223
- } catch (e2) {
190224
- this.spinner.suspend(() => {
190225
- console.error("Error reading log file", e2);
190226
- });
190227
- }
190228
- await (0, dashboard_integration_1.sendErrorReportToDashboard)(this.options.apiKey, e.stack ?? e.message ?? "Unknown stack trace", shouldLogSharing, this.options.repoUrl, this.options.projectName, logContent);
190246
+ await (0, dashboard_integration_1.sendErrorReportToDashboard)(this.options.apiKey, e.stack ?? e.message ?? "Unknown stack trace", shouldLogSharing, this.options.repoUrl, this.options.projectName, await this.getLogContent());
190229
190247
  }
190230
190248
  }
190249
+ async shareLogWithDashboard() {
190250
+ if (this.options.apiKey && this.reportId)
190251
+ await (0, dashboard_integration_1.sendLogToDashboard)(await this.getLogContent(), this.reportId, this.options.apiKey);
190252
+ }
190231
190253
  async outputAndShareReport(report) {
190232
190254
  logger_singleton_1.logger.info("Report computed successfully");
190233
190255
  const outputDir = this.options.outputDir;
@@ -190252,9 +190274,12 @@ var require_cli_core = __commonJS({
190252
190274
  }
190253
190275
  if (report.vulnerabilities.some((v) => v.codeAwareScanResult.type === "analysisError")) {
190254
190276
  logger_singleton_1.logger.warn("Analysis error detected in the report - sharing log with Coana to help debug the issue");
190255
- await this.shareLogWithDashboard(new Error("Sharing log due to analysis error"), false);
190277
+ await this.shareErrorLogWithDashboard(new Error("Sharing log due to analysis error"), false);
190256
190278
  } else if (report.vulnerabilities.some((v) => v.ecosystem === "PIP")) {
190257
- await this.shareLogWithDashboard(new Error("Sharing log file for run including a python project"), false);
190279
+ await this.shareErrorLogWithDashboard(new Error("Sharing log file for run including a python project"), false);
190280
+ }
190281
+ if (this.options.runEnv === "MANAGED_SCAN") {
190282
+ this.shareLogWithDashboard();
190258
190283
  }
190259
190284
  if (this.options.printReport) {
190260
190285
  logger_singleton_1.logger.info(JSON.stringify((0, lodash_1.omit)(report, "dependencyTrees"), null, 2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "13.19.3",
3
+ "version": "13.19.4",
4
4
  "description": "Coana CLI",
5
5
  "bin": {
6
6
  "@coana-tech/cli": "./cli.js"