@coana-tech/cli 13.19.2 → 13.19.3

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 +98 -13
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -130101,6 +130101,7 @@ __export(dashboard_integration_exports, {
130101
130101
  getExperimentName: () => getExperimentName,
130102
130102
  getPreviousAnalysisResults: () => getPreviousAnalysisResults,
130103
130103
  sendCLIProgressToDashboard: () => sendCLIProgressToDashboard,
130104
+ sendDependencyTreesToDashboard: () => sendDependencyTreesToDashboard,
130104
130105
  sendErrorReportToDashboard: () => sendErrorReportToDashboard,
130105
130106
  sendRegressionsToDashboard: () => sendRegressionsToDashboard,
130106
130107
  sendToDashboard: () => sendToDashboard,
@@ -130249,6 +130250,22 @@ async function sendWarningToDashboard(message2, data2, additionalData, reportId,
130249
130250
  logger.warn("Unable to send warning to dashboard:", error.message);
130250
130251
  }
130251
130252
  }
130253
+ async function sendDependencyTreesToDashboard(dependencyTrees, reportId, apiKey) {
130254
+ try {
130255
+ await sendPostRequest(
130256
+ coanaAPIUrls.SEND_DEPENDENCY_TREES.replace(":reportId", reportId),
130257
+ apiKey,
130258
+ {},
130259
+ dependencyTrees
130260
+ );
130261
+ } catch (e) {
130262
+ sendWarningToDashboard("Unable to send dependency trees", { reportId }, void 0, reportId, apiKey);
130263
+ logger.warn(
130264
+ "Unable to send dependency trees:",
130265
+ e.message
130266
+ );
130267
+ }
130268
+ }
130252
130269
  async function sendToDashboard(report, writeReportToFile, reportId, apiKey) {
130253
130270
  try {
130254
130271
  if (writeReportToFile) {
@@ -130313,7 +130330,8 @@ var init_dashboard_integration = __esm({
130313
130330
  GET_LATEST_BUCKETS: `${coanaAPI}/latest-buckets`,
130314
130331
  GET_LATEST_RESULTS: `${coanaAPI}/latest-results`,
130315
130332
  GET_EXPERIMENT_NAME: `${coanaAPI}/experiment-name`,
130316
- REPORT_WARNING: `${coanaAPI}/cli/warn`
130333
+ REPORT_WARNING: `${coanaAPI}/cli/warn`,
130334
+ SEND_DEPENDENCY_TREES: `${coanaAPI}/reports/:reportId/dependency-trees`
130317
130335
  };
130318
130336
  reportSubmitEndpoint = process.env.COANA_CLI_SUBMIT_ENDPOINT ?? "https://app.coana.tech/api/v1/reports/submit";
130319
130337
  errorSubmitEndpoint = process.env.COANA_CLI_ERROR_SUBMIT_ENDPOINT ?? "https://app.coana.tech/api/v1/cli/error";
@@ -189074,13 +189092,56 @@ var init_slack = __esm({
189074
189092
  });
189075
189093
 
189076
189094
  // ../web-compat-utils/src/dependency-tree.ts
189095
+ var dependency_tree_exports = {};
189096
+ __export(dependency_tree_exports, {
189097
+ ADVISORY_ECOSYSTEMS: () => ADVISORY_ECOSYSTEMS,
189098
+ ADVISORY_SEVERITIES: () => ADVISORY_SEVERITIES,
189099
+ PACKAGE_MANAGERS: () => PACKAGE_MANAGERS,
189100
+ getEcosystem: () => getEcosystem,
189101
+ mergeDependencyTrees: () => mergeDependencyTrees,
189102
+ toPlainDependencyTree: () => toPlainDependencyTree
189103
+ });
189077
189104
  function getEcosystem({ ecosystem }) {
189078
189105
  return ecosystem ?? "NPM";
189079
189106
  }
189080
- var ADVISORY_ECOSYSTEMS;
189107
+ function mergeDependencyTrees(dependencyTrees) {
189108
+ if (dependencyTrees.length === 1) return dependencyTrees[0];
189109
+ const newTree = {
189110
+ ...dependencyTrees[0],
189111
+ transitiveDependencies: {},
189112
+ dependencies: []
189113
+ };
189114
+ for (const dependencyTree of dependencyTrees) {
189115
+ if (dependencyTree.dependencies)
189116
+ newTree.dependencies = i([...newTree.dependencies, ...dependencyTree.dependencies ?? []]);
189117
+ for (const [identifier, node] of Object.entries(dependencyTree.transitiveDependencies)) {
189118
+ if (!newTree.transitiveDependencies[identifier])
189119
+ newTree.transitiveDependencies[identifier] = { ...node, dependencies: [...node.dependencies ?? []] };
189120
+ else {
189121
+ const existingNode = newTree.transitiveDependencies[identifier];
189122
+ existingNode.dependencies = i([...existingNode.dependencies ?? [], ...node.dependencies ?? []]);
189123
+ }
189124
+ }
189125
+ }
189126
+ return newTree;
189127
+ }
189128
+ function toPlainDependencyTree(dependencyTree) {
189129
+ function pickNode(node) {
189130
+ return a(node, ["packageName", "version", "dependencies", "resolvedType"]);
189131
+ }
189132
+ return {
189133
+ ...pickNode(dependencyTree),
189134
+ transitiveDependencies: Object.fromEntries(
189135
+ Object.entries(dependencyTree.transitiveDependencies).map(([key, value]) => [key, pickNode(value)])
189136
+ ),
189137
+ ecosystem: dependencyTree.ecosystem
189138
+ };
189139
+ }
189140
+ var ADVISORY_ECOSYSTEMS, ADVISORY_SEVERITIES, PACKAGE_MANAGERS;
189081
189141
  var init_dependency_tree = __esm({
189082
189142
  "../web-compat-utils/src/dependency-tree.ts"() {
189083
189143
  "use strict";
189144
+ init_dist();
189084
189145
  ADVISORY_ECOSYSTEMS = [
189085
189146
  "COMPOSER",
189086
189147
  "ERLANG",
@@ -189095,6 +189156,24 @@ var init_dependency_tree = __esm({
189095
189156
  "RUST",
189096
189157
  "SWIFT"
189097
189158
  ];
189159
+ ADVISORY_SEVERITIES = ["info", "INFO", "low", "LOW", "moderate", "MODERATE", "high", "HIGH", "critical", "CRITICAL"];
189160
+ PACKAGE_MANAGERS = [
189161
+ "NPM",
189162
+ "PNPM",
189163
+ "YARN",
189164
+ "RUSH",
189165
+ "MAVEN",
189166
+ "GRADLE",
189167
+ "SBT",
189168
+ "POETRY",
189169
+ "PIP_REQUIREMENTS",
189170
+ "PIPENV",
189171
+ "GO",
189172
+ "CARGO",
189173
+ "NUGET",
189174
+ "RUBYGEMS",
189175
+ "COMPOSER"
189176
+ ];
189098
189177
  }
189099
189178
  });
189100
189179
 
@@ -190036,7 +190115,7 @@ var require_version = __commonJS({
190036
190115
  "use strict";
190037
190116
  Object.defineProperty(exports2, "__esModule", { value: true });
190038
190117
  exports2.version = void 0;
190039
- exports2.version = "13.19.2";
190118
+ exports2.version = "13.19.3";
190040
190119
  }
190041
190120
  });
190042
190121
 
@@ -190071,6 +190150,7 @@ var require_cli_core = __commonJS({
190071
190150
  var dashboard_integration_1 = (init_dashboard_integration(), __toCommonJS(dashboard_integration_exports));
190072
190151
  var vulnerability_scanning_1 = require_vulnerability_scanning();
190073
190152
  var version_12 = require_version();
190153
+ var dependency_tree_1 = (init_dependency_tree(), __toCommonJS(dependency_tree_exports));
190074
190154
  var CliCore = class {
190075
190155
  options;
190076
190156
  spinner;
@@ -190226,18 +190306,10 @@ var require_cli_core = __commonJS({
190226
190306
  await this.spinner.setText(`Compiling report`);
190227
190307
  const allVulnerabilities = workspacesOutput.flatMap(({ vulnerabilities }) => vulnerabilities);
190228
190308
  this.spinner.stop();
190229
- const dependencyTrees = workspacesOutput.map(({ subprojectPath, workspacePath, dependencyTree }) => ({
190230
- treeType: "v1",
190231
- dependencyTree,
190232
- ecosystem: dependencyTree.ecosystem ?? "NPM",
190233
- workspacePath,
190234
- subprojectPath
190235
- }));
190236
190309
  const report = {
190237
- reportType: "v6",
190310
+ reportType: "v7",
190238
190311
  vulnerabilities: allVulnerabilities,
190239
- ...await this.createMetadataForReport(manager, startTime),
190240
- dependencyTrees: dependencyTrees.flat()
190312
+ ...await this.createMetadataForReport(manager, startTime)
190241
190313
  };
190242
190314
  return report;
190243
190315
  }
@@ -190365,6 +190437,19 @@ var require_cli_core = __commonJS({
190365
190437
  this.sendProgress("PREPARE_PROJECT_AND_GET_PROJECT_DATA", true, subprojectPath);
190366
190438
  const projectInfo = await otherModulesCommunicator.prepareProjectAndGetProjectData(packageManagerName, subprojectPath, workspacePaths, this.options.lightweightReachability, this.options.providerProject ? await this.runOnProvider(this.options.providerProject) : void 0);
190367
190439
  this.sendProgress("PREPARE_PROJECT_AND_GET_PROJECT_DATA", false, subprojectPath);
190440
+ const workspaceToPlainDependencyTree = Object.fromEntries(workspacePaths.map((workspacePath) => [
190441
+ workspacePath,
190442
+ (0, dependency_tree_1.toPlainDependencyTree)(projectInfo[workspacePath].dataForAnalysis.dependencyTree)
190443
+ ]));
190444
+ const dependencyTrees = workspacePaths.map((workspacePath) => ({
190445
+ treeType: "v1",
190446
+ dependencyTree: workspaceToPlainDependencyTree[workspacePath],
190447
+ ecosystem: workspaceToPlainDependencyTree[workspacePath].ecosystem ?? "NPM",
190448
+ workspacePath,
190449
+ subprojectPath: (0, path_1.relative)(rootWorkingDirectory, subprojectPath) || "."
190450
+ }));
190451
+ if (this.shareWithDashboard)
190452
+ (0, dashboard_integration_1.sendDependencyTreesToDashboard)(dependencyTrees, this.reportId, this.options.apiKey);
190368
190453
  const workspaceToVulnerabilities = Object.fromEntries(await (0, async_1.asyncMap)(workspacePaths, async (workspacePath) => this.spinner.wrap(`Scanning for vulnerabilities: (${subProjAndWsPath.packageManagerName}) ${(0, path_1.join)(subProjAndWsPath.subprojectPath, workspacePath)}`, async () => {
190369
190454
  const dependencyTree = projectInfo[workspacePath].dataForAnalysis.dependencyTree;
190370
190455
  this.sendProgress("SCAN_FOR_VULNERABILITIES", true, subprojectPath, workspacePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "13.19.2",
3
+ "version": "13.19.3",
4
4
  "description": "Coana CLI",
5
5
  "bin": {
6
6
  "@coana-tech/cli": "./cli.js"