@coana-tech/cli 14.12.134 → 14.12.136

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
@@ -200720,12 +200720,12 @@ var require_file_upload = __commonJS({
200720
200720
  function getAllFileUploadsToComplete(fileUploads) {
200721
200721
  const toComplete = {};
200722
200722
  fileUploads.forEach((upload) => {
200723
- const { channel_id, thread_ts, initial_comment, file_id, title } = upload;
200723
+ const { channel_id, thread_ts, initial_comment, file_id, title: title2 } = upload;
200724
200724
  if (file_id) {
200725
200725
  const compareString = `:::${channel_id}:::${thread_ts}:::${initial_comment}`;
200726
200726
  if (!Object.prototype.hasOwnProperty.call(toComplete, compareString)) {
200727
200727
  toComplete[compareString] = {
200728
- files: [{ id: file_id, title }],
200728
+ files: [{ id: file_id, title: title2 }],
200729
200729
  channel_id,
200730
200730
  initial_comment,
200731
200731
  thread_ts
@@ -200733,7 +200733,7 @@ var require_file_upload = __commonJS({
200733
200733
  } else {
200734
200734
  toComplete[compareString].files.push({
200735
200735
  id: file_id,
200736
- title
200736
+ title: title2
200737
200737
  });
200738
200738
  }
200739
200739
  } else {
@@ -236363,6 +236363,455 @@ function toSocketReachabilitySchema(vulnerability) {
236363
236363
  throw new Error("Unknown codeAwareScanResult type");
236364
236364
  }
236365
236365
 
236366
+ // dist/results-summary-display.js
236367
+ var TABLE_WIDTH = 132;
236368
+ var SEPARATOR_CHAR = "\u2550";
236369
+ var TIER2_FALLBACK_MESSAGE = "Reachability falls back to Tier 2 (precomputed) results for affected vulnerabilities";
236370
+ var SEPARATOR = SEPARATOR_CHAR.repeat(TABLE_WIDTH);
236371
+ function displayResultsSummary(vulns, workspaceTimings) {
236372
+ try {
236373
+ displayResultsSummaryInternal(vulns, workspaceTimings);
236374
+ } catch (error) {
236375
+ const errorMessage = error instanceof Error ? error.message : String(error);
236376
+ logger.warn(`Unable to compute results summary. Failed with error: ${errorMessage}`);
236377
+ }
236378
+ }
236379
+ function displayResultsSummaryInternal(vulns, workspaceTimings) {
236380
+ const ecosystemToWorkspaceToVulnResults = /* @__PURE__ */ new Map();
236381
+ const getResultPriority = (reachability, resultType) => {
236382
+ if (resultType === "analysisError")
236383
+ return 3;
236384
+ if (reachability === "REACHABLE")
236385
+ return 2;
236386
+ if (reachability === "UNREACHABLE")
236387
+ return 1;
236388
+ return 0;
236389
+ };
236390
+ for (const vuln of vulns) {
236391
+ const ecosystem = vuln.ecosystem;
236392
+ const workspace = vuln.subprojectPath === "." && vuln.workspacePath !== "." ? vuln.workspacePath : vuln.subprojectPath;
236393
+ const resultType = vuln.codeAwareScanResult.type;
236394
+ const reachability = vuln.reachability;
236395
+ const vulnUrl = vuln.vulnerabilityUrl;
236396
+ if (!ecosystemToWorkspaceToVulnResults.has(ecosystem)) {
236397
+ ecosystemToWorkspaceToVulnResults.set(ecosystem, /* @__PURE__ */ new Map());
236398
+ }
236399
+ const workspaceMap = ecosystemToWorkspaceToVulnResults.get(ecosystem);
236400
+ if (!workspaceMap.has(workspace)) {
236401
+ workspaceMap.set(workspace, /* @__PURE__ */ new Map());
236402
+ }
236403
+ const vulnResultsMap = workspaceMap.get(workspace);
236404
+ const existingResult = vulnResultsMap.get(vulnUrl);
236405
+ const newPriority = getResultPriority(reachability, resultType);
236406
+ if (!existingResult || newPriority > getResultPriority(existingResult.reachability, existingResult.resultType)) {
236407
+ vulnResultsMap.set(vulnUrl, { reachability, resultType });
236408
+ }
236409
+ }
236410
+ const ecosystemToWorkspaceStats = /* @__PURE__ */ new Map();
236411
+ for (const [ecosystem, workspaceMap] of ecosystemToWorkspaceToVulnResults) {
236412
+ const workspaceStatsMap = /* @__PURE__ */ new Map();
236413
+ ecosystemToWorkspaceStats.set(ecosystem, workspaceStatsMap);
236414
+ for (const [workspace, vulnResultsMap] of workspaceMap) {
236415
+ const stats = {
236416
+ vulnerabilities: 0,
236417
+ reachable: 0,
236418
+ unreachable: 0,
236419
+ missingPattern: 0,
236420
+ noAnalysisCheck: 0,
236421
+ unknownFiltered: 0,
236422
+ analysisError: 0,
236423
+ resultTypes: /* @__PURE__ */ new Map()
236424
+ };
236425
+ workspaceStatsMap.set(workspace, stats);
236426
+ for (const [, { reachability, resultType }] of vulnResultsMap) {
236427
+ stats.vulnerabilities++;
236428
+ if (reachability === "REACHABLE") {
236429
+ stats.reachable++;
236430
+ } else if (reachability === "UNREACHABLE") {
236431
+ stats.unreachable++;
236432
+ } else {
236433
+ if (resultType === "missingVulnerabilityPattern") {
236434
+ stats.missingPattern++;
236435
+ } else if (resultType === "noAnalysisCheck") {
236436
+ stats.noAnalysisCheck++;
236437
+ } else if (resultType === "unknown") {
236438
+ stats.unknownFiltered++;
236439
+ } else if (resultType === "analysisError") {
236440
+ stats.analysisError++;
236441
+ }
236442
+ }
236443
+ stats.resultTypes.set(resultType, (stats.resultTypes.get(resultType) ?? 0) + 1);
236444
+ }
236445
+ }
236446
+ }
236447
+ if (ecosystemToWorkspaceStats.size === 0) {
236448
+ return;
236449
+ }
236450
+ const output = [];
236451
+ output.push("");
236452
+ output.push(SEPARATOR);
236453
+ output.push(bold(" REACHABILITY ANALYSIS RESULTS "));
236454
+ output.push(SEPARATOR);
236455
+ const sortedEcosystems = Array.from(ecosystemToWorkspaceStats.keys()).sort();
236456
+ for (const ecosystem of sortedEcosystems) {
236457
+ const workspaceStatsMap = ecosystemToWorkspaceStats.get(ecosystem);
236458
+ const socketPurlType = getPurlType(ecosystem);
236459
+ output.push("");
236460
+ output.push(bold(`${socketPurlType}:`));
236461
+ output.push("");
236462
+ const colWidths = {
236463
+ workspace: 40,
236464
+ vulns: 6,
236465
+ reachable: 5,
236466
+ unreachable: 7,
236467
+ missingPat: 6,
236468
+ noCheck: 8,
236469
+ filtered: 8,
236470
+ error: 6,
236471
+ noiseRed: 7,
236472
+ time: 10
236473
+ };
236474
+ const header = ` ${"Project".padEnd(colWidths.workspace)} \u2502 ${"Vulns".padStart(colWidths.vulns)} \u2502 ${"Reach".padStart(colWidths.reachable)} \u2502 ${"Unreach".padStart(colWidths.unreachable)} \u2502 ${"NoSup".padStart(colWidths.missingPat)} \u2502 ${"NoReach".padStart(colWidths.noCheck)} \u2502 ${"Skipped".padStart(colWidths.filtered)} \u2502 ` + kleur_default.red("Error".padStart(colWidths.error)) + ` \u2502 ${"Noise%".padStart(colWidths.noiseRed)} \u2502 ${"Time".padStart(colWidths.time)}`;
236475
+ const rowSeparator = ` ${"\u2500".repeat(colWidths.workspace)}\u2500\u253C\u2500${"\u2500".repeat(colWidths.vulns)}\u2500\u253C\u2500${"\u2500".repeat(colWidths.reachable)}\u2500\u253C\u2500${"\u2500".repeat(colWidths.unreachable)}\u2500\u253C\u2500${"\u2500".repeat(colWidths.missingPat)}\u2500\u253C\u2500${"\u2500".repeat(colWidths.noCheck)}\u2500\u253C\u2500${"\u2500".repeat(colWidths.filtered)}\u2500\u253C\u2500${"\u2500".repeat(colWidths.error)}\u2500\u253C\u2500${"\u2500".repeat(colWidths.noiseRed)}\u2500\u253C\u2500${"\u2500".repeat(colWidths.time)}`;
236476
+ output.push(bold(header));
236477
+ output.push(rowSeparator);
236478
+ const sortedWorkspaces = Array.from(workspaceStatsMap.keys()).sort();
236479
+ for (const workspace of sortedWorkspaces) {
236480
+ const stats = workspaceStatsMap.get(workspace);
236481
+ const noiseReduction = stats.vulnerabilities > 0 ? Math.round(stats.unreachable / stats.vulnerabilities * 100) : 0;
236482
+ let workspaceDisplay;
236483
+ const displayWorkspace = workspace === "." ? ". (root project)" : workspace;
236484
+ if (displayWorkspace.length > colWidths.workspace) {
236485
+ const ellipsis = "...";
236486
+ const availableChars = colWidths.workspace - ellipsis.length;
236487
+ const startChars = Math.ceil(availableChars / 2);
236488
+ const endChars = Math.floor(availableChars / 2);
236489
+ workspaceDisplay = displayWorkspace.slice(0, startChars) + ellipsis + displayWorkspace.slice(-endChars);
236490
+ } else {
236491
+ workspaceDisplay = displayWorkspace.padEnd(colWidths.workspace);
236492
+ }
236493
+ let noiseRedStr = `${noiseReduction}%`.padStart(colWidths.noiseRed);
236494
+ if (noiseReduction >= 50) {
236495
+ noiseRedStr = kleur_default.green(noiseRedStr);
236496
+ } else if (noiseReduction > 0) {
236497
+ noiseRedStr = kleur_default.yellow(noiseRedStr);
236498
+ }
236499
+ const reachableStr = stats.reachable > 0 ? kleur_default.red(String(stats.reachable).padStart(colWidths.reachable)) : String(stats.reachable).padStart(colWidths.reachable);
236500
+ const unreachableStr = stats.unreachable > 0 ? kleur_default.green(String(stats.unreachable).padStart(colWidths.unreachable)) : String(stats.unreachable).padStart(colWidths.unreachable);
236501
+ const missingPatStr = stats.missingPattern > 0 ? kleur_default.yellow(String(stats.missingPattern).padStart(colWidths.missingPat)) : String(stats.missingPattern).padStart(colWidths.missingPat);
236502
+ const noCheckStr = stats.noAnalysisCheck > 0 ? kleur_default.yellow(String(stats.noAnalysisCheck).padStart(colWidths.noCheck)) : String(stats.noAnalysisCheck).padStart(colWidths.noCheck);
236503
+ const filteredStr = stats.unknownFiltered > 0 ? kleur_default.yellow(String(stats.unknownFiltered).padStart(colWidths.filtered)) : String(stats.unknownFiltered).padStart(colWidths.filtered);
236504
+ const errorStr = stats.analysisError > 0 ? kleur_default.bgRed().white().bold(` ${stats.analysisError} `) + " ".repeat(Math.max(0, colWidths.error - String(stats.analysisError).length - 2)) : String(stats.analysisError).padStart(colWidths.error);
236505
+ const timingKey = `${ecosystem}:${workspace}`;
236506
+ const timingMs = workspaceTimings?.get(timingKey);
236507
+ let timeStr;
236508
+ if (timingMs !== void 0) {
236509
+ if (timingMs >= 6e4) {
236510
+ const mins = Math.floor(timingMs / 6e4);
236511
+ const secs = Math.round(timingMs % 6e4 / 1e3);
236512
+ timeStr = `${mins}m${secs}s`.padStart(colWidths.time);
236513
+ } else if (timingMs >= 1e3) {
236514
+ timeStr = `${(timingMs / 1e3).toFixed(1)}s`.padStart(colWidths.time);
236515
+ } else {
236516
+ timeStr = `${timingMs}ms`.padStart(colWidths.time);
236517
+ }
236518
+ } else {
236519
+ timeStr = "-".padStart(colWidths.time);
236520
+ }
236521
+ const row = ` ${workspaceDisplay} \u2502 ${String(stats.vulnerabilities).padStart(colWidths.vulns)} \u2502 ${reachableStr} \u2502 ${unreachableStr} \u2502 ${missingPatStr} \u2502 ${noCheckStr} \u2502 ${filteredStr} \u2502 ${errorStr} \u2502 ${noiseRedStr} \u2502 ${timeStr}`;
236522
+ output.push(row);
236523
+ }
236524
+ }
236525
+ output.push("");
236526
+ output.push(kleur_default.gray(" Legend: Vulns=Vulnerabilities, Reach=Reachable, Unreach=Unreachable, NoSup=No reachability support yet,"));
236527
+ output.push(kleur_default.gray(" NoReach=Reachability analysis not possible, Skipped=Filtered through options, Error=Analysis error, Noise%=Noise reduction"));
236528
+ output.push("");
236529
+ output.push(SEPARATOR);
236530
+ logger.info(output.join("\n"));
236531
+ }
236532
+ var title = "An error occurred during the reachability analysis";
236533
+ var ERROR_CATEGORY_MESSAGES = {
236534
+ install: {
236535
+ title,
236536
+ details: [
236537
+ TIER2_FALLBACK_MESSAGE,
236538
+ "This problem can be fixed by pre-installing dependencies before running the analysis"
236539
+ ]
236540
+ },
236541
+ timeout: {
236542
+ title,
236543
+ details: [
236544
+ TIER2_FALLBACK_MESSAGE,
236545
+ "Consider increasing analysis timeout",
236546
+ "Large projects may require more resources"
236547
+ ]
236548
+ },
236549
+ memory: {
236550
+ title,
236551
+ details: [TIER2_FALLBACK_MESSAGE, "Consider increasing memory limit", "Large projects may require more resources"]
236552
+ },
236553
+ parse: {
236554
+ title,
236555
+ details: [
236556
+ TIER2_FALLBACK_MESSAGE,
236557
+ "Make sure none of the project source files contain syntax errors",
236558
+ "Make sure the analyzed languages are supported by Socket",
236559
+ "Check https://docs.socket.dev/docs/reachability-analysis#reachability-ecosystem-support for more details"
236560
+ ]
236561
+ },
236562
+ general: {
236563
+ title,
236564
+ details: [TIER2_FALLBACK_MESSAGE, "Check the logs for more details on the specific error"]
236565
+ }
236566
+ };
236567
+ var MAX_PACKAGES_TO_DISPLAY = 5;
236568
+ function displayWorkspaceDiagnosticsSummary(diagnosticsEntries, vulns) {
236569
+ try {
236570
+ displayWorkspaceDiagnosticsSummaryInternal(diagnosticsEntries, vulns);
236571
+ } catch (error) {
236572
+ const errorMessage = error instanceof Error ? error.message : String(error);
236573
+ logger.warn(`Unable to compute diagnostics summary. Failed with error: ${errorMessage}`);
236574
+ }
236575
+ }
236576
+ function displayWorkspaceDiagnosticsSummaryInternal(diagnosticsEntries, vulns) {
236577
+ const warnings = [];
236578
+ const infos = [];
236579
+ const typeToEntry = /* @__PURE__ */ new Map();
236580
+ for (const entry of diagnosticsEntries) {
236581
+ for (const warning of entry.diagnostics.warnings) {
236582
+ const existing = typeToEntry.get(warning.type);
236583
+ const workspaceLabel = `${entry.subprojectPath} (${entry.purl_type})`;
236584
+ if (existing) {
236585
+ existing.workspaces.push(workspaceLabel);
236586
+ } else {
236587
+ const isNoSourceFilesError = warning.message.toLowerCase().includes("no source files") || warning.type.toLowerCase().includes("nosource");
236588
+ const severity = isNoSourceFilesError ? "error" : warning.severity === "warning" ? "warning" : "info";
236589
+ const newEntry = {
236590
+ message: warning.message,
236591
+ workspaces: [workspaceLabel],
236592
+ severity,
236593
+ errorCategory: isNoSourceFilesError ? "NO SOURCE FILES" : void 0,
236594
+ details: isNoSourceFilesError ? [
236595
+ "Make sure to run the Tier 1 analysis in a folder that also contain the project source files for it to work properly"
236596
+ ] : void 0
236597
+ };
236598
+ typeToEntry.set(warning.type, newEntry);
236599
+ if (severity === "error" || severity === "warning") {
236600
+ warnings.push(newEntry);
236601
+ } else {
236602
+ infos.push(newEntry);
236603
+ }
236604
+ }
236605
+ }
236606
+ }
236607
+ const workspacesWithAnalysisErrors = /* @__PURE__ */ new Map();
236608
+ const analysisErrorMessages = /* @__PURE__ */ new Map();
236609
+ const failedToInstallPackages = /* @__PURE__ */ new Set();
236610
+ const categoryVulnCounts = /* @__PURE__ */ new Map();
236611
+ const workspaceVulnCounts = /* @__PURE__ */ new Map();
236612
+ for (const vuln of vulns) {
236613
+ if (vuln.codeAwareScanResult.type === "analysisError") {
236614
+ const socketPurlType = getPurlType(vuln.ecosystem);
236615
+ const workspaceLabel = `${vuln.subprojectPath} (${socketPurlType})`;
236616
+ const errorMessage = vuln.codeAwareScanResult.message ?? "";
236617
+ const errorMessageLower = errorMessage.toLowerCase();
236618
+ const packageInstallMatch = errorMessage.match(/\[UNABLE_TO_INSTALL_PACKAGE_ERROR\]: ([^\n]{1,500})/);
236619
+ if (packageInstallMatch) {
236620
+ failedToInstallPackages.add(packageInstallMatch[1]);
236621
+ }
236622
+ let category = "general";
236623
+ if (errorMessageLower.includes("install") || errorMessageLower.includes("npm") || errorMessageLower.includes("pip") || errorMessageLower.includes("dependency")) {
236624
+ category = "install";
236625
+ } else if (errorMessageLower.includes("timeout") || errorMessageLower.includes("timed out")) {
236626
+ category = "timeout";
236627
+ } else if (errorMessageLower.includes("memory") || errorMessageLower.includes("oom")) {
236628
+ category = "memory";
236629
+ } else if (errorMessageLower.includes("parse") || errorMessageLower.includes("syntax")) {
236630
+ category = "parse";
236631
+ }
236632
+ if (!workspacesWithAnalysisErrors.has(category)) {
236633
+ workspacesWithAnalysisErrors.set(category, /* @__PURE__ */ new Set());
236634
+ }
236635
+ workspacesWithAnalysisErrors.get(category).add(workspaceLabel);
236636
+ categoryVulnCounts.set(category, (categoryVulnCounts.get(category) ?? 0) + 1);
236637
+ if (!workspaceVulnCounts.has(category)) {
236638
+ workspaceVulnCounts.set(category, /* @__PURE__ */ new Map());
236639
+ }
236640
+ const wsCountsForCategory = workspaceVulnCounts.get(category);
236641
+ wsCountsForCategory.set(workspaceLabel, (wsCountsForCategory.get(workspaceLabel) ?? 0) + 1);
236642
+ if (!analysisErrorMessages.has(workspaceLabel)) {
236643
+ analysisErrorMessages.set(workspaceLabel, []);
236644
+ }
236645
+ const messages = analysisErrorMessages.get(workspaceLabel);
236646
+ if (vuln.codeAwareScanResult.message && !messages.includes(vuln.codeAwareScanResult.message)) {
236647
+ messages.push(vuln.codeAwareScanResult.message);
236648
+ }
236649
+ }
236650
+ }
236651
+ for (const [category, workspaces] of workspacesWithAnalysisErrors) {
236652
+ const categoryInfo = ERROR_CATEGORY_MESSAGES[category] ?? ERROR_CATEGORY_MESSAGES.general;
236653
+ let details = [...categoryInfo.details];
236654
+ if (category === "install" && failedToInstallPackages.size > 0) {
236655
+ const packageList = Array.from(failedToInstallPackages).sort();
236656
+ if (packageList.length <= MAX_PACKAGES_TO_DISPLAY) {
236657
+ details = [`Unable to install packages: ${packageList.join(", ")}`, ...details];
236658
+ } else {
236659
+ details = [
236660
+ `Unable to install packages: ${packageList.slice(0, MAX_PACKAGES_TO_DISPLAY).join(", ")} and ${packageList.length - MAX_PACKAGES_TO_DISPLAY} more`,
236661
+ ...details
236662
+ ];
236663
+ }
236664
+ }
236665
+ const totalCount = categoryVulnCounts.get(category) ?? 0;
236666
+ const analysisErrorEntry = {
236667
+ message: categoryInfo.title,
236668
+ workspaces: Array.from(workspaces).sort(),
236669
+ workspaceVulnCounts: workspaceVulnCounts.get(category),
236670
+ totalVulnCount: totalCount,
236671
+ severity: "error",
236672
+ errorCategory: category.toUpperCase(),
236673
+ details
236674
+ };
236675
+ typeToEntry.set(`analysisError_${category}`, analysisErrorEntry);
236676
+ warnings.push(analysisErrorEntry);
236677
+ }
236678
+ if (warnings.length === 0 && infos.length === 0) {
236679
+ return;
236680
+ }
236681
+ const totalWorkspacesPerEcosystem = /* @__PURE__ */ new Map();
236682
+ for (const entry of diagnosticsEntries) {
236683
+ totalWorkspacesPerEcosystem.set(entry.purl_type, (totalWorkspacesPerEcosystem.get(entry.purl_type) ?? 0) + 1);
236684
+ }
236685
+ const formatDetailLine = (detail) => {
236686
+ if (detail.startsWith("This problem can be fixed")) {
236687
+ return kleur_default.green(` \u2192 ${detail}`);
236688
+ }
236689
+ if (detail.includes("Tier 2") || detail.includes("precomputed")) {
236690
+ return kleur_default.dim(` \u2022 ${detail}`);
236691
+ }
236692
+ if (detail.startsWith("Unable to install packages:")) {
236693
+ const prefix = "Unable to install packages: ";
236694
+ const packagesStr = detail.slice(prefix.length);
236695
+ return ` \u2022 ${prefix}${bold(packagesStr)}`;
236696
+ }
236697
+ return ` \u2022 ${detail}`;
236698
+ };
236699
+ const buildWorkspaceLines = (workspaces, workspaceVulnCounts2) => {
236700
+ const lines = [];
236701
+ if (workspaces.length === 0) {
236702
+ return lines;
236703
+ }
236704
+ const ecosystemToWorkspaces = /* @__PURE__ */ new Map();
236705
+ for (const workspaceLabel of workspaces) {
236706
+ const match2 = workspaceLabel.match(/^(.+) \(([^)]+)\)$/);
236707
+ if (match2) {
236708
+ const [, workspace, ecosystem] = match2;
236709
+ if (!ecosystemToWorkspaces.has(ecosystem)) {
236710
+ ecosystemToWorkspaces.set(ecosystem, []);
236711
+ }
236712
+ ecosystemToWorkspaces.get(ecosystem).push(workspace);
236713
+ } else {
236714
+ if (!ecosystemToWorkspaces.has("unknown")) {
236715
+ ecosystemToWorkspaces.set("unknown", []);
236716
+ }
236717
+ ecosystemToWorkspaces.get("unknown").push(workspaceLabel);
236718
+ }
236719
+ }
236720
+ const sortedEcosystems = Array.from(ecosystemToWorkspaces.keys()).sort();
236721
+ for (const ecosystem of sortedEcosystems) {
236722
+ const wsForEcosystem = ecosystemToWorkspaces.get(ecosystem);
236723
+ const totalForEcosystem = totalWorkspacesPerEcosystem.get(ecosystem) ?? 0;
236724
+ lines.push(` ${ecosystem}:`);
236725
+ if (wsForEcosystem.length === totalForEcosystem && totalForEcosystem > 1) {
236726
+ lines.push(` each of the ${totalForEcosystem} projects`);
236727
+ } else {
236728
+ for (const ws of wsForEcosystem.sort()) {
236729
+ const workspaceLabel = `${ws} (${ecosystem})`;
236730
+ const count = workspaceVulnCounts2?.get(workspaceLabel);
236731
+ const displayName = ws === "." ? ". (root project)" : ws;
236732
+ if (count !== void 0) {
236733
+ const vulnText = count === 1 ? "vulnerability" : "vulnerabilities";
236734
+ lines.push(` ${displayName} (${count} ${vulnText})`);
236735
+ } else {
236736
+ lines.push(` ${displayName}`);
236737
+ }
236738
+ }
236739
+ }
236740
+ }
236741
+ return lines;
236742
+ };
236743
+ const output = [];
236744
+ output.push("");
236745
+ const hasErrors = warnings.some((w) => w.severity === "error");
236746
+ if (warnings.length > 0) {
236747
+ if (hasErrors) {
236748
+ const bannerWidth = TABLE_WIDTH;
236749
+ const bannerLine = "\u2588".repeat(bannerWidth);
236750
+ const emptyLine = "\u2588" + " ".repeat(bannerWidth - 2) + "\u2588";
236751
+ const titleText = "\u26A0 REACHABILITY ANALYSIS WARNINGS AND ERRORS \u26A0";
236752
+ const titlePadding = Math.floor((bannerWidth - titleText.length - 2) / 2);
236753
+ const titleLine = "\u2588" + " ".repeat(titlePadding) + titleText + " ".repeat(bannerWidth - titlePadding - titleText.length - 2) + "\u2588";
236754
+ output.push(kleur_default.bgRed().white(bannerLine));
236755
+ output.push(kleur_default.bgRed().white(emptyLine));
236756
+ output.push(kleur_default.bgRed().white().bold(titleLine));
236757
+ output.push(kleur_default.bgRed().white(emptyLine));
236758
+ output.push(kleur_default.bgRed().white(bannerLine));
236759
+ } else {
236760
+ output.push(SEPARATOR);
236761
+ output.push(bold(" REACHABILITY ANALYSIS WARNINGS AND ERRORS "));
236762
+ output.push(SEPARATOR);
236763
+ }
236764
+ for (const { message: message2, workspaces, workspaceVulnCounts: wsCounts, totalVulnCount, details, severity, errorCategory } of warnings) {
236765
+ output.push("");
236766
+ const displayMessage = message2.endsWith(".") ? message2.slice(0, -1) : message2;
236767
+ const projectsText = `${workspaces.length} project${workspaces.length === 1 ? "" : "s"}`;
236768
+ const vulnsText = totalVulnCount ? ` / ${totalVulnCount} vulnerabilit${totalVulnCount === 1 ? "y" : "ies"}` : "";
236769
+ if (severity === "error") {
236770
+ const categoryLabel = errorCategory ? `${errorCategory} ERROR` : "ERROR";
236771
+ output.push(kleur_default.bgRed().white().bold(` \u2716 ${categoryLabel} `) + ` ${displayMessage}. Affecting ${bold(`${projectsText}${vulnsText}`)}:`);
236772
+ } else {
236773
+ output.push(kleur_default.yellow("\u26A0") + ` ${displayMessage} of ${bold(`${projectsText}${vulnsText}`)}:`);
236774
+ }
236775
+ output.push(...buildWorkspaceLines(workspaces, wsCounts));
236776
+ if (details && details.length > 0) {
236777
+ output.push(bold(" Details:"));
236778
+ for (const detail of details) {
236779
+ output.push(formatDetailLine(detail));
236780
+ }
236781
+ }
236782
+ }
236783
+ output.push("");
236784
+ if (hasErrors) {
236785
+ const bannerLine = "\u2588".repeat(TABLE_WIDTH);
236786
+ output.push(kleur_default.bgRed().white(bannerLine));
236787
+ } else {
236788
+ output.push(SEPARATOR);
236789
+ }
236790
+ output.push("");
236791
+ }
236792
+ if (infos.length > 0) {
236793
+ output.push(SEPARATOR);
236794
+ output.push(bold(" REACHABILITY ANALYSIS INFO "));
236795
+ output.push(SEPARATOR);
236796
+ for (const { message: message2, workspaces, details } of infos) {
236797
+ output.push("");
236798
+ const displayMessage = message2.endsWith(".") ? message2.slice(0, -1) : message2;
236799
+ output.push(kleur_default.cyan("\u2139") + ` ${displayMessage}:`);
236800
+ output.push(...buildWorkspaceLines(workspaces));
236801
+ if (details && details.length > 0) {
236802
+ output.push("");
236803
+ for (const detail of details) {
236804
+ output.push(` ${detail}`);
236805
+ }
236806
+ }
236807
+ }
236808
+ output.push("");
236809
+ output.push(SEPARATOR);
236810
+ output.push("");
236811
+ }
236812
+ logger.info(output.join("\n"));
236813
+ }
236814
+
236366
236815
  // dist/internal/socket-report-socket-dependency-tree.js
236367
236816
  function toSocketFactsSocketDependencyTree(artifacts, vulnerabilities, tier1ReachabilityScanId, workspaceDiagnostics) {
236368
236817
  const artifactIdToArtifact = Object.fromEntries(artifacts.map((artifact) => [artifact.id, artifact]));
@@ -251285,7 +251734,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
251285
251734
  }
251286
251735
 
251287
251736
  // dist/version.js
251288
- var version3 = "14.12.134";
251737
+ var version3 = "14.12.136";
251289
251738
 
251290
251739
  // dist/cli-core.js
251291
251740
  var { mapValues, omit, partition, pickBy: pickBy2 } = import_lodash15.default;
@@ -251515,6 +251964,7 @@ var CliCore = class {
251515
251964
  });
251516
251965
  const vulnsWithResults = [];
251517
251966
  const allWorkspaceDiagnostics = [];
251967
+ const allWorkspaceTimings = /* @__PURE__ */ new Map();
251518
251968
  const allEcosystems = Object.entries(ecosystemToWorkspaceToAnalysisData);
251519
251969
  const totalEcosystems = allEcosystems.length;
251520
251970
  let currentOverallWorkspace = 0;
@@ -251524,7 +251974,7 @@ var CliCore = class {
251524
251974
  if (!isEcosystemToAnalyze) {
251525
251975
  logger.info(`Skipping reachability analysis for ecosystem ${getPurlType(ecosystem)} since it is not included in the list of ecosystems to analyze.`);
251526
251976
  }
251527
- const { vulnerabilities, diagnostics } = await this.runReachabilityAnalysisForWorkspaces(
251977
+ const { vulnerabilities, diagnostics, timings } = await this.runReachabilityAnalysisForWorkspaces(
251528
251978
  workspaceToAnalysisData,
251529
251979
  ecosystemToWorkspaceToVulnerabilities[ecosystem] ?? {},
251530
251980
  {},
@@ -251547,72 +251997,20 @@ var CliCore = class {
251547
251997
  purl_type: getPurlType(ecosystem),
251548
251998
  diagnostics: workspaceDiagnostics
251549
251999
  });
252000
+ if (timings[workspacePath] !== void 0) {
252001
+ allWorkspaceTimings.set(`${ecosystem}:${workspacePath}`, timings[workspacePath]);
252002
+ }
251550
252003
  }
251551
252004
  this.sendProgress("RUN_ON_SUBPROJECT", false, this.rootWorkingDirectory);
251552
252005
  }
251553
- this.displayWorkspaceDiagnosticsSummary(allWorkspaceDiagnostics);
252006
+ displayResultsSummary(vulnsWithResults, allWorkspaceTimings);
252007
+ displayWorkspaceDiagnosticsSummary(allWorkspaceDiagnostics, vulnsWithResults);
251554
252008
  await this.shareLogIfAnalysisError(vulnsWithResults);
251555
252009
  const socketReport = toSocketFactsSocketDependencyTree(artifacts, vulnsWithResults, this.reportId, allWorkspaceDiagnostics);
251556
252010
  const outputFile = resolve43(this.options.socketMode);
251557
252011
  await writeFile13(outputFile, JSON.stringify(socketReport, null, 2));
251558
252012
  logger.info(kleur_default.green(`Socket report written to: ${outputFile}`));
251559
252013
  }
251560
- displayWorkspaceDiagnosticsSummary(diagnosticsEntries) {
251561
- const warnings = [];
251562
- const infos = [];
251563
- const typeToEntry = /* @__PURE__ */ new Map();
251564
- for (const entry of diagnosticsEntries) {
251565
- for (const warning of entry.diagnostics.warnings) {
251566
- const existing = typeToEntry.get(warning.type);
251567
- const workspaceLabel = `${entry.subprojectPath} (${entry.purl_type})`;
251568
- if (existing) {
251569
- existing.workspaces.push(workspaceLabel);
251570
- } else {
251571
- const newEntry = { message: warning.message, workspaces: [workspaceLabel], severity: warning.severity };
251572
- typeToEntry.set(warning.type, newEntry);
251573
- if (warning.severity === "warning") {
251574
- warnings.push(newEntry);
251575
- } else {
251576
- infos.push(newEntry);
251577
- }
251578
- }
251579
- }
251580
- }
251581
- if (warnings.length === 0 && infos.length === 0) {
251582
- return;
251583
- }
251584
- logger.info("");
251585
- if (warnings.length > 0) {
251586
- logger.info(bold(kleur_default.red("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")));
251587
- logger.info(bold(kleur_default.red(" REACHABILITY ANALYSIS WARNINGS ")));
251588
- logger.info(bold(kleur_default.red("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")));
251589
- for (const { message: message2, workspaces } of warnings) {
251590
- logger.info("");
251591
- logger.info(kleur_default.red(`\u26A0 ${message2}:`));
251592
- for (const workspace of workspaces) {
251593
- logger.info(kleur_default.red(` ${workspace}`));
251594
- }
251595
- }
251596
- logger.info("");
251597
- logger.info(bold(kleur_default.red("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")));
251598
- logger.info("");
251599
- }
251600
- if (infos.length > 0) {
251601
- logger.info(bold(kleur_default.cyan("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")));
251602
- logger.info(bold(kleur_default.cyan(" REACHABILITY ANALYSIS INFO ")));
251603
- logger.info(bold(kleur_default.cyan("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")));
251604
- for (const { message: message2, workspaces } of infos) {
251605
- logger.info("");
251606
- logger.info(kleur_default.cyan(`\u2139 ${message2}:`));
251607
- for (const workspace of workspaces) {
251608
- logger.info(kleur_default.cyan(` ${workspace}`));
251609
- }
251610
- }
251611
- logger.info("");
251612
- logger.info(bold(kleur_default.cyan("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")));
251613
- logger.info("");
251614
- }
251615
- }
251616
252014
  async shareLogIfAnalysisError(vulns) {
251617
252015
  if (this.dashboardAPI.disableAnalyticsSharing) {
251618
252016
  return;
@@ -251874,8 +252272,10 @@ Subproject: ${subproject}`);
251874
252272
  npmProjectDirPool = new ProjectDirPool(subprojectPath, copies);
251875
252273
  }
251876
252274
  }
252275
+ const workspaceTimings = {};
251877
252276
  try {
251878
252277
  const workspaceToAugmentedVulnerabilities = Object.fromEntries(await asyncMap(workspaces, async (workspacePath, index2) => {
252278
+ const startTime = Date.now();
251879
252279
  analysisStarting?.(workspacePath, index2 + 1, totalWorkspaces);
251880
252280
  const vulnerabilities2 = workspaceToVulnerabilities[workspacePath] ?? [];
251881
252281
  const workspacePrefix = shouldIncludeWorkspaceInLogs ? `[${workspacePath}] ` : "";
@@ -251974,6 +252374,8 @@ Subproject: ${subproject}`);
251974
252374
  }
251975
252375
  }
251976
252376
  ];
252377
+ } finally {
252378
+ workspaceTimings[workspacePath] = Date.now() - startTime;
251977
252379
  }
251978
252380
  }, concurrency));
251979
252381
  const successfulWorkspaceToResults = Object.fromEntries(Object.entries(workspaceToAugmentedVulnerabilities).filter(([_, vulns]) => vulns !== void 0));
@@ -251983,7 +252385,7 @@ Subproject: ${subproject}`);
251983
252385
  }
251984
252386
  const vulnerabilities = mapValues(successfulWorkspaceToAugmentedVulnerabilities, (augmentedVulnerabilities, workspacePath) => this.transformToReportVulnerabilities(augmentedVulnerabilities, workspaceToDirectDependencies[workspacePath] ?? {}, subprojectPath, workspacePath, this.rootWorkingDirectory));
251985
252387
  const diagnostics = mapValues(successfulWorkspaceToResults, (result) => result.diagnostics);
251986
- return { vulnerabilities, diagnostics };
252388
+ return { vulnerabilities, diagnostics, timings: workspaceTimings };
251987
252389
  } finally {
251988
252390
  await npmProjectDirPool?.cleanup();
251989
252391
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.12.134",
3
+ "version": "14.12.136",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {