@arsh342/athena 0.2.4 → 0.2.5

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 (3) hide show
  1. package/README.md +2 -1
  2. package/dist/index.cjs +296 -161
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -51,6 +51,7 @@ athena setup all
51
51
  athena setup all --auto
52
52
  athena setup semgrep
53
53
  athena setup semgrep --auto
54
+ athena doctor --fix
54
55
  ```
55
56
 
56
57
  ## Common Options
@@ -111,5 +112,5 @@ npm run build -w @arsh342/athena
111
112
  - Runs fully local (no external AI service required).
112
113
  - Supports JavaScript, TypeScript, JSX, and TSX.
113
114
  - Requires Node.js 18 or newer.
114
- - ESLint scanner support is included via optional package dependencies.
115
+ - ESLint scanner support is bundled through Athena optional package dependencies.
115
116
  - Semgrep, Docker (for nodejsscan), and Bearer CLI remain external optional tools.
package/dist/index.cjs CHANGED
@@ -214587,6 +214587,7 @@ function generateReport(startedAt, files, totalLoc, skippedFiles, config) {
214587
214587
  const units = files.flatMap((file) => file.units);
214588
214588
  const findings = files.flatMap((file) => file.findings);
214589
214589
  const severityCounts = severityOrder.reduce((acc, severity) => ({ ...acc, [severity]: findings.filter((finding) => finding.severity === severity).length }), { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 });
214590
+ const sourceBreakdown = summarizeSourceBreakdown(findings);
214590
214591
  const confidenceBands = {
214591
214592
  LOW: countBand(units, "LOW"),
214592
214593
  UNCERTAIN: countBand(units, "UNCERTAIN"),
@@ -214627,7 +214628,8 @@ function generateReport(startedAt, files, totalLoc, skippedFiles, config) {
214627
214628
  security: {
214628
214629
  findings: severityCounts,
214629
214630
  blocked,
214630
- riskDensity
214631
+ riskDensity,
214632
+ sourceBreakdown
214631
214633
  },
214632
214634
  weightedContributions,
214633
214635
  calibration: {
@@ -214662,6 +214664,30 @@ function summarizeWeightedContributions(units) {
214662
214664
  maxWeight: values.maxWeight
214663
214665
  })).sort((a, b) => b.score - a.score).slice(0, 8);
214664
214666
  }
214667
+ function summarizeSourceBreakdown(findings) {
214668
+ const createBucket = () => ({
214669
+ total: 0,
214670
+ findings: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 },
214671
+ bySource: {}
214672
+ });
214673
+ const buckets = {
214674
+ local: createBucket(),
214675
+ external: createBucket()
214676
+ };
214677
+ for (const finding of findings) {
214678
+ const pass = classifyFindingPass(finding.source);
214679
+ buckets[pass].total += 1;
214680
+ buckets[pass].findings[finding.severity] += 1;
214681
+ buckets[pass].bySource[finding.source] = (buckets[pass].bySource[finding.source] ?? 0) + 1;
214682
+ }
214683
+ return buckets;
214684
+ }
214685
+ function classifyFindingPass(source) {
214686
+ if (source === "secret-detector" || source === "hallucination-detector" || source === "security-analyzer") {
214687
+ return "local";
214688
+ }
214689
+ return "external";
214690
+ }
214665
214691
  function formatJsonl(report) {
214666
214692
  return report.files.flatMap((file) => file.findings).map((finding) => JSON.stringify(finding)).join("\n");
214667
214693
  }
@@ -216673,6 +216699,24 @@ function formatTerminalReport(report, options = {}) {
216673
216699
  ["medium", String(summary.security.findings.MEDIUM)],
216674
216700
  ["low", String(summary.security.findings.LOW)]
216675
216701
  ]));
216702
+ if (summary.security.sourceBreakdown) {
216703
+ const local = summary.security.sourceBreakdown.local;
216704
+ const external = summary.security.sourceBreakdown.external;
216705
+ lines.push("");
216706
+ lines.push(` ${c.bold}Finding Sources${c.reset}`);
216707
+ lines.push(metricLine([
216708
+ ["local pass", String(local.total)],
216709
+ ["external pass", String(external.total)]
216710
+ ]));
216711
+ const localSources = formatSourceCounts(local.bySource);
216712
+ if (localSources) {
216713
+ lines.push(` ${c.dim}local sources${c.reset} ${localSources}`);
216714
+ }
216715
+ const externalSources = formatSourceCounts(external.bySource);
216716
+ if (externalSources) {
216717
+ lines.push(` ${c.dim}external sources${c.reset} ${externalSources}`);
216718
+ }
216719
+ }
216676
216720
  lines.push("");
216677
216721
  }
216678
216722
  lines.push(` ${c.bold}Severity${c.reset}`);
@@ -216696,8 +216740,9 @@ function formatTerminalReport(report, options = {}) {
216696
216740
  const shownFindings = findings.slice(0, maxFindings);
216697
216741
  for (const finding of shownFindings) {
216698
216742
  const sevColor = severityColor[finding.severity];
216743
+ const findingPass = classifyFindingPass2(finding.source);
216699
216744
  lines.push(` ${sevColor}\u25CF ${finding.severity}${c.reset} ${c.bold}${finding.type}${c.reset} ${c.dim}${finding.id}${c.reset}`);
216700
- lines.push(` ${c.orange}${finding.file}:${finding.line}${c.reset} ${c.dim}source=${finding.source}${c.reset} ${c.dim}ai=${finding.aiScore}${c.reset}`);
216745
+ lines.push(` ${c.orange}${finding.file}:${finding.line}${c.reset} ${c.dim}pass=${findingPass}${c.reset} ${c.dim}source=${finding.source}${c.reset} ${c.dim}ai=${finding.aiScore}${c.reset}`);
216701
216746
  lines.push(` ${c.dim}${finding.message}${c.reset}`);
216702
216747
  const snippet = formatCodeSnippet(finding.code, codePreviewLines);
216703
216748
  if (snippet.length > 0) {
@@ -216745,6 +216790,15 @@ function formatSigned(value) {
216745
216790
  return `+${value}`;
216746
216791
  return String(value);
216747
216792
  }
216793
+ function classifyFindingPass2(source) {
216794
+ if (source === "secret-detector" || source === "hallucination-detector" || source === "security-analyzer") {
216795
+ return "local";
216796
+ }
216797
+ return "external";
216798
+ }
216799
+ function formatSourceCounts(bySource) {
216800
+ return Object.entries(bySource).sort((a, b) => b[1] - a[1]).map(([source, count]) => `${source}:${count}`).join(" ");
216801
+ }
216748
216802
 
216749
216803
  // src/commands/check.ts
216750
216804
  var import_node_path12 = require("path");
@@ -217353,20 +217407,203 @@ function parseMaxFindings(raw) {
217353
217407
  }
217354
217408
 
217355
217409
  // src/commands/doctor.ts
217410
+ var import_node_child_process10 = require("child_process");
217411
+ var import_node_util10 = require("util");
217412
+
217413
+ // src/commands/setup.ts
217356
217414
  var import_node_child_process9 = require("child_process");
217357
217415
  var import_node_util9 = require("util");
217358
- var execFileAsync9 = (0, import_node_util9.promisify)(import_node_child_process9.execFile);
217359
- async function doctorCommand() {
217416
+ var execAsync = (0, import_node_util9.promisify)(import_node_child_process9.exec);
217417
+ function getSemgrepInstallCommand(platform) {
217418
+ if (platform === "darwin") return "brew install semgrep";
217419
+ if (platform === "win32") return "choco install semgrep -y";
217420
+ return "python3 -m pip install --user semgrep";
217421
+ }
217422
+ function getTrivyInstallCommand(platform) {
217423
+ if (platform === "darwin") return "brew install trivy";
217424
+ if (platform === "win32") return "choco install trivy -y";
217425
+ return void 0;
217426
+ }
217427
+ function getTrivyManualInstallCommand(platform) {
217428
+ return getTrivyInstallCommand(platform) ?? "https://trivy.dev/latest/getting-started/installation/";
217429
+ }
217430
+ function getHorusecInstallCommand(platform) {
217431
+ if (platform === "win32") {
217432
+ return 'curl -k "https://github.com/ZupIT/horusec/releases/latest/download/horusec_win_amd64.exe" -o "./horusec.exe" -L';
217433
+ }
217434
+ return "curl -fsSL https://raw.githubusercontent.com/ZupIT/horusec/master/deployments/scripts/install.sh | bash -s latest";
217435
+ }
217436
+ async function setupSemgrepCommand(options = {}) {
217437
+ const installCommand = getSemgrepInstallCommand(process.platform);
217438
+ console.log("Semgrep setup");
217439
+ console.log(`Install command for this system:
217440
+ ${installCommand}`);
217441
+ if (!options.auto) {
217442
+ console.log("Run command above, then verify with: semgrep --version");
217443
+ return;
217444
+ }
217445
+ try {
217446
+ console.log("Running installer...");
217447
+ const { stdout, stderr } = await execAsync(installCommand, { timeout: 12e4, maxBuffer: 1024 * 1024 });
217448
+ if (stdout.trim()) console.log(stdout.trim());
217449
+ if (stderr.trim()) console.log(stderr.trim());
217450
+ console.log("Semgrep install command completed. Verify with: semgrep --version");
217451
+ } catch (error) {
217452
+ const message = error instanceof Error ? error.message : String(error);
217453
+ console.error(`Semgrep install failed: ${message}`);
217454
+ process.exitCode = 1;
217455
+ }
217456
+ }
217457
+ function getSetupAllPlan(platform) {
217458
+ return [
217459
+ {
217460
+ id: "eslint",
217461
+ name: "ESLint + eslint-plugin-security",
217462
+ includedWithAthena: true,
217463
+ note: "Bundled as Athena optional dependencies and used by the ESLint scanner when present."
217464
+ },
217465
+ {
217466
+ id: "npm-audit",
217467
+ name: "npm audit",
217468
+ includedWithAthena: true,
217469
+ note: "Uses npm CLI that ships with Node.js. No separate scanner package install required."
217470
+ },
217471
+ {
217472
+ id: "semgrep",
217473
+ name: "Semgrep",
217474
+ includedWithAthena: false,
217475
+ autoInstallCommand: getSemgrepInstallCommand(platform),
217476
+ manualInstallCommand: getSemgrepInstallCommand(platform),
217477
+ note: "External binary scanner. Optional, but improves SAST coverage."
217478
+ },
217479
+ {
217480
+ id: "docker",
217481
+ name: "Docker (for nodejsscan)",
217482
+ includedWithAthena: false,
217483
+ note: "Required runtime for nodejsscan container execution; install from Docker Desktop/package manager."
217484
+ },
217485
+ {
217486
+ id: "bearer",
217487
+ name: "Bearer CLI",
217488
+ includedWithAthena: false,
217489
+ autoInstallCommand: "npm install -g @bearer/cli",
217490
+ manualInstallCommand: "npm install -g @bearer/cli",
217491
+ note: "External CLI scanner for privacy and data-flow analysis."
217492
+ },
217493
+ {
217494
+ id: "trivy",
217495
+ name: "Trivy",
217496
+ includedWithAthena: false,
217497
+ autoInstallCommand: getTrivyInstallCommand(platform),
217498
+ manualInstallCommand: getTrivyManualInstallCommand(platform),
217499
+ note: "External unified scanner for dependency vulnerabilities, secrets, and misconfigurations."
217500
+ },
217501
+ {
217502
+ id: "horusec",
217503
+ name: "Horusec",
217504
+ includedWithAthena: false,
217505
+ autoInstallCommand: getHorusecInstallCommand(platform),
217506
+ manualInstallCommand: getHorusecInstallCommand(platform),
217507
+ note: "External multi-language SAST orchestrator. Docker recommended for full analysis coverage."
217508
+ }
217509
+ ];
217510
+ }
217511
+ function getAutoInstallPlans(plan, missingToolIds) {
217512
+ const missing = new Set(missingToolIds);
217513
+ return plan.filter((tool) => missing.has(tool.id) && Boolean(tool.autoInstallCommand));
217514
+ }
217515
+ async function installSetupPlans(plan) {
217516
+ let failed = false;
217517
+ for (const tool of plan) {
217518
+ if (!tool.autoInstallCommand) continue;
217519
+ try {
217520
+ console.log(`
217521
+ Installing ${tool.name}...`);
217522
+ const { stdout, stderr } = await execAsync(tool.autoInstallCommand, { timeout: 18e4, maxBuffer: 1024 * 1024 });
217523
+ if (stdout.trim()) console.log(stdout.trim());
217524
+ if (stderr.trim()) console.log(stderr.trim());
217525
+ console.log(`Completed: ${tool.name}`);
217526
+ } catch (error) {
217527
+ const message = error instanceof Error ? error.message : String(error);
217528
+ console.error(`Failed: ${tool.name} (${message})`);
217529
+ failed = true;
217530
+ }
217531
+ }
217532
+ return !failed;
217533
+ }
217534
+ async function setupAllCommand(options = {}) {
217535
+ const plan = getSetupAllPlan(process.platform);
217536
+ console.log("Athena scanner setup plan\n");
217537
+ for (const tool of plan) {
217538
+ const inclusion = tool.includedWithAthena ? "included" : "external";
217539
+ console.log(`- ${tool.name} (${inclusion})`);
217540
+ console.log(` ${tool.note}`);
217541
+ if (tool.manualInstallCommand && !tool.includedWithAthena) {
217542
+ console.log(` install: ${tool.manualInstallCommand}`);
217543
+ }
217544
+ }
217545
+ if (!options.auto) {
217546
+ console.log("\nUse --auto to run supported install commands automatically.");
217547
+ return;
217548
+ }
217549
+ const success = await installSetupPlans(plan);
217550
+ if (!success) {
217551
+ console.log("\nSome installs failed. You can run their manual commands from the setup plan above.");
217552
+ process.exitCode = 1;
217553
+ return;
217554
+ }
217555
+ console.log("\nSetup complete. Run `athena doctor` to verify tool availability.");
217556
+ }
217557
+
217558
+ // src/commands/doctor.ts
217559
+ var execFileAsync9 = (0, import_node_util10.promisify)(import_node_child_process10.execFile);
217560
+ async function doctorCommand(options = {}) {
217561
+ let statuses = await collectDoctorStatuses();
217562
+ printDoctorStatuses(statuses);
217563
+ if (options.fix) {
217564
+ const setupPlan = getSetupAllPlan(process.platform);
217565
+ const installable = getAutoInstallPlans(
217566
+ setupPlan,
217567
+ statuses.filter((status) => !status.ok).map((status) => status.id)
217568
+ );
217569
+ if (installable.length === 0) {
217570
+ console.log(`
217571
+ ${c2.green}fix:${c2.reset} no auto-installable missing tools found`);
217572
+ printDoctorTips(statuses, true);
217573
+ return;
217574
+ }
217575
+ console.log(`
217576
+ ${c2.yellow}fix:${c2.reset} attempting automatic install for missing tools...`);
217577
+ const success = await installSetupPlans(installable);
217578
+ statuses = await collectDoctorStatuses();
217579
+ console.log(`
217580
+ ${c2.bold}Athena doctor (after fix)${c2.reset}
217581
+ `);
217582
+ printDoctorStatuses(statuses);
217583
+ if (!success) {
217584
+ console.log(`
217585
+ ${c2.yellow}fix:${c2.reset} some installs failed`);
217586
+ process.exitCode = 1;
217587
+ }
217588
+ }
217589
+ printDoctorTips(statuses, Boolean(options.fix));
217590
+ }
217591
+ async function collectDoctorStatuses() {
217592
+ const plan = getSetupAllPlan(process.platform);
217593
+ const findPlan = (id) => plan.find((tool) => tool.id === id);
217360
217594
  const statuses = await Promise.all([
217361
- checkTool("node", ["--version"], "required runtime"),
217362
- checkTool("npm", ["--version"], "required package manager"),
217363
- checkTool("semgrep", ["--version"], "optional: deep SAST findings"),
217364
- checkTool("eslint", ["--version"], "optional: JavaScript/TypeScript linting"),
217365
- checkTool("docker", ["--version"], "optional: required for nodejsscan"),
217366
- checkTool("bearer", ["--version"], "optional: privacy & data flow analysis"),
217367
- checkTool("trivy", ["--version"], "optional: IaC/container/dependency/misconfig findings"),
217368
- checkTool("horusec", ["version"], "optional: multi-tool SAST orchestrator")
217595
+ checkTool("node", "node", ["--version"], "required runtime"),
217596
+ checkTool("npm", "npm", ["--version"], "required package manager"),
217597
+ checkTool("semgrep", "semgrep", ["--version"], "optional: deep SAST findings", findPlan("semgrep")),
217598
+ checkBundledEslint(findPlan("eslint")),
217599
+ checkTool("docker", "docker", ["--version"], "optional: required for nodejsscan", findPlan("docker")),
217600
+ checkTool("bearer", "bearer", ["--version"], "optional: privacy & data flow analysis", findPlan("bearer")),
217601
+ checkTool("trivy", "trivy", ["--version"], "optional: IaC/container/dependency/misconfig findings", findPlan("trivy")),
217602
+ checkTool("horusec", "horusec", ["version"], "optional: multi-tool SAST orchestrator", findPlan("horusec"))
217369
217603
  ]);
217604
+ return statuses;
217605
+ }
217606
+ function printDoctorStatuses(statuses) {
217370
217607
  console.log("Athena doctor\n");
217371
217608
  for (const status of statuses) {
217372
217609
  const mark = status.ok ? `${c2.green}\u2713${c2.reset}` : `${c2.red}\u2717${c2.reset}`;
@@ -217374,50 +217611,75 @@ async function doctorCommand() {
217374
217611
  console.log(` ${mark} ${status.name.padEnd(10)} ${version}`);
217375
217612
  if (status.note) console.log(` ${c2.dim}${status.note}${c2.reset}`);
217376
217613
  }
217377
- const semgrep = statuses.find((item) => item.name === "semgrep");
217378
- if (!semgrep?.ok) {
217614
+ }
217615
+ function printDoctorTips(statuses, fixed) {
217616
+ const autoFixableMissing = statuses.filter((status) => !status.ok && status.autoFixable);
217617
+ if (autoFixableMissing.length > 0 && !fixed) {
217379
217618
  console.log(`
217380
- ${c2.yellow}tip:${c2.reset} install Semgrep with ${c2.bold}athena setup semgrep${c2.reset}`);
217619
+ ${c2.yellow}tip:${c2.reset} run ${c2.bold}athena doctor --fix${c2.reset} to auto-install supported missing tools`);
217381
217620
  }
217382
- const eslint = statuses.find((item) => item.name === "eslint");
217621
+ const eslint = statuses.find((item) => item.id === "eslint");
217383
217622
  if (!eslint?.ok) {
217384
- console.log(` ${c2.yellow}tip:${c2.reset} install ESLint with ${c2.bold}npm install --save-dev eslint eslint-plugin-security${c2.reset}`);
217623
+ console.log(` ${c2.yellow}tip:${c2.reset} ESLint scanner is bundled with Athena optional deps; reinstall Athena or run ${c2.bold}npm install${c2.reset} in repo if missing`);
217385
217624
  }
217386
- const docker = statuses.find((item) => item.name === "docker");
217625
+ const docker = statuses.find((item) => item.id === "docker");
217387
217626
  if (!docker?.ok) {
217388
217627
  console.log(` ${c2.yellow}tip:${c2.reset} install Docker to enable nodejsscan scanner`);
217389
217628
  }
217390
- const bearer = statuses.find((item) => item.name === "bearer");
217391
- if (!bearer?.ok) {
217392
- console.log(` ${c2.yellow}tip:${c2.reset} install Bearer with ${c2.bold}npm install -g @bearer/cli${c2.reset}`);
217393
- }
217394
- const trivy = statuses.find((item) => item.name === "trivy");
217395
- if (!trivy?.ok) {
217396
- console.log(` ${c2.yellow}tip:${c2.reset} install Trivy from ${c2.bold}https://trivy.dev/latest/getting-started/installation/${c2.reset}`);
217397
- }
217398
- const horusec = statuses.find((item) => item.name === "horusec");
217399
- if (!horusec?.ok) {
217400
- console.log(` ${c2.yellow}tip:${c2.reset} install Horusec from ${c2.bold}https://github.com/ZupIT/horusec${c2.reset}`);
217629
+ for (const status of statuses.filter((item) => !item.ok && item.manualInstallCommand && !item.autoFixable)) {
217630
+ console.log(` ${c2.yellow}tip:${c2.reset} install ${status.name} with ${c2.bold}${status.manualInstallCommand}${c2.reset}`);
217401
217631
  }
217402
217632
  }
217403
- async function checkTool(name, args, note) {
217633
+ async function checkTool(id, name, args, note, plan) {
217404
217634
  try {
217405
217635
  const { stdout, stderr } = await execFileAsync9(name, args, { timeout: 15e3, maxBuffer: 1024 * 1024 });
217406
217636
  const raw = `${stdout}
217407
217637
  ${stderr}`.trim();
217408
217638
  const line = raw.split(/\r?\n/).find((value) => value.trim().length > 0) ?? "ok";
217409
217639
  return {
217640
+ id,
217410
217641
  name,
217411
217642
  ok: true,
217412
217643
  version: line.trim(),
217413
- note
217644
+ note,
217645
+ manualInstallCommand: plan?.manualInstallCommand,
217646
+ autoFixable: Boolean(plan?.autoInstallCommand)
217414
217647
  };
217415
217648
  } catch {
217416
217649
  return {
217650
+ id,
217417
217651
  name,
217418
217652
  ok: false,
217419
217653
  version: "not found",
217420
- note
217654
+ note,
217655
+ manualInstallCommand: plan?.manualInstallCommand,
217656
+ autoFixable: Boolean(plan?.autoInstallCommand)
217657
+ };
217658
+ }
217659
+ }
217660
+ async function checkBundledEslint(plan) {
217661
+ try {
217662
+ const eslintModule = await import("eslint");
217663
+ await import("eslint-plugin-security");
217664
+ const version = eslintModule.ESLint?.version;
217665
+ return {
217666
+ id: "eslint",
217667
+ name: "eslint",
217668
+ ok: true,
217669
+ version: version ? `v${version} (bundled)` : "bundled module available",
217670
+ note: "optional: JavaScript/TypeScript linting via Athena bundled deps",
217671
+ manualInstallCommand: plan?.manualInstallCommand,
217672
+ autoFixable: Boolean(plan?.autoInstallCommand)
217673
+ };
217674
+ } catch {
217675
+ return {
217676
+ id: "eslint",
217677
+ name: "eslint",
217678
+ ok: false,
217679
+ version: "not found",
217680
+ note: "optional: JavaScript/TypeScript linting via Athena bundled deps",
217681
+ manualInstallCommand: plan?.manualInstallCommand,
217682
+ autoFixable: Boolean(plan?.autoInstallCommand)
217421
217683
  };
217422
217684
  }
217423
217685
  }
@@ -217508,133 +217770,6 @@ function parseMaxFindings2(raw) {
217508
217770
  return Number.isFinite(parsed2) && parsed2 > 0 ? Math.floor(parsed2) : Number.POSITIVE_INFINITY;
217509
217771
  }
217510
217772
 
217511
- // src/commands/setup.ts
217512
- var import_node_child_process10 = require("child_process");
217513
- var import_node_util10 = require("util");
217514
- var execAsync = (0, import_node_util10.promisify)(import_node_child_process10.exec);
217515
- function getSemgrepInstallCommand(platform) {
217516
- if (platform === "darwin") return "brew install semgrep";
217517
- if (platform === "win32") return "choco install semgrep -y";
217518
- return "python3 -m pip install --user semgrep";
217519
- }
217520
- function getTrivyInstallCommand(platform) {
217521
- if (platform === "darwin") return "brew install trivy";
217522
- if (platform === "win32") return "choco install trivy -y";
217523
- return void 0;
217524
- }
217525
- function getHorusecInstallCommand(platform) {
217526
- if (platform === "win32") {
217527
- return 'curl -k "https://github.com/ZupIT/horusec/releases/latest/download/horusec_win_amd64.exe" -o "./horusec.exe" -L';
217528
- }
217529
- return "curl -fsSL https://raw.githubusercontent.com/ZupIT/horusec/master/deployments/scripts/install.sh | bash -s latest";
217530
- }
217531
- async function setupSemgrepCommand(options = {}) {
217532
- const installCommand = getSemgrepInstallCommand(process.platform);
217533
- console.log("Semgrep setup");
217534
- console.log(`Install command for this system:
217535
- ${installCommand}`);
217536
- if (!options.auto) {
217537
- console.log("Run command above, then verify with: semgrep --version");
217538
- return;
217539
- }
217540
- try {
217541
- console.log("Running installer...");
217542
- const { stdout, stderr } = await execAsync(installCommand, { timeout: 12e4, maxBuffer: 1024 * 1024 });
217543
- if (stdout.trim()) console.log(stdout.trim());
217544
- if (stderr.trim()) console.log(stderr.trim());
217545
- console.log("Semgrep install command completed. Verify with: semgrep --version");
217546
- } catch (error) {
217547
- const message = error instanceof Error ? error.message : String(error);
217548
- console.error(`Semgrep install failed: ${message}`);
217549
- process.exitCode = 1;
217550
- }
217551
- }
217552
- function getSetupAllPlan(platform) {
217553
- return [
217554
- {
217555
- name: "ESLint + eslint-plugin-security",
217556
- includedWithAthena: true,
217557
- note: "Bundled as Athena optional dependencies and used by the ESLint scanner when present."
217558
- },
217559
- {
217560
- name: "npm audit",
217561
- includedWithAthena: true,
217562
- note: "Uses npm CLI that ships with Node.js. No separate scanner package install required."
217563
- },
217564
- {
217565
- name: "Semgrep",
217566
- includedWithAthena: false,
217567
- autoInstallCommand: getSemgrepInstallCommand(platform),
217568
- manualInstallCommand: getSemgrepInstallCommand(platform),
217569
- note: "External binary scanner. Optional, but improves SAST coverage."
217570
- },
217571
- {
217572
- name: "Docker (for nodejsscan)",
217573
- includedWithAthena: false,
217574
- note: "Required runtime for nodejsscan container execution; install from Docker Desktop/package manager."
217575
- },
217576
- {
217577
- name: "Bearer CLI",
217578
- includedWithAthena: false,
217579
- autoInstallCommand: "npm install -g @bearer/cli",
217580
- manualInstallCommand: "npm install -g @bearer/cli",
217581
- note: "External CLI scanner for privacy and data-flow analysis."
217582
- },
217583
- {
217584
- name: "Trivy",
217585
- includedWithAthena: false,
217586
- autoInstallCommand: getTrivyInstallCommand(platform),
217587
- manualInstallCommand: getTrivyInstallCommand(platform),
217588
- note: "External unified scanner for dependency vulnerabilities, secrets, and misconfigurations."
217589
- },
217590
- {
217591
- name: "Horusec",
217592
- includedWithAthena: false,
217593
- autoInstallCommand: getHorusecInstallCommand(platform),
217594
- manualInstallCommand: getHorusecInstallCommand(platform),
217595
- note: "External multi-language SAST orchestrator. Docker recommended for full analysis coverage."
217596
- }
217597
- ];
217598
- }
217599
- async function setupAllCommand(options = {}) {
217600
- const plan = getSetupAllPlan(process.platform);
217601
- console.log("Athena scanner setup plan\n");
217602
- for (const tool of plan) {
217603
- const inclusion = tool.includedWithAthena ? "included" : "external";
217604
- console.log(`- ${tool.name} (${inclusion})`);
217605
- console.log(` ${tool.note}`);
217606
- if (tool.manualInstallCommand && !tool.includedWithAthena) {
217607
- console.log(` install: ${tool.manualInstallCommand}`);
217608
- }
217609
- }
217610
- if (!options.auto) {
217611
- console.log("\nUse --auto to run supported install commands automatically.");
217612
- return;
217613
- }
217614
- let failed = false;
217615
- for (const tool of plan) {
217616
- if (!tool.autoInstallCommand) continue;
217617
- try {
217618
- console.log(`
217619
- Installing ${tool.name}...`);
217620
- const { stdout, stderr } = await execAsync(tool.autoInstallCommand, { timeout: 18e4, maxBuffer: 1024 * 1024 });
217621
- if (stdout.trim()) console.log(stdout.trim());
217622
- if (stderr.trim()) console.log(stderr.trim());
217623
- console.log(`Completed: ${tool.name}`);
217624
- } catch (error) {
217625
- const message = error instanceof Error ? error.message : String(error);
217626
- console.error(`Failed: ${tool.name} (${message})`);
217627
- failed = true;
217628
- }
217629
- }
217630
- if (failed) {
217631
- console.log("\nSome installs failed. You can run their manual commands from the setup plan above.");
217632
- process.exitCode = 1;
217633
- return;
217634
- }
217635
- console.log("\nSetup complete. Run `athena doctor` to verify tool availability.");
217636
- }
217637
-
217638
217773
  // src/commands/uninstall.ts
217639
217774
  var import_promises9 = require("fs/promises");
217640
217775
  var import_node_path15 = require("path");
@@ -217654,7 +217789,7 @@ async function uninstallCommand() {
217654
217789
  // package.json
217655
217790
  var package_default = {
217656
217791
  name: "@arsh342/athena",
217657
- version: "0.2.4",
217792
+ version: "0.2.5",
217658
217793
  description: "AI code provenance tracker and terminal scanner for JavaScript and TypeScript repositories.",
217659
217794
  type: "module",
217660
217795
  bin: {
@@ -217909,7 +218044,7 @@ program2.command("scan").argument("[dir]", "directory to scan", ".").option("-t,
217909
218044
  program2.command("check").argument("[files...]", "files to check; defaults to staged JS/TS files").option("-t, --threshold <number>", "AI score threshold", "9").option("-f, --format <format>", "terminal | json | jsonl", "terminal").option("-m, --max-findings <number|all>", "max findings to print (default: all)", "all").option("--no-eslint", "disable ESLint scanner").option("--no-npm-audit", "disable npm audit scanner").option("--no-nodejsscan", "disable nodejsscan scanner").option("--no-bearer", "disable Bearer scanner").option("--no-semgrep", "disable Semgrep scanner").option("--no-trivy", "disable Trivy scanner").option("--no-horusec", "disable Horusec scanner").description("check changed files for blocking findings").action(checkCommand);
217910
218045
  program2.command("init").description("install Athena pre-commit hook").action(initCommand);
217911
218046
  program2.command("uninstall").description("remove Athena pre-commit hook").action(uninstallCommand);
217912
- program2.command("doctor").description("check local toolchain health (node, npm, semgrep, trivy)").action(doctorCommand);
218047
+ program2.command("doctor").option("--fix", "auto-install supported missing external tools").description("check local toolchain health and optionally auto-fix missing scanners").action(doctorCommand);
217913
218048
  var setupCommand = program2.command("setup").description("setup optional external scanners");
217914
218049
  setupCommand.command("semgrep").option("--auto", "run install command automatically").description("install or print install command for semgrep").action(setupSemgrepCommand);
217915
218050
  setupCommand.command("all").option("--auto", "run supported install commands automatically").description("print/setup all scanner dependencies (included + external)").action(setupAllCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arsh342/athena",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "AI code provenance tracker and terminal scanner for JavaScript and TypeScript repositories.",
5
5
  "type": "module",
6
6
  "bin": {