deepscan-cli 1.0.0 → 1.2.1

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 (46) hide show
  1. package/NOTICE +5 -0
  2. package/README.md +224 -61
  3. package/dist/bin/deepscan.js +189 -71
  4. package/dist/bin/deepscan.js.map +1 -1
  5. package/dist/{chunk-OSYJXVNF.js → chunk-4TWV5TES.js} +5130 -610
  6. package/dist/chunk-4TWV5TES.js.map +1 -0
  7. package/dist/index.d.ts +62 -5
  8. package/dist/index.js +13 -3
  9. package/package.json +38 -12
  10. package/rules/built-in/default-config.yml +28 -3
  11. package/rules/built-in/operations.yml +287 -0
  12. package/rules/built-in/security.yml +12 -6
  13. package/dist/chunk-OSYJXVNF.js.map +0 -1
  14. package/rules/built-in/converted-semgrep.yml +0 -37
  15. package/rules/built-in/semgrep-apex.yml +0 -336
  16. package/rules/built-in/semgrep-bash.yml +0 -362
  17. package/rules/built-in/semgrep-c.yml +0 -429
  18. package/rules/built-in/semgrep-clojure.yml +0 -166
  19. package/rules/built-in/semgrep-csharp.yml +0 -1260
  20. package/rules/built-in/semgrep-dart.yml +0 -21
  21. package/rules/built-in/semgrep-dockerfile.yml +0 -874
  22. package/rules/built-in/semgrep-elixir.yml +0 -146
  23. package/rules/built-in/semgrep-generic.yml +0 -2945
  24. package/rules/built-in/semgrep-go.yml +0 -2898
  25. package/rules/built-in/semgrep-hcl.yml +0 -8181
  26. package/rules/built-in/semgrep-html.yml +0 -94
  27. package/rules/built-in/semgrep-java.yml +0 -4219
  28. package/rules/built-in/semgrep-javascript.yml +0 -6243
  29. package/rules/built-in/semgrep-json.yml +0 -360
  30. package/rules/built-in/semgrep-kotlin.yml +0 -540
  31. package/rules/built-in/semgrep-lua.yml +0 -46
  32. package/rules/built-in/semgrep-ocaml.yml +0 -773
  33. package/rules/built-in/semgrep-php.yml +0 -1638
  34. package/rules/built-in/semgrep-python.yml +0 -11240
  35. package/rules/built-in/semgrep-regex.yml +0 -6444
  36. package/rules/built-in/semgrep-ruby.yml +0 -2687
  37. package/rules/built-in/semgrep-rust.yml +0 -278
  38. package/rules/built-in/semgrep-scala.yml +0 -807
  39. package/rules/built-in/semgrep-sh.yml +0 -46
  40. package/rules/built-in/semgrep-solidity.yml +0 -1046
  41. package/rules/built-in/semgrep-swift.yml +0 -200
  42. package/rules/built-in/semgrep-terraform.yml +0 -147
  43. package/rules/built-in/semgrep-typescript.yml +0 -6212
  44. package/rules/built-in/semgrep-xml.yml +0 -31
  45. package/rules/built-in/semgrep-yaml.yml +0 -2785
  46. package/rules/examples/custom-api-security.yml +0 -66
@@ -1,14 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CVEScanner,
4
+ DEEPSCAN_VERSION,
4
5
  DEFAULT_CONFIG,
6
+ OperationsScanner,
5
7
  QualityScanner,
6
8
  RuleEngine,
7
9
  ScanPipeline,
8
10
  SecurityScanner,
11
+ applyBaseline,
9
12
  getReporter,
10
- loadConfig
11
- } from "../chunk-OSYJXVNF.js";
13
+ loadBaseline,
14
+ loadConfig,
15
+ saveBaseline
16
+ } from "../chunk-4TWV5TES.js";
12
17
 
13
18
  // src/cli/index.ts
14
19
  import { Command as Command5 } from "commander";
@@ -19,32 +24,69 @@ import { resolve } from "path";
19
24
  import { consola } from "consola";
20
25
  function createScanCommand() {
21
26
  const scan = new Command("scan");
22
- scan.description("Scan source code for security vulnerabilities and quality issues").argument("[path]", "Path to scan (default: current directory)", ".").option("-s, --scanners <scanners>", "Scanner engines to use (comma-separated: security,quality,cve) [default: security]").option("--security", "Run security scanner only").option("--quality", "Run quality scanner only").option("--cve", "Run CVE/dependency scanner only").option("-f, --format <format>", "Output format: json, csv, html, sarif, console", "console").option("-o, --output <file>", "Output file path").option("--severity <levels>", "Filter by severity (comma-separated: critical,error,warning,info)").option("--include <patterns>", "Include file patterns (comma-separated)").option("--exclude <patterns>", "Exclude file patterns (comma-separated)").option("--deep", "Enable deep analysis (taint tracking, semantic analysis)").option("--ai", "Enable AI-assisted validation (requires API key)").option("--ai-provider <provider>", "AI provider: openai, anthropic, ollama, google").option("--rules <path>", "Path to custom rules directory").option("--parallel <n>", "Number of parallel workers", "4").option("--incremental", "Only scan changed files (git-based)").option("--preset <name>", "Use a preset configuration (node-api, python-web, java-spring, minimal)").option("--config <path>", "Path to configuration file").action(async (targetPath, options) => {
27
+ scan.description("Scan source code for security and operational reliability issues (optional: quality, cve)").argument("[path]", "Path to scan (default: current directory)", ".").allowExcessArguments(true).option("-s, --scanners <scanners>", "Scanner engines to use (comma-separated: security,ops,quality,cve) [default: security,ops]").option("--security", "Run security scanner only").option("--ops", "Run operational & OOM reliability scanner only").option("--quality", "Run quality scanner only").option("--cve", "Run CVE/dependency scanner only").option("-f, --format <format>", "Output format: json, csv, html, sarif, console", "console").option("-o, --output <file>", "Output file path").option("--severity <levels>", "Filter by severity (comma-separated: critical,high,medium,low)").option("--include <patterns>", "Include file patterns (comma-separated)").option("--exclude <patterns>", "Exclude file patterns (comma-separated)").option("--deep", "Enable deep analysis (taint tracking, semantic analysis)").option("--ai", "Enable AI-assisted validation (requires API key)").option("--ai-provider <provider>", "AI provider: openai, anthropic, ollama, google").option("--rules <path>", "Path to custom rules directory").option("--parallel <n>", "Number of parallel workers", "4").option("--incremental", "Only scan changed files (git-based)").option("--preset <name>", "Use a preset configuration (node-api, python-web, java-spring, minimal)").option("--config <path>", "Path to configuration file").option("--cache", "Enable local result caching (default: true)", true).option("--no-cache", "Disable local result caching").option("--cache-dir <dir>", "Path to cache directory").option("--fail-on <severities>", "Fail scan (exit code 1) on matching severities (comma-separated: critical,high,medium,low)").option("--baseline <file>", "Ignore existing findings present in baseline JSON or prior scan report").option("--save-baseline <file>", "Save current finding fingerprints to a baseline JSON file").option("-q, --quiet", "Suppress progress output").option("-w, --watch", "Watch files and automatically re-scan on change").action(async (targetPath, options, command) => {
23
28
  try {
24
- const absolutePath = resolve(targetPath);
29
+ const validScanners = /* @__PURE__ */ new Set(["security", "ops", "quality", "cve"]);
30
+ const extraArgs = (command?.args ?? []).slice(1);
31
+ let resolvedTargetPath = targetPath;
32
+ const extraScannerArgs = [];
33
+ if (options.scanners && validScanners.has(targetPath)) {
34
+ extraScannerArgs.push(targetPath);
35
+ resolvedTargetPath = extraArgs.find((arg) => !validScanners.has(arg)) ?? ".";
36
+ }
37
+ for (const arg of extraArgs) {
38
+ if (validScanners.has(arg)) {
39
+ extraScannerArgs.push(arg);
40
+ }
41
+ }
42
+ const absolutePath = resolve(resolvedTargetPath);
25
43
  const cliOverrides = {};
26
- const hasExplicitFlag = options.security || options.quality || options.cve;
44
+ const hasExplicitFlag = options.security || options.ops || options.quality || options.cve;
27
45
  if (hasExplicitFlag) {
28
46
  cliOverrides.scanners = {
29
47
  security: { enabled: !!options.security },
48
+ ops: { enabled: !!options.ops },
30
49
  quality: { enabled: !!options.quality },
31
50
  cve: { enabled: !!options.cve }
32
51
  };
33
52
  } else if (options.scanners) {
34
- const scannerList = options.scanners.split(",");
35
- cliOverrides.scanners = {
36
- security: { enabled: scannerList.includes("security") },
37
- quality: { enabled: scannerList.includes("quality") },
38
- cve: { enabled: scannerList.includes("cve") }
39
- };
53
+ const rawScanners = String(options.scanners);
54
+ if (rawScanners.includes("System.Object[]")) {
55
+ cliOverrides.scanners = {
56
+ security: { enabled: true },
57
+ ops: { enabled: true },
58
+ quality: { enabled: true },
59
+ cve: { enabled: true }
60
+ };
61
+ } else {
62
+ const scannerList = [
63
+ ...rawScanners.split(/[\s,]+/).map((s) => s.trim().toLowerCase()).filter(Boolean),
64
+ ...extraScannerArgs
65
+ ];
66
+ const hasValidScanner = scannerList.some((s) => validScanners.has(s));
67
+ if (!hasValidScanner) {
68
+ consola.warn(`No valid scanner found in "${rawScanners}". Falling back to default (security,ops).`);
69
+ } else {
70
+ cliOverrides.scanners = {
71
+ security: { enabled: scannerList.includes("security") },
72
+ ops: { enabled: scannerList.includes("ops") },
73
+ quality: { enabled: scannerList.includes("quality") },
74
+ cve: { enabled: scannerList.includes("cve") }
75
+ };
76
+ }
77
+ }
40
78
  }
41
79
  if (options.format) {
42
80
  cliOverrides.output = { format: options.format };
43
81
  }
44
82
  if (options.severity) {
45
- const severities = options.severity.split(",");
83
+ const severities = options.severity.split(/[\s,]+/).map((s) => s.trim()).filter(Boolean);
46
84
  if (!cliOverrides.scanners) cliOverrides.scanners = {};
47
- cliOverrides.scanners.security = { severity: severities };
85
+ const scannersOverride = cliOverrides.scanners;
86
+ const existingSec = scannersOverride.security || {};
87
+ const existingOps = scannersOverride.ops || {};
88
+ scannersOverride.security = { ...existingSec, severity: severities };
89
+ scannersOverride.ops = { ...existingOps, severity: severities };
48
90
  }
49
91
  if (options.include) {
50
92
  cliOverrides.paths = {
@@ -61,6 +103,10 @@ function createScanCommand() {
61
103
  if (options.deep) cliOverrides.deep = true;
62
104
  if (options.incremental) cliOverrides.incremental = true;
63
105
  if (options.parallel) cliOverrides.parallel = parseInt(options.parallel, 10);
106
+ if (options.cache === false) cliOverrides.cache = false;
107
+ if (options.cacheDir) cliOverrides.cacheLocation = resolve(options.cacheDir, "cache.json");
108
+ if (options.failOn) cliOverrides.failOn = options.failOn.split(",");
109
+ if (options.watch) cliOverrides.watch = true;
64
110
  if (options.ai) {
65
111
  cliOverrides.ai = {
66
112
  enabled: true,
@@ -70,56 +116,114 @@ function createScanCommand() {
70
116
  if (options.rules) {
71
117
  cliOverrides.rules = { custom: [options.rules] };
72
118
  }
73
- const config = await loadConfig({
74
- configPath: options.config,
75
- targetPath: absolutePath,
76
- cliOverrides,
77
- preset: options.preset
78
- });
79
- if (options.format) {
80
- config.output.format = options.format;
81
- }
82
- const pipeline = new ScanPipeline(config);
83
- if (config.scanners.security.enabled) {
84
- pipeline.addScanner(new SecurityScanner());
85
- }
86
- if (config.scanners.quality.enabled) {
87
- pipeline.addScanner(new QualityScanner());
88
- }
89
- if (config.scanners.cve.enabled) {
90
- pipeline.addScanner(new CVEScanner());
91
- }
92
- const result = await pipeline.run({
93
- config,
94
- targetPath: absolutePath,
95
- onProgress: (current, total, file) => {
96
- if (!options.quiet) {
97
- const pct = Math.round(current / total * 100);
98
- const fileDisplay = file.length > 50 ? "..." + file.slice(-47) : file;
99
- process.stderr.write(`\r Scanning... ${pct}% (${current}/${total}) ${fileDisplay.padEnd(50)}`);
119
+ const runScanIteration = async () => {
120
+ const config = await loadConfig({
121
+ configPath: options.config,
122
+ targetPath: absolutePath,
123
+ cliOverrides,
124
+ preset: options.preset
125
+ });
126
+ if (options.format) {
127
+ config.output.format = options.format;
128
+ }
129
+ const pipeline = new ScanPipeline(config);
130
+ if (config.scanners.security.enabled) {
131
+ pipeline.addScanner(new SecurityScanner());
132
+ }
133
+ if (config.scanners.ops?.enabled) {
134
+ pipeline.addScanner(new OperationsScanner());
135
+ }
136
+ if (config.scanners.quality.enabled) {
137
+ pipeline.addScanner(new QualityScanner());
138
+ }
139
+ if (config.scanners.cve.enabled) {
140
+ pipeline.addScanner(new CVEScanner());
141
+ }
142
+ const isQuiet = Boolean(options.quiet || command.parent?.opts()?.quiet);
143
+ const rawResult = await pipeline.run({
144
+ config,
145
+ targetPath: absolutePath,
146
+ onProgress: (current, total, file) => {
147
+ if (!isQuiet && !options.watch) {
148
+ const pct = Math.round(current / total * 100);
149
+ const fileDisplay = file.length > 50 ? "..." + file.slice(-47) : file;
150
+ process.stderr.write(`\r Scanning... ${pct}% (${current}/${total}) ${fileDisplay.padEnd(50)}`);
151
+ }
100
152
  }
153
+ });
154
+ if (!isQuiet && !options.watch) {
155
+ process.stderr.write("\r" + " ".repeat(120) + "\r");
156
+ }
157
+ if (options.saveBaseline) {
158
+ const baselineOut = resolve(options.saveBaseline);
159
+ saveBaseline(baselineOut, rawResult.findings);
160
+ consola.success(`Saved baseline with ${rawResult.findings.length} finding(s) to: ${baselineOut}`);
161
+ }
162
+ let result = rawResult;
163
+ if (options.baseline) {
164
+ const baselinePath = resolve(options.baseline);
165
+ const baselineSet = loadBaseline(baselinePath);
166
+ const applied = applyBaseline(rawResult, baselineSet);
167
+ result = applied.result;
168
+ if (applied.suppressedCount > 0) {
169
+ consola.info(`Baseline suppressed ${applied.suppressedCount} existing finding(s); ${result.summary.totalFindings} new finding(s) remain.`);
170
+ }
171
+ }
172
+ const reporter = getReporter(config.output.format);
173
+ const output = await reporter.generate(result);
174
+ if (options.output) {
175
+ await reporter.writeToFile(result, options.output);
176
+ consola.success(`Report written to: ${options.output}`);
177
+ } else if (config.output.format === "html") {
178
+ const defaultPath = "report.html";
179
+ await reporter.writeToFile(result, defaultPath);
180
+ consola.success(`Report written to: ${defaultPath}`);
181
+ } else if (config.output.format !== "console") {
182
+ process.stdout.write(output);
183
+ } else {
184
+ process.stdout.write(output);
185
+ }
186
+ const failSeverities = config.failOn || ["critical", "high"];
187
+ const hasFailingFindings = failSeverities.some((sev) => (result.summary.bySeverity[sev] || 0) > 0);
188
+ if (hasFailingFindings) {
189
+ process.exitCode = 1;
190
+ } else {
191
+ process.exitCode = 0;
192
+ }
193
+ return result;
194
+ };
195
+ await runScanIteration();
196
+ if (options.watch) {
197
+ const { watch } = await import("fs");
198
+ consola.info("\u{1F440} Watch mode active. Waiting for file changes (press Ctrl+C to stop)...");
199
+ let debounceTimer = null;
200
+ let isScanning = false;
201
+ try {
202
+ watch(absolutePath, { recursive: true }, (eventType, filename) => {
203
+ if (!filename) return;
204
+ const norm = filename.replace(/\\/g, "/");
205
+ if (norm.includes("node_modules") || norm.includes(".git") || norm.includes(".deepscan") || norm.endsWith(".tmp") || norm.endsWith(".log")) {
206
+ return;
207
+ }
208
+ if (debounceTimer) clearTimeout(debounceTimer);
209
+ debounceTimer = setTimeout(async () => {
210
+ if (isScanning) return;
211
+ isScanning = true;
212
+ console.log(`
213
+ \u{1F504} Change detected in ${filename}. Re-scanning...
214
+ `);
215
+ try {
216
+ await runScanIteration();
217
+ } catch (err) {
218
+ consola.error("Scan error during watch:", err);
219
+ } finally {
220
+ isScanning = false;
221
+ }
222
+ }, 300);
223
+ });
224
+ } catch (watchErr) {
225
+ consola.warn("Recursive watch failed, falling back to non-recursive watch:", watchErr);
101
226
  }
102
- });
103
- if (!options.quiet) {
104
- process.stderr.write("\r" + " ".repeat(120) + "\r");
105
- }
106
- const reporter = getReporter(config.output.format);
107
- const output = await reporter.generate(result);
108
- if (options.output) {
109
- await reporter.writeToFile(result, options.output);
110
- consola.success(`Report written to: ${options.output}`);
111
- } else if (config.output.format === "html") {
112
- const defaultPath = "report.html";
113
- await reporter.writeToFile(result, defaultPath);
114
- consola.success(`Report written to: ${defaultPath}`);
115
- } else if (config.output.format !== "console") {
116
- process.stdout.write(output);
117
- } else {
118
- process.stdout.write(output);
119
- }
120
- const hasErrors = result.summary.bySeverity.critical > 0 || result.summary.bySeverity.high > 0;
121
- if (hasErrors) {
122
- process.exitCode = 1;
123
227
  }
124
228
  } catch (error) {
125
229
  consola.error("Scan failed:", error);
@@ -147,7 +251,7 @@ function createInitCommand() {
147
251
  severity: ["critical", "high", "medium", "low"]
148
252
  },
149
253
  quality: {
150
- enabled: true,
254
+ enabled: false,
151
255
  thresholds: {
152
256
  maxComplexity: 15,
153
257
  maxFileLength: 500,
@@ -155,8 +259,12 @@ function createInitCommand() {
155
259
  }
156
260
  },
157
261
  cve: {
158
- enabled: true,
262
+ enabled: false,
159
263
  sources: ["osv"]
264
+ },
265
+ ops: {
266
+ enabled: true,
267
+ severity: ["critical", "high", "medium", "low"]
160
268
  }
161
269
  },
162
270
  rules: {
@@ -228,6 +336,11 @@ var RULE_CATEGORIES = [
228
336
  { id: "auth", name: "Authentication & Authorization", description: "Weak auth patterns, missing authorization", scanner: "security" },
229
337
  { id: "crypto", name: "Cryptography", description: "Weak algorithms, insecure random, hardcoded keys", scanner: "security" },
230
338
  { id: "file-ops", name: "File Operations", description: "Path traversal, unsafe uploads, directory listing", scanner: "security" },
339
+ // Operations & Reliability categories
340
+ { id: "oom-memory", name: "OOM & Unbounded Memory", description: "Unbounded queries without pagination, full-body buffering, uncapped page limits, and unbounded caches", scanner: "ops" },
341
+ { id: "timeout-resilience", name: "Timeouts & Resilience", description: "Missing HTTP/client timeouts, unbounded retry loops, and unsafe pool limits", scanner: "ops" },
342
+ { id: "resource-leaks", name: "Resource & Connection Leaks", description: "Unclosed handles/connections, per-request DB clients, and uncleaned timers or listeners", scanner: "ops" },
343
+ { id: "ops-performance", name: "Operational Bottlenecks", description: "N+1 queries in loops, blocking sync I/O in async handlers, unbounded Promise.all fan-out, and ReDoS", scanner: "ops" },
231
344
  // Quality categories
232
345
  { id: "complexity", name: "Complexity", description: "Cyclomatic and cognitive complexity issues", scanner: "quality" },
233
346
  { id: "duplication", name: "Code Duplication", description: "Duplicated code blocks", scanner: "quality" },
@@ -240,7 +353,7 @@ var RULE_CATEGORIES = [
240
353
  function createRulesCommand() {
241
354
  const rules = new Command3("rules");
242
355
  rules.description("Manage and inspect scanning rules");
243
- rules.command("list").description("List all available rules").option("-c, --category <category>", "Filter by category").option("-s, --severity <severity>", "Filter by severity").option("-l, --language <language>", "Filter by language").option("--scanner <type>", "Filter by scanner type (security, quality)").action(async (options) => {
356
+ rules.command("list").description("List all available rules").option("-c, --category <category>", "Filter by category").option("-s, --severity <severity>", "Filter by severity").option("-l, --language <language>", "Filter by language").option("--scanner <type>", "Filter by scanner type (security, ops, quality)").action(async (options) => {
244
357
  try {
245
358
  const ruleEngine = new RuleEngine(DEFAULT_CONFIG);
246
359
  await ruleEngine.initialize();
@@ -255,11 +368,16 @@ function createRulesCommand() {
255
368
  allRules = allRules.filter((r) => r.languages.includes(options.language) || r.languages.includes("*"));
256
369
  }
257
370
  if (options.scanner) {
258
- const secCategories = ["injection", "xss", "secrets", "auth", "crypto", "file-ops"];
371
+ const secCategories = ["injection", "xss", "secrets", "auth", "crypto", "file-ops", "api-security"];
372
+ const opsCategories = ["oom-memory", "timeout-resilience", "resource-leaks", "ops-performance"];
259
373
  if (options.scanner === "security") {
260
374
  allRules = allRules.filter((r) => secCategories.includes(r.category));
375
+ } else if (options.scanner === "ops") {
376
+ allRules = allRules.filter((r) => opsCategories.includes(r.category));
261
377
  } else {
262
- allRules = allRules.filter((r) => !secCategories.includes(r.category));
378
+ allRules = allRules.filter(
379
+ (r) => !secCategories.includes(r.category) && !opsCategories.includes(r.category)
380
+ );
263
381
  }
264
382
  }
265
383
  console.log(chalk.bold(`
@@ -267,9 +385,9 @@ function createRulesCommand() {
267
385
  `));
268
386
  const severityColors = {
269
387
  critical: chalk.bgRed.white,
270
- error: chalk.red,
271
- warning: chalk.yellow,
272
- info: chalk.blue
388
+ high: chalk.red,
389
+ medium: chalk.yellow,
390
+ low: chalk.blue
273
391
  };
274
392
  for (const rule of allRules) {
275
393
  const sevColor = severityColors[rule.severity] || chalk.white;
@@ -329,7 +447,7 @@ function createRulesCommand() {
329
447
  rules.command("categories").description("List all rule categories").action(async () => {
330
448
  console.log(chalk.bold("\n\u{1F4C2} Rule Categories\n"));
331
449
  for (const cat of RULE_CATEGORIES) {
332
- const scanner = cat.scanner === "security" ? chalk.red("\u{1F6E1} Security") : chalk.blue("\u{1F4CA} Quality");
450
+ const scanner = cat.scanner === "security" ? chalk.red("\u{1F6E1} Security") : cat.scanner === "ops" ? chalk.magenta("\u2699\uFE0F Ops") : chalk.blue("\u{1F4CA} Quality");
333
451
  console.log(` ${chalk.cyan(cat.id.padEnd(20))} ${scanner} ${cat.name}`);
334
452
  console.log(` ${" ".repeat(20)} ${chalk.dim(cat.description)}`);
335
453
  console.log();
@@ -373,7 +491,7 @@ function createReportCommand() {
373
491
  }
374
492
 
375
493
  // src/cli/index.ts
376
- var VERSION = "1.0.0";
494
+ var VERSION = DEEPSCAN_VERSION;
377
495
  function createCLI() {
378
496
  const program = new Command5();
379
497
  program.name("deepscan").description("\u{1F50D} DeepScan - Open-source security & code quality scanner").version(VERSION, "-v, --version", "Display version number").option("--config <path>", "Path to configuration file").option("--verbose", "Enable verbose output").option("--quiet", "Suppress all output except errors").option("--no-color", "Disable colored output");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/scan.ts","../../src/cli/commands/init.ts","../../src/cli/commands/rules.ts","../../src/types/rule.ts","../../src/cli/commands/report.ts","../../src/bin/deepscan.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { createScanCommand } from './commands/scan.js';\nimport { createInitCommand } from './commands/init.js';\nimport { createRulesCommand } from './commands/rules.js';\nimport { createReportCommand } from './commands/report.js';\n\nconst VERSION = '1.0.0';\n\n/**\n * Create the DeepScan CLI application\n */\nexport function createCLI(): Command {\n const program = new Command();\n\n program\n .name('deepscan')\n .description('šŸ” DeepScan - Open-source security & code quality scanner')\n .version(VERSION, '-v, --version', 'Display version number')\n .option('--config <path>', 'Path to configuration file')\n .option('--verbose', 'Enable verbose output')\n .option('--quiet', 'Suppress all output except errors')\n .option('--no-color', 'Disable colored output');\n\n // Register commands\n program.addCommand(createScanCommand());\n program.addCommand(createInitCommand());\n program.addCommand(createRulesCommand());\n program.addCommand(createReportCommand());\n\n // Default action (no subcommand) → show help\n program.action(() => {\n program.outputHelp();\n });\n\n return program;\n}\n","import { Command } from 'commander';\nimport { resolve } from 'node:path';\nimport { consola } from 'consola';\nimport { loadConfig } from '../../config/loader.js';\nimport { ScanPipeline, generateFingerprint } from '../../core/pipeline.js';\nimport { SecurityScanner } from '../../scanners/security/index.js';\nimport { QualityScanner } from '../../scanners/quality/index.js';\nimport { CVEScanner } from '../../scanners/cve/index.js';\nimport { getReporter } from '../../reporters/index.js';\nimport type { OutputFormat } from '../../types/config.js';\n\n/**\n * Create the 'scan' command\n * Usage: deepscan scan [path] [options]\n */\nexport function createScanCommand(): Command {\n const scan = new Command('scan');\n\n scan\n .description('Scan source code for security vulnerabilities and quality issues')\n .argument('[path]', 'Path to scan (default: current directory)', '.')\n .option('-s, --scanners <scanners>', 'Scanner engines to use (comma-separated: security,quality,cve) [default: security]')\n .option('--security', 'Run security scanner only')\n .option('--quality', 'Run quality scanner only')\n .option('--cve', 'Run CVE/dependency scanner only')\n .option('-f, --format <format>', 'Output format: json, csv, html, sarif, console', 'console')\n .option('-o, --output <file>', 'Output file path')\n .option('--severity <levels>', 'Filter by severity (comma-separated: critical,error,warning,info)')\n .option('--include <patterns>', 'Include file patterns (comma-separated)')\n .option('--exclude <patterns>', 'Exclude file patterns (comma-separated)')\n .option('--deep', 'Enable deep analysis (taint tracking, semantic analysis)')\n .option('--ai', 'Enable AI-assisted validation (requires API key)')\n .option('--ai-provider <provider>', 'AI provider: openai, anthropic, ollama, google')\n .option('--rules <path>', 'Path to custom rules directory')\n .option('--parallel <n>', 'Number of parallel workers', '4')\n .option('--incremental', 'Only scan changed files (git-based)')\n .option('--preset <name>', 'Use a preset configuration (node-api, python-web, java-spring, minimal)')\n .option('--config <path>', 'Path to configuration file')\n .action(async (targetPath: string, options: Record<string, string | boolean | undefined>) => {\n try {\n const absolutePath = resolve(targetPath);\n\n // Build CLI overrides from options\n const cliOverrides: Record<string, unknown> = {};\n\n const hasExplicitFlag = options.security || options.quality || options.cve;\n if (hasExplicitFlag) {\n cliOverrides.scanners = {\n security: { enabled: !!options.security },\n quality: { enabled: !!options.quality },\n cve: { enabled: !!options.cve },\n };\n } else if (options.scanners) {\n const scannerList = (options.scanners as string).split(',');\n cliOverrides.scanners = {\n security: { enabled: scannerList.includes('security') },\n quality: { enabled: scannerList.includes('quality') },\n cve: { enabled: scannerList.includes('cve') },\n };\n }\n\n if (options.format) {\n cliOverrides.output = { format: options.format };\n }\n\n if (options.severity) {\n const severities = (options.severity as string).split(',');\n if (!cliOverrides.scanners) cliOverrides.scanners = {};\n (cliOverrides.scanners as Record<string, unknown>).security = { severity: severities };\n }\n\n if (options.include) {\n cliOverrides.paths = {\n ...(cliOverrides.paths as Record<string, unknown> || {}),\n include: (options.include as string).split(','),\n };\n }\n\n if (options.exclude) {\n cliOverrides.paths = {\n ...(cliOverrides.paths as Record<string, unknown> || {}),\n exclude: (options.exclude as string).split(','),\n };\n }\n\n if (options.deep) cliOverrides.deep = true;\n if (options.incremental) cliOverrides.incremental = true;\n if (options.parallel) cliOverrides.parallel = parseInt(options.parallel as string, 10);\n\n if (options.ai) {\n cliOverrides.ai = {\n enabled: true,\n provider: options.aiProvider || 'openai',\n };\n }\n\n if (options.rules) {\n cliOverrides.rules = { custom: [(options.rules as string)] };\n }\n\n // Load configuration\n const config = await loadConfig({\n configPath: options.config as string,\n targetPath: absolutePath,\n cliOverrides: cliOverrides as any,\n preset: options.preset as string,\n });\n\n // Override output format from CLI\n if (options.format) {\n config.output.format = options.format as OutputFormat;\n }\n\n // Create pipeline\n const pipeline = new ScanPipeline(config);\n\n // Register enabled scanners\n if (config.scanners.security.enabled) {\n pipeline.addScanner(new SecurityScanner());\n }\n if (config.scanners.quality.enabled) {\n pipeline.addScanner(new QualityScanner());\n }\n if (config.scanners.cve.enabled) {\n pipeline.addScanner(new CVEScanner());\n }\n\n // Run scan with progress\n const result = await pipeline.run({\n config,\n targetPath: absolutePath,\n onProgress: (current, total, file) => {\n if (!options.quiet) {\n const pct = Math.round((current / total) * 100);\n const fileDisplay = file.length > 50 ? '...' + file.slice(-47) : file;\n process.stderr.write(`\\r Scanning... ${pct}% (${current}/${total}) ${fileDisplay.padEnd(50)}`);\n }\n },\n });\n\n // Clear progress line\n if (!options.quiet) {\n process.stderr.write('\\r' + ' '.repeat(120) + '\\r');\n }\n\n // Generate report\n const reporter = getReporter(config.output.format);\n const output = await reporter.generate(result);\n\n // Write to file or stdout\n if (options.output) {\n await reporter.writeToFile(result, options.output as string);\n consola.success(`Report written to: ${options.output}`);\n } else if (config.output.format === 'html') {\n const defaultPath = 'report.html';\n await reporter.writeToFile(result, defaultPath);\n consola.success(`Report written to: ${defaultPath}`);\n } else if (config.output.format !== 'console') {\n // For non-console formats, write to stdout\n process.stdout.write(output);\n } else {\n // Console format already printed\n process.stdout.write(output);\n }\n\n // Exit with error code if critical/error findings found\n const hasErrors = result.summary.bySeverity.critical > 0 || result.summary.bySeverity.high > 0;\n if (hasErrors) {\n process.exitCode = 1;\n }\n } catch (error) {\n consola.error('Scan failed:', error);\n process.exitCode = 2;\n }\n });\n\n return scan;\n}\n","import { Command } from 'commander';\nimport { writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport yaml from 'js-yaml';\nimport { consola } from 'consola';\nimport { DEFAULT_CONFIG } from '../../config/defaults.js';\n\n/**\n * Create the 'init' command\n * Usage: deepscan init\n */\nexport function createInitCommand(): Command {\n const init = new Command('init');\n\n init\n .description('Initialize a .deepscan.yml configuration file in the current directory')\n .option('--preset <name>', 'Use a preset: node-api, python-web, java-spring, minimal')\n .option('--format <format>', 'Config file format: yml, json', 'yml')\n .action(async (options: Record<string, string | undefined>) => {\n try {\n const config = {\n version: '1.0',\n scanners: {\n security: {\n enabled: true,\n severity: ['critical', 'high', 'medium', 'low'],\n },\n quality: {\n enabled: true,\n thresholds: {\n maxComplexity: 15,\n maxFileLength: 500,\n maxFunctionLength: 50,\n },\n },\n cve: {\n enabled: true,\n sources: ['osv'],\n },\n },\n rules: {\n include: ['*'],\n exclude: [],\n custom: [],\n },\n paths: {\n include: ['**/*'],\n exclude: [\n 'node_modules/',\n 'vendor/',\n 'dist/',\n 'build/',\n '.git/',\n 'storage/',\n 'bootstrap/cache/',\n 'public/build/',\n 'assets/',\n '**/node_modules/**',\n '**/vendor/**',\n '**/dist/**',\n '**/build/**',\n '**/.git/**',\n '**/storage/**',\n '**/bootstrap/cache/**',\n '**/public/build/**',\n '**/assets/**',\n ],\n },\n output: {\n format: 'console',\n },\n ai: {\n enabled: false,\n },\n };\n\n const format = options.format || 'yml';\n const fileName = format === 'json' ? '.deepscan.json' : '.deepscan.yml';\n const filePath = resolve(process.cwd(), fileName);\n\n let content: string;\n if (format === 'json') {\n content = JSON.stringify(config, null, 2);\n } else {\n content = '# DeepScan Configuration\\n# https://github.com/deepscan/deepscan-cli\\n\\n'\n + yaml.dump(config, { indent: 2, lineWidth: 100, quotingType: '\"' });\n }\n\n writeFileSync(filePath, content, 'utf-8');\n consola.success(`Created ${fileName}`);\n consola.info('Customize the configuration and run: deepscan scan');\n } catch (error) {\n consola.error('Init failed:', error);\n process.exitCode = 1;\n }\n });\n\n return init;\n}\n","import { Command } from 'commander';\nimport { consola } from 'consola';\nimport chalk from 'chalk';\nimport { RuleEngine } from '../../rules/rule-engine.js';\nimport { DEFAULT_CONFIG } from '../../config/defaults.js';\nimport type { DeepScanConfig } from '../../types/config.js';\nimport { RULE_CATEGORIES } from '../../types/rule.js';\n\n/**\n * Create the 'rules' command group\n * Usage: deepscan rules list|info\n */\nexport function createRulesCommand(): Command {\n const rules = new Command('rules');\n rules.description('Manage and inspect scanning rules');\n\n // Subcommand: list\n rules\n .command('list')\n .description('List all available rules')\n .option('-c, --category <category>', 'Filter by category')\n .option('-s, --severity <severity>', 'Filter by severity')\n .option('-l, --language <language>', 'Filter by language')\n .option('--scanner <type>', 'Filter by scanner type (security, quality)')\n .action(async (options: Record<string, string | undefined>) => {\n try {\n const ruleEngine = new RuleEngine(DEFAULT_CONFIG as DeepScanConfig);\n await ruleEngine.initialize();\n\n let allRules = ruleEngine.getAllRules();\n\n // Apply filters\n if (options.category) {\n allRules = allRules.filter(r => r.category === options.category);\n }\n if (options.severity) {\n allRules = allRules.filter(r => r.severity === options.severity);\n }\n if (options.language) {\n allRules = allRules.filter(r => r.languages.includes(options.language!) || r.languages.includes('*'));\n }\n if (options.scanner) {\n const secCategories = ['injection', 'xss', 'secrets', 'auth', 'crypto', 'file-ops'];\n if (options.scanner === 'security') {\n allRules = allRules.filter(r => secCategories.includes(r.category));\n } else {\n allRules = allRules.filter(r => !secCategories.includes(r.category));\n }\n }\n\n // Display results\n console.log(chalk.bold(`\\nšŸ“‹ DeepScan Rules (${allRules.length} rules)\\n`));\n\n const severityColors: Record<string, (s: string) => string> = {\n critical: chalk.bgRed.white,\n error: chalk.red,\n warning: chalk.yellow,\n info: chalk.blue,\n };\n\n for (const rule of allRules) {\n const sevColor = severityColors[rule.severity] || chalk.white;\n const id = chalk.cyan(rule.id.padEnd(35));\n const sev = sevColor(rule.severity.padEnd(10));\n const langs = chalk.gray(rule.languages.join(', '));\n console.log(` ${id} ${sev} ${rule.name}`);\n console.log(` ${' '.repeat(35)} ${chalk.dim(rule.description.slice(0, 80))}`);\n console.log(` ${' '.repeat(35)} Languages: ${langs}`);\n console.log();\n }\n } catch (error) {\n consola.error('Failed to list rules:', error);\n }\n });\n\n // Subcommand: info\n rules\n .command('info <ruleId>')\n .description('Show detailed information about a specific rule')\n .action(async (ruleId: string) => {\n try {\n const ruleEngine = new RuleEngine(DEFAULT_CONFIG as DeepScanConfig);\n await ruleEngine.initialize();\n\n const rule = ruleEngine.getRule(ruleId);\n if (!rule) {\n consola.error(`Rule not found: ${ruleId}`);\n return;\n }\n\n console.log(chalk.bold(`\\nšŸ” Rule: ${rule.id}\\n`));\n console.log(` ${chalk.bold('Name:')} ${rule.name}`);\n console.log(` ${chalk.bold('Category:')} ${rule.category}`);\n console.log(` ${chalk.bold('Severity:')} ${rule.severity}`);\n console.log(` ${chalk.bold('Confidence:')} ${rule.confidence}`);\n console.log(` ${chalk.bold('Languages:')} ${rule.languages.join(', ')}`);\n console.log(` ${chalk.bold('Description:')} ${rule.description}`);\n\n if (rule.cwe?.length) {\n console.log(` ${chalk.bold('CWE:')} ${rule.cwe.join(', ')}`);\n }\n if (rule.owasp?.length) {\n console.log(` ${chalk.bold('OWASP:')} ${rule.owasp.join(', ')}`);\n }\n if (rule.fix) {\n console.log(` ${chalk.bold('Fix:')} ${rule.fix.description}`);\n }\n if (rule.references?.length) {\n console.log(` ${chalk.bold('References:')}`);\n for (const ref of rule.references) {\n console.log(` - ${chalk.underline(ref)}`);\n }\n }\n if (rule.tags?.length) {\n console.log(` ${chalk.bold('Tags:')} ${rule.tags.join(', ')}`);\n }\n console.log();\n } catch (error) {\n consola.error('Failed to get rule info:', error);\n }\n });\n\n // Subcommand: categories\n rules\n .command('categories')\n .description('List all rule categories')\n .action(async () => {\n console.log(chalk.bold('\\nšŸ“‚ Rule Categories\\n'));\n for (const cat of RULE_CATEGORIES) {\n const scanner = cat.scanner === 'security' ? chalk.red('šŸ›” Security') : chalk.blue('šŸ“Š Quality');\n console.log(` ${chalk.cyan(cat.id.padEnd(20))} ${scanner} ${cat.name}`);\n console.log(` ${' '.repeat(20)} ${chalk.dim(cat.description)}`);\n console.log();\n }\n });\n\n return rules;\n}\n","import type { Severity, Confidence } from './finding.js';\n\n// ─── Rule Types ────────────────────────────────────────────────────────────\n\n/** Pattern definition within a rule */\nexport interface RulePattern {\n /** Tree-sitter query or code pattern */\n pattern?: string;\n /** Message to display when this pattern matches */\n message?: string;\n /** Regex pattern (for non-AST matching) */\n regex?: string;\n /** Flags for regex */\n regexFlags?: string;\n}\n\n/** Condition for advanced rule logic */\nexport interface RuleCondition {\n type: 'taint-check' | 'context-check' | 'scope-check' | 'ast-check';\n /** For taint-check: source type */\n source?: string;\n /** For taint-check: sink variable */\n sink?: string;\n /** For context-check: contexts to include/exclude */\n in?: string[];\n notIn?: string[];\n /** For scope-check */\n scope?: string;\n}\n\n/** Fix suggestion within a rule */\nexport interface RuleFix {\n description: string;\n replacement?: string;\n}\n\n/** A single rule definition */\nexport interface Rule {\n id: string;\n name: string;\n description: string;\n category: string;\n subcategory?: string;\n severity: Severity;\n confidence: Confidence;\n cwe?: string[];\n owasp?: string[];\n languages: string[];\n patterns: RulePattern[];\n conditions?: RuleCondition[];\n fix?: RuleFix;\n tags?: string[];\n references?: string[];\n enabled?: boolean;\n}\n\n/** Collection of rules in a YAML file */\nexport interface RuleFile {\n rules: Rule[];\n}\n\n/** Rule category for organization */\nexport interface RuleCategory {\n id: string;\n name: string;\n description: string;\n scanner: 'security' | 'quality';\n}\n\n/** Default rule categories */\nexport const RULE_CATEGORIES: RuleCategory[] = [\n // Security categories\n { id: 'injection', name: 'Injection', description: 'SQL, Command, LDAP, XPath injection vulnerabilities', scanner: 'security' },\n { id: 'xss', name: 'Cross-Site Scripting', description: 'XSS vulnerabilities including DOM-based and reflected', scanner: 'security' },\n { id: 'secrets', name: 'Secrets & Credentials', description: 'Hardcoded passwords, API keys, tokens', scanner: 'security' },\n { id: 'auth', name: 'Authentication & Authorization', description: 'Weak auth patterns, missing authorization', scanner: 'security' },\n { id: 'crypto', name: 'Cryptography', description: 'Weak algorithms, insecure random, hardcoded keys', scanner: 'security' },\n { id: 'file-ops', name: 'File Operations', description: 'Path traversal, unsafe uploads, directory listing', scanner: 'security' },\n // Quality categories\n { id: 'complexity', name: 'Complexity', description: 'Cyclomatic and cognitive complexity issues', scanner: 'quality' },\n { id: 'duplication', name: 'Code Duplication', description: 'Duplicated code blocks', scanner: 'quality' },\n { id: 'code-smells', name: 'Code Smells', description: 'Long methods, large files, dead code', scanner: 'quality' },\n { id: 'naming', name: 'Naming Conventions', description: 'Inconsistent or unclear naming', scanner: 'quality' },\n { id: 'metrics', name: 'Code Metrics', description: 'Lines of code, comment ratio, maintainability', scanner: 'quality' },\n];\n","import { Command } from 'commander';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { consola } from 'consola';\nimport type { ScanResult } from '../../types/finding.js';\nimport type { OutputFormat } from '../../types/config.js';\nimport { getReporter } from '../../reporters/index.js';\n\n/**\n * Create the 'report' command\n * Usage: deepscan report convert <input> --to <format> --output <file>\n */\nexport function createReportCommand(): Command {\n const report = new Command('report');\n report.description('Convert and manage scan reports');\n\n report\n .command('convert <input>')\n .description('Convert scan results between formats')\n .requiredOption('--to <format>', 'Target format: json, csv, html, sarif')\n .option('-o, --output <file>', 'Output file path')\n .action(async (input: string, options: { to: string; output?: string }) => {\n try {\n const inputPath = resolve(input);\n const content = readFileSync(inputPath, 'utf-8');\n const scanResult: ScanResult = JSON.parse(content);\n\n const reporter = getReporter(options.to as OutputFormat);\n const output = await reporter.generate(scanResult);\n\n if (options.output) {\n const outputPath = resolve(options.output);\n writeFileSync(outputPath, output, 'utf-8');\n consola.success(`Report converted to ${options.to}: ${outputPath}`);\n } else if (options.to === 'html') {\n const outputPath = resolve('report.html');\n writeFileSync(outputPath, output, 'utf-8');\n consola.success(`Report converted to ${options.to}: ${outputPath}`);\n } else {\n process.stdout.write(output);\n }\n } catch (error) {\n consola.error('Report conversion failed:', error);\n process.exitCode = 1;\n }\n });\n\n return report;\n}\n","#!/usr/bin/env node\nimport { createRequire } from 'node:module';\nimport { createCLI } from '../cli/index.js';\n\n// Run the CLI\nconst cli = createCLI();\ncli.parse(process.argv);\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,WAAAA,gBAAe;;;ACAxB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,eAAe;AAajB,SAAS,oBAA6B;AAC3C,QAAM,OAAO,IAAI,QAAQ,MAAM;AAE/B,OACG,YAAY,kEAAkE,EAC9E,SAAS,UAAU,6CAA6C,GAAG,EACnE,OAAO,6BAA6B,oFAAoF,EACxH,OAAO,cAAc,2BAA2B,EAChD,OAAO,aAAa,0BAA0B,EAC9C,OAAO,SAAS,iCAAiC,EACjD,OAAO,yBAAyB,kDAAkD,SAAS,EAC3F,OAAO,uBAAuB,kBAAkB,EAChD,OAAO,uBAAuB,mEAAmE,EACjG,OAAO,wBAAwB,yCAAyC,EACxE,OAAO,wBAAwB,yCAAyC,EACxE,OAAO,UAAU,0DAA0D,EAC3E,OAAO,QAAQ,kDAAkD,EACjE,OAAO,4BAA4B,gDAAgD,EACnF,OAAO,kBAAkB,gCAAgC,EACzD,OAAO,kBAAkB,8BAA8B,GAAG,EAC1D,OAAO,iBAAiB,qCAAqC,EAC7D,OAAO,mBAAmB,yEAAyE,EACnG,OAAO,mBAAmB,4BAA4B,EACtD,OAAO,OAAO,YAAoB,YAA0D;AAC3F,QAAI;AACF,YAAM,eAAe,QAAQ,UAAU;AAGvC,YAAM,eAAwC,CAAC;AAE/C,YAAM,kBAAkB,QAAQ,YAAY,QAAQ,WAAW,QAAQ;AACvE,UAAI,iBAAiB;AACnB,qBAAa,WAAW;AAAA,UACtB,UAAU,EAAE,SAAS,CAAC,CAAC,QA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W,mBAAmB,CAAC;AACvC,UAAQ,WAAW,oBAAoB,CAAC;AAGxC,UAAQ,OAAO,MAAM;AACnB,YAAQ,WAAW;AAAA,EACrB,CAAC;AAED,SAAO;AACT;;;AM9BA,IAAM,MAAM,UAAU;AACtB,IAAI,MAAM,QAAQ,IAAI;","names":["Command","Command","resolve","consola","Command","consola","Command","consola","Command","writeFileSync","resolve","consola","Command","resolve","writeFileSync","consola","Command"]}
1
+ {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/scan.ts","../../src/cli/commands/init.ts","../../src/cli/commands/rules.ts","../../src/types/rule.ts","../../src/cli/commands/report.ts","../../src/bin/deepscan.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { createScanCommand } from './commands/scan.js';\nimport { createInitCommand } from './commands/init.js';\nimport { createRulesCommand } from './commands/rules.js';\nimport { createReportCommand } from './commands/report.js';\nimport { DEEPSCAN_VERSION } from '../version.js';\n\nconst VERSION = DEEPSCAN_VERSION;\n\n/**\n * Create the DeepScan CLI application\n */\nexport function createCLI(): Command {\n const program = new Command();\n\n program\n .name('deepscan')\n .description('šŸ” DeepScan - Open-source security & code quality scanner')\n .version(VERSION, '-v, --version', 'Display version number')\n .option('--config <path>', 'Path to configuration file')\n .option('--verbose', 'Enable verbose output')\n .option('--quiet', 'Suppress all output except errors')\n .option('--no-color', 'Disable colored output');\n\n // Register commands\n program.addCommand(createScanCommand());\n program.addCommand(createInitCommand());\n program.addCommand(createRulesCommand());\n program.addCommand(createReportCommand());\n\n // Default action (no subcommand) → show help\n program.action(() => {\n program.outputHelp();\n });\n\n return program;\n}\n","import { Command } from 'commander';\nimport { resolve } from 'node:path';\nimport { consola } from 'consola';\nimport { loadConfig } from '../../config/loader.js';\nimport { ScanPipeline, generateFingerprint } from '../../core/pipeline.js';\nimport { applyBaseline, loadBaseline, saveBaseline } from '../../core/baseline.js';\nimport { SecurityScanner } from '../../scanners/security/index.js';\nimport { OperationsScanner } from '../../scanners/ops/index.js';\nimport { QualityScanner } from '../../scanners/quality/index.js';\nimport { CVEScanner } from '../../scanners/cve/index.js';\nimport { getReporter } from '../../reporters/index.js';\nimport type { OutputFormat } from '../../types/config.js';\n\n/**\n * Create the 'scan' command\n * Usage: deepscan scan [path] [options]\n */\nexport function createScanCommand(): Command {\n const scan = new Command('scan');\n\n scan\n .description('Scan source code for security and operational reliability issues (optional: quality, cve)')\n .argument('[path]', 'Path to scan (default: current directory)', '.')\n .allowExcessArguments(true)\n .option('-s, --scanners <scanners>', 'Scanner engines to use (comma-separated: security,ops,quality,cve) [default: security,ops]')\n .option('--security', 'Run security scanner only')\n .option('--ops', 'Run operational & OOM reliability scanner only')\n .option('--quality', 'Run quality scanner only')\n .option('--cve', 'Run CVE/dependency scanner only')\n .option('-f, --format <format>', 'Output format: json, csv, html, sarif, console', 'console')\n .option('-o, --output <file>', 'Output file path')\n .option('--severity <levels>', 'Filter by severity (comma-separated: critical,high,medium,low)')\n .option('--include <patterns>', 'Include file patterns (comma-separated)')\n .option('--exclude <patterns>', 'Exclude file patterns (comma-separated)')\n .option('--deep', 'Enable deep analysis (taint tracking, semantic analysis)')\n .option('--ai', 'Enable AI-assisted validation (requires API key)')\n .option('--ai-provider <provider>', 'AI provider: openai, anthropic, ollama, google')\n .option('--rules <path>', 'Path to custom rules directory')\n .option('--parallel <n>', 'Number of parallel workers', '4')\n .option('--incremental', 'Only scan changed files (git-based)')\n .option('--preset <name>', 'Use a preset configuration (node-api, python-web, java-spring, minimal)')\n .option('--config <path>', 'Path to configuration file')\n .option('--cache', 'Enable local result caching (default: true)', true)\n .option('--no-cache', 'Disable local result caching')\n .option('--cache-dir <dir>', 'Path to cache directory')\n .option('--fail-on <severities>', 'Fail scan (exit code 1) on matching severities (comma-separated: critical,high,medium,low)')\n .option('--baseline <file>', 'Ignore existing findings present in baseline JSON or prior scan report')\n .option('--save-baseline <file>', 'Save current finding fingerprints to a baseline JSON file')\n .option('-q, --quiet', 'Suppress progress output')\n .option('-w, --watch', 'Watch files and automatically re-scan on change')\n .action(async (targetPath: string, options: Record<string, string | boolean | undefined>, command: Command) => {\n try {\n const validScanners = new Set(['security', 'ops', 'quality', 'cve']);\n const extraArgs = (command?.args ?? []).slice(1);\n let resolvedTargetPath = targetPath;\n const extraScannerArgs: string[] = [];\n\n if (options.scanners && validScanners.has(targetPath)) {\n extraScannerArgs.push(targetPath);\n resolvedTargetPath = extraArgs.find(arg => !validScanners.has(arg)) ?? '.';\n }\n for (const arg of extraArgs) {\n if (validScanners.has(arg)) {\n extraScannerArgs.push(arg);\n }\n }\n\n const absolutePath = resolve(resolvedTargetPath);\n\n // Build CLI overrides from options\n const cliOverrides: Record<string, unknown> = {};\n\n const hasExplicitFlag = options.security || options.ops || options.quality || options.cve;\n if (hasExplicitFlag) {\n cliOverrides.scanners = {\n security: { enabled: !!options.security },\n ops: { enabled: !!options.ops },\n quality: { enabled: !!options.quality },\n cve: { enabled: !!options.cve },\n };\n } else if (options.scanners) {\n const rawScanners = String(options.scanners);\n // Windows PowerShell .ps1 shim converts unquoted comma lists (e.g. -s security,quality,cve) into \"System.Object[]\"\n if (rawScanners.includes('System.Object[]')) {\n cliOverrides.scanners = {\n security: { enabled: true },\n ops: { enabled: true },\n quality: { enabled: true },\n cve: { enabled: true },\n };\n } else {\n const scannerList = [\n ...rawScanners.split(/[\\s,]+/).map(s => s.trim().toLowerCase()).filter(Boolean),\n ...extraScannerArgs,\n ];\n const hasValidScanner = scannerList.some(s => validScanners.has(s));\n if (!hasValidScanner) {\n consola.warn(`No valid scanner found in \"${rawScanners}\". Falling back to default (security,ops).`);\n } else {\n cliOverrides.scanners = {\n security: { enabled: scannerList.includes('security') },\n ops: { enabled: scannerList.includes('ops') },\n quality: { enabled: scannerList.includes('quality') },\n cve: { enabled: scannerList.includes('cve') },\n };\n }\n }\n }\n\n if (options.format) {\n cliOverrides.output = { format: options.format };\n }\n\n if (options.severity) {\n const severities = (options.severity as string).split(/[\\s,]+/).map(s => s.trim()).filter(Boolean);\n if (!cliOverrides.scanners) cliOverrides.scanners = {};\n const scannersOverride = cliOverrides.scanners as Record<string, unknown>;\n const existingSec = (scannersOverride.security as Record<string, unknown>) || {};\n const existingOps = (scannersOverride.ops as Record<string, unknown>) || {};\n scannersOverride.security = { ...existingSec, severity: severities };\n scannersOverride.ops = { ...existingOps, severity: severities };\n }\n\n if (options.include) {\n cliOverrides.paths = {\n ...(cliOverrides.paths as Record<string, unknown> || {}),\n include: (options.include as string).split(','),\n };\n }\n\n if (options.exclude) {\n cliOverrides.paths = {\n ...(cliOverrides.paths as Record<string, unknown> || {}),\n exclude: (options.exclude as string).split(','),\n };\n }\n\n if (options.deep) cliOverrides.deep = true;\n if (options.incremental) cliOverrides.incremental = true;\n if (options.parallel) cliOverrides.parallel = parseInt(options.parallel as string, 10);\n if (options.cache === false) cliOverrides.cache = false;\n if (options.cacheDir) cliOverrides.cacheLocation = resolve(options.cacheDir as string, 'cache.json');\n if (options.failOn) cliOverrides.failOn = (options.failOn as string).split(',');\n if (options.watch) cliOverrides.watch = true;\n\n if (options.ai) {\n cliOverrides.ai = {\n enabled: true,\n provider: options.aiProvider || 'openai',\n };\n }\n\n if (options.rules) {\n cliOverrides.rules = { custom: [(options.rules as string)] };\n }\n\n const runScanIteration = async () => {\n // Load configuration\n const config = await loadConfig({\n configPath: options.config as string,\n targetPath: absolutePath,\n cliOverrides: cliOverrides as any,\n preset: options.preset as string,\n });\n\n // Override output format from CLI\n if (options.format) {\n config.output.format = options.format as OutputFormat;\n }\n\n // Create pipeline\n const pipeline = new ScanPipeline(config);\n\n // Register enabled scanners\n if (config.scanners.security.enabled) {\n pipeline.addScanner(new SecurityScanner());\n }\n if (config.scanners.ops?.enabled) {\n pipeline.addScanner(new OperationsScanner());\n }\n if (config.scanners.quality.enabled) {\n pipeline.addScanner(new QualityScanner());\n }\n if (config.scanners.cve.enabled) {\n pipeline.addScanner(new CVEScanner());\n }\n\n const isQuiet = Boolean(options.quiet || command.parent?.opts()?.quiet);\n\n // Run scan with progress\n const rawResult = await pipeline.run({\n config,\n targetPath: absolutePath,\n onProgress: (current, total, file) => {\n if (!isQuiet && !options.watch) {\n const pct = Math.round((current / total) * 100);\n const fileDisplay = file.length > 50 ? '...' + file.slice(-47) : file;\n process.stderr.write(`\\r Scanning... ${pct}% (${current}/${total}) ${fileDisplay.padEnd(50)}`);\n }\n },\n });\n\n // Clear progress line\n if (!isQuiet && !options.watch) {\n process.stderr.write('\\r' + ' '.repeat(120) + '\\r');\n }\n\n if (options.saveBaseline) {\n const baselineOut = resolve(options.saveBaseline as string);\n saveBaseline(baselineOut, rawResult.findings);\n consola.success(`Saved baseline with ${rawResult.findings.length} finding(s) to: ${baselineOut}`);\n }\n\n let result = rawResult;\n if (options.baseline) {\n const baselinePath = resolve(options.baseline as string);\n const baselineSet = loadBaseline(baselinePath);\n const applied = applyBaseline(rawResult, baselineSet);\n result = applied.result;\n if (applied.suppressedCount > 0) {\n consola.info(`Baseline suppressed ${applied.suppressedCount} existing finding(s); ${result.summary.totalFindings} new finding(s) remain.`);\n }\n }\n\n // Generate report\n const reporter = getReporter(config.output.format);\n const output = await reporter.generate(result);\n\n // Write to file or stdout\n if (options.output) {\n await reporter.writeToFile(result, options.output as string);\n consola.success(`Report written to: ${options.output}`);\n } else if (config.output.format === 'html') {\n const defaultPath = 'report.html';\n await reporter.writeToFile(result, defaultPath);\n consola.success(`Report written to: ${defaultPath}`);\n } else if (config.output.format !== 'console') {\n // For non-console formats, write to stdout\n process.stdout.write(output);\n } else {\n // Console format already printed\n process.stdout.write(output);\n }\n\n // Check failure thresholds\n const failSeverities = config.failOn || ['critical', 'high'];\n const hasFailingFindings = failSeverities.some(sev => (result.summary.bySeverity[sev] || 0) > 0);\n\n if (hasFailingFindings) {\n process.exitCode = 1;\n } else {\n process.exitCode = 0;\n }\n\n return result;\n };\n\n // Execute initial scan\n await runScanIteration();\n\n // If watch mode is enabled, listen for file changes\n if (options.watch) {\n const { watch } = await import('node:fs');\n consola.info('šŸ‘€ Watch mode active. Waiting for file changes (press Ctrl+C to stop)...');\n\n let debounceTimer: NodeJS.Timeout | null = null;\n let isScanning = false;\n\n try {\n watch(absolutePath, { recursive: true }, (eventType, filename) => {\n if (!filename) return;\n const norm = filename.replace(/\\\\/g, '/');\n if (\n norm.includes('node_modules') ||\n norm.includes('.git') ||\n norm.includes('.deepscan') ||\n norm.endsWith('.tmp') ||\n norm.endsWith('.log')\n ) {\n return;\n }\n\n if (debounceTimer) clearTimeout(debounceTimer);\n debounceTimer = setTimeout(async () => {\n if (isScanning) return;\n isScanning = true;\n console.log(`\\nšŸ”„ Change detected in ${filename}. Re-scanning...\\n`);\n try {\n await runScanIteration();\n } catch (err) {\n consola.error('Scan error during watch:', err);\n } finally {\n isScanning = false;\n }\n }, 300);\n });\n } catch (watchErr) {\n consola.warn('Recursive watch failed, falling back to non-recursive watch:', watchErr);\n }\n }\n } catch (error) {\n consola.error('Scan failed:', error);\n process.exitCode = 2;\n }\n });\n\n return scan;\n}\n","import { Command } from 'commander';\nimport { writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport yaml from 'js-yaml';\nimport { consola } from 'consola';\nimport { DEFAULT_CONFIG } from '../../config/defaults.js';\n\n/**\n * Create the 'init' command\n * Usage: deepscan init\n */\nexport function createInitCommand(): Command {\n const init = new Command('init');\n\n init\n .description('Initialize a .deepscan.yml configuration file in the current directory')\n .option('--preset <name>', 'Use a preset: node-api, python-web, java-spring, minimal')\n .option('--format <format>', 'Config file format: yml, json', 'yml')\n .action(async (options: Record<string, string | undefined>) => {\n try {\n const config = {\n version: '1.0',\n scanners: {\n security: {\n enabled: true,\n severity: ['critical', 'high', 'medium', 'low'],\n },\n quality: {\n enabled: false,\n thresholds: {\n maxComplexity: 15,\n maxFileLength: 500,\n maxFunctionLength: 50,\n },\n },\n cve: {\n enabled: false,\n sources: ['osv'],\n },\n ops: {\n enabled: true,\n severity: ['critical', 'high', 'medium', 'low'],\n },\n },\n rules: {\n include: ['*'],\n exclude: [],\n custom: [],\n },\n paths: {\n include: ['**/*'],\n exclude: [\n 'node_modules/',\n 'vendor/',\n 'dist/',\n 'build/',\n '.git/',\n 'storage/',\n 'bootstrap/cache/',\n 'public/build/',\n 'assets/',\n '**/node_modules/**',\n '**/vendor/**',\n '**/dist/**',\n '**/build/**',\n '**/.git/**',\n '**/storage/**',\n '**/bootstrap/cache/**',\n '**/public/build/**',\n '**/assets/**',\n ],\n },\n output: {\n format: 'console',\n },\n ai: {\n enabled: false,\n },\n };\n\n const format = options.format || 'yml';\n const fileName = format === 'json' ? '.deepscan.json' : '.deepscan.yml';\n const filePath = resolve(process.cwd(), fileName);\n\n let content: string;\n if (format === 'json') {\n content = JSON.stringify(config, null, 2);\n } else {\n content = '# DeepScan Configuration\\n# https://github.com/deepscan/deepscan-cli\\n\\n'\n + yaml.dump(config, { indent: 2, lineWidth: 100, quotingType: '\"' });\n }\n\n writeFileSync(filePath, content, 'utf-8');\n consola.success(`Created ${fileName}`);\n consola.info('Customize the configuration and run: deepscan scan');\n } catch (error) {\n consola.error('Init failed:', error);\n process.exitCode = 1;\n }\n });\n\n return init;\n}\n","import { Command } from 'commander';\nimport { consola } from 'consola';\nimport chalk from 'chalk';\nimport { RuleEngine } from '../../rules/rule-engine.js';\nimport { DEFAULT_CONFIG } from '../../config/defaults.js';\nimport type { DeepScanConfig } from '../../types/config.js';\nimport { RULE_CATEGORIES } from '../../types/rule.js';\n\n/**\n * Create the 'rules' command group\n * Usage: deepscan rules list|info\n */\nexport function createRulesCommand(): Command {\n const rules = new Command('rules');\n rules.description('Manage and inspect scanning rules');\n\n // Subcommand: list\n rules\n .command('list')\n .description('List all available rules')\n .option('-c, --category <category>', 'Filter by category')\n .option('-s, --severity <severity>', 'Filter by severity')\n .option('-l, --language <language>', 'Filter by language')\n .option('--scanner <type>', 'Filter by scanner type (security, ops, quality)')\n .action(async (options: Record<string, string | undefined>) => {\n try {\n const ruleEngine = new RuleEngine(DEFAULT_CONFIG as DeepScanConfig);\n await ruleEngine.initialize();\n\n let allRules = ruleEngine.getAllRules();\n\n // Apply filters\n if (options.category) {\n allRules = allRules.filter(r => r.category === options.category);\n }\n if (options.severity) {\n allRules = allRules.filter(r => r.severity === options.severity);\n }\n if (options.language) {\n allRules = allRules.filter(r => r.languages.includes(options.language!) || r.languages.includes('*'));\n }\n if (options.scanner) {\n const secCategories = ['injection', 'xss', 'secrets', 'auth', 'crypto', 'file-ops', 'api-security'];\n const opsCategories = ['oom-memory', 'timeout-resilience', 'resource-leaks', 'ops-performance'];\n if (options.scanner === 'security') {\n allRules = allRules.filter(r => secCategories.includes(r.category));\n } else if (options.scanner === 'ops') {\n allRules = allRules.filter(r => opsCategories.includes(r.category));\n } else {\n allRules = allRules.filter(\n r => !secCategories.includes(r.category) && !opsCategories.includes(r.category),\n );\n }\n }\n\n // Display results\n console.log(chalk.bold(`\\nšŸ“‹ DeepScan Rules (${allRules.length} rules)\\n`));\n\n const severityColors: Record<string, (s: string) => string> = {\n critical: chalk.bgRed.white,\n high: chalk.red,\n medium: chalk.yellow,\n low: chalk.blue,\n };\n\n for (const rule of allRules) {\n const sevColor = severityColors[rule.severity] || chalk.white;\n const id = chalk.cyan(rule.id.padEnd(35));\n const sev = sevColor(rule.severity.padEnd(10));\n const langs = chalk.gray(rule.languages.join(', '));\n console.log(` ${id} ${sev} ${rule.name}`);\n console.log(` ${' '.repeat(35)} ${chalk.dim(rule.description.slice(0, 80))}`);\n console.log(` ${' '.repeat(35)} Languages: ${langs}`);\n console.log();\n }\n } catch (error) {\n consola.error('Failed to list rules:', error);\n }\n });\n\n // Subcommand: info\n rules\n .command('info <ruleId>')\n .description('Show detailed information about a specific rule')\n .action(async (ruleId: string) => {\n try {\n const ruleEngine = new RuleEngine(DEFAULT_CONFIG as DeepScanConfig);\n await ruleEngine.initialize();\n\n const rule = ruleEngine.getRule(ruleId);\n if (!rule) {\n consola.error(`Rule not found: ${ruleId}`);\n return;\n }\n\n console.log(chalk.bold(`\\nšŸ” Rule: ${rule.id}\\n`));\n console.log(` ${chalk.bold('Name:')} ${rule.name}`);\n console.log(` ${chalk.bold('Category:')} ${rule.category}`);\n console.log(` ${chalk.bold('Severity:')} ${rule.severity}`);\n console.log(` ${chalk.bold('Confidence:')} ${rule.confidence}`);\n console.log(` ${chalk.bold('Languages:')} ${rule.languages.join(', ')}`);\n console.log(` ${chalk.bold('Description:')} ${rule.description}`);\n\n if (rule.cwe?.length) {\n console.log(` ${chalk.bold('CWE:')} ${rule.cwe.join(', ')}`);\n }\n if (rule.owasp?.length) {\n console.log(` ${chalk.bold('OWASP:')} ${rule.owasp.join(', ')}`);\n }\n if (rule.fix) {\n console.log(` ${chalk.bold('Fix:')} ${rule.fix.description}`);\n }\n if (rule.references?.length) {\n console.log(` ${chalk.bold('References:')}`);\n for (const ref of rule.references) {\n console.log(` - ${chalk.underline(ref)}`);\n }\n }\n if (rule.tags?.length) {\n console.log(` ${chalk.bold('Tags:')} ${rule.tags.join(', ')}`);\n }\n console.log();\n } catch (error) {\n consola.error('Failed to get rule info:', error);\n }\n });\n\n // Subcommand: categories\n rules\n .command('categories')\n .description('List all rule categories')\n .action(async () => {\n console.log(chalk.bold('\\nšŸ“‚ Rule Categories\\n'));\n for (const cat of RULE_CATEGORIES) {\n const scanner =\n cat.scanner === 'security'\n ? chalk.red('šŸ›” Security')\n : cat.scanner === 'ops'\n ? chalk.magenta('āš™ļø Ops')\n : chalk.blue('šŸ“Š Quality');\n console.log(` ${chalk.cyan(cat.id.padEnd(20))} ${scanner} ${cat.name}`);\n console.log(` ${' '.repeat(20)} ${chalk.dim(cat.description)}`);\n console.log();\n }\n });\n\n return rules;\n}\n","import type { Severity, Confidence } from './finding.js';\n\n// ─── Rule Types ────────────────────────────────────────────────────────────\n\n/** Pattern definition within a rule */\nexport interface RulePattern {\n /** Tree-sitter query or code pattern */\n pattern?: string;\n /** Message to display when this pattern matches */\n message?: string;\n /** Regex pattern (for non-AST matching) */\n regex?: string;\n /** Flags for regex */\n regexFlags?: string;\n}\n\n/** Condition for advanced rule logic */\nexport interface RuleCondition {\n type: 'taint-check' | 'context-check' | 'scope-check' | 'ast-check';\n /** For taint-check: source type */\n source?: string;\n /** For taint-check: sink variable */\n sink?: string;\n /** For context-check: contexts to include/exclude */\n in?: string[];\n notIn?: string[];\n /** For scope-check */\n scope?: string;\n}\n\n/** Fix suggestion within a rule */\nexport interface RuleFix {\n description: string;\n replacement?: string;\n}\n\n/** A single rule definition */\nexport interface Rule {\n id: string;\n name: string;\n description: string;\n category: string;\n subcategory?: string;\n severity: Severity;\n confidence: Confidence;\n cwe?: string[];\n owasp?: string[];\n languages: string[];\n patterns: RulePattern[];\n conditions?: RuleCondition[];\n fix?: RuleFix;\n tags?: string[];\n references?: string[];\n enabled?: boolean;\n}\n\n/** Collection of rules in a YAML file */\nexport interface RuleFile {\n rules: Rule[];\n}\n\n/** Rule category for organization */\nexport interface RuleCategory {\n id: string;\n name: string;\n description: string;\n scanner: 'security' | 'quality' | 'ops';\n}\n\n/** Default rule categories */\nexport const RULE_CATEGORIES: RuleCategory[] = [\n // Security categories\n { id: 'injection', name: 'Injection', description: 'SQL, Command, LDAP, XPath injection vulnerabilities', scanner: 'security' },\n { id: 'xss', name: 'Cross-Site Scripting', description: 'XSS vulnerabilities including DOM-based and reflected', scanner: 'security' },\n { id: 'secrets', name: 'Secrets & Credentials', description: 'Hardcoded passwords, API keys, tokens', scanner: 'security' },\n { id: 'auth', name: 'Authentication & Authorization', description: 'Weak auth patterns, missing authorization', scanner: 'security' },\n { id: 'crypto', name: 'Cryptography', description: 'Weak algorithms, insecure random, hardcoded keys', scanner: 'security' },\n { id: 'file-ops', name: 'File Operations', description: 'Path traversal, unsafe uploads, directory listing', scanner: 'security' },\n // Operations & Reliability categories\n { id: 'oom-memory', name: 'OOM & Unbounded Memory', description: 'Unbounded queries without pagination, full-body buffering, uncapped page limits, and unbounded caches', scanner: 'ops' },\n { id: 'timeout-resilience', name: 'Timeouts & Resilience', description: 'Missing HTTP/client timeouts, unbounded retry loops, and unsafe pool limits', scanner: 'ops' },\n { id: 'resource-leaks', name: 'Resource & Connection Leaks', description: 'Unclosed handles/connections, per-request DB clients, and uncleaned timers or listeners', scanner: 'ops' },\n { id: 'ops-performance', name: 'Operational Bottlenecks', description: 'N+1 queries in loops, blocking sync I/O in async handlers, unbounded Promise.all fan-out, and ReDoS', scanner: 'ops' },\n // Quality categories\n { id: 'complexity', name: 'Complexity', description: 'Cyclomatic and cognitive complexity issues', scanner: 'quality' },\n { id: 'duplication', name: 'Code Duplication', description: 'Duplicated code blocks', scanner: 'quality' },\n { id: 'code-smells', name: 'Code Smells', description: 'Long methods, large files, dead code', scanner: 'quality' },\n { id: 'naming', name: 'Naming Conventions', description: 'Inconsistent or unclear naming', scanner: 'quality' },\n { id: 'metrics', name: 'Code Metrics', description: 'Lines of code, comment ratio, maintainability', scanner: 'quality' },\n];\n","import { Command } from 'commander';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { consola } from 'consola';\nimport type { ScanResult } from '../../types/finding.js';\nimport type { OutputFormat } from '../../types/config.js';\nimport { getReporter } from '../../reporters/index.js';\n\n/**\n * Create the 'report' command\n * Usage: deepscan report convert <input> --to <format> --output <file>\n */\nexport function createReportCommand(): Command {\n const report = new Command('report');\n report.description('Convert and manage scan reports');\n\n report\n .command('convert <input>')\n .description('Convert scan results between formats')\n .requiredOption('--to <format>', 'Target format: json, csv, html, sarif')\n .option('-o, --output <file>', 'Output file path')\n .action(async (input: string, options: { to: string; output?: string }) => {\n try {\n const inputPath = resolve(input);\n const content = readFileSync(inputPath, 'utf-8');\n const scanResult: ScanResult = JSON.parse(content);\n\n const reporter = getReporter(options.to as OutputFormat);\n const output = await reporter.generate(scanResult);\n\n if (options.output) {\n const outputPath = resolve(options.output);\n writeFileSync(outputPath, output, 'utf-8');\n consola.success(`Report converted to ${options.to}: ${outputPath}`);\n } else if (options.to === 'html') {\n const outputPath = resolve('report.html');\n writeFileSync(outputPath, output, 'utf-8');\n consola.success(`Report converted to ${options.to}: ${outputPath}`);\n } else {\n process.stdout.write(output);\n }\n } catch (error) {\n consola.error('Report conversion failed:', error);\n process.exitCode = 1;\n }\n });\n\n return report;\n}\n","#!/usr/bin/env node\nimport { createRequire } from 'node:module';\nimport { createCLI } from '../cli/index.js';\n\n// Run the CLI\nconst cli = createCLI();\ncli.parse(process.argv);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAAA,gBAAe;;;ACAxB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,eAAe;AAejB,SAAS,oBAA6B;AAC3C,QAAM,OAAO,IAAI,QAAQ,MAAM;AAE/B,OACG,YAAY,2FAA2F,EACvG,SAAS,UAAU,6CAA6C,GAAG,EACnE,qBAAqB,IAAI,EACzB,OAAO,6BAA6B,4FAA4F,EAChI,OAAO,cAAc,2BAA2B,EAChD,OAAO,SAAS,gDAAgD,EAChE,OAAO,aAAa,0BAA0B,EAC9C,OAAO,SAAS,iCAAiC,EACjD,OAAO,yBAAyB,kDAAkD,SAAS,EAC3F,OAAO,uBAAuB,kBAAkB,EAChD,OAAO,uBAAuB,gEAAgE,EAC9F,OAAO,wBAAwB,yCAAyC,EACxE,OAAO,wBAAwB,yCAAyC,EACxE,OAAO,UAAU,0DAA0D,EAC3E,OAAO,QAAQ,kDAAkD,EACjE,OAAO,4BAA4B,gDAAgD,EACnF,OAAO,kBAAkB,gCAAgC,EACzD,OAAO,kBAAkB,8BAA8B,GAAG,EAC1D,OAAO,iBAAiB,qCAAqC,EAC7D,OAAO,mBAAmB,yEAAyE,EACnG,OAAO,mBAAmB,4BAA4B,EACtD,OAAO,WAAW,+CAA+C,IAAI,EACrE,OAAO,cAAc,8BAA8B,EACnD,OAAO,qBAAqB,yBAAyB,EACrD,OAAO,0BAA0B,4FAA4F,EAC7H,OAAO,qBAAqB,wEAAwE,EACpG,OAAO,0BAA0B,2DAA2D,EAC5F,OAAO,eAAe,0BAA0B,EAChD,OAAO,eAAe,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AS,OAAO;AACd,MAAAA,SAAQ,MAAM,6BAA6B,KAAK;AAChD,cAAQ,WAAW;AAAA,IACrB;AAAA,EACF,CAAC;AAEH,SAAO;AACT;;;ALzCA,IAAM,UAAU;AAKT,SAAS,YAAqB;AACnC,QAAM,UAAU,IAAIC,SAAQ;AAE5B,UACG,KAAK,UAAU,EACf,YAAY,kEAA2D,EACvE,QAAQ,SAAS,iBAAiB,wBAAwB,EAC1D,OAAO,mBAAmB,4BAA4B,EACtD,OAAO,aAAa,uBAAuB,EAC3C,OAAO,WAAW,mCAAmC,EACrD,OAAO,cAAc,wBAAwB;AAGhD,UAAQ,WAAW,kBAAkB,CAAC;AACtC,UAAQ,WAAW,kBAAkB,CAAC;AACtC,UAAQ,WAAW,mBAAmB,CAAC;AACvC,UAAQ,WAAW,oBAAoB,CAAC;AAGxC,UAAQ,OAAO,MAAM;AACnB,YAAQ,WAAW;AAAA,EACrB,CAAC;AAED,SAAO;AACT;;;AM/BA,IAAM,MAAM,UAAU;AACtB,IAAI,MAAM,QAAQ,IAAI;","names":["Command","Command","resolve","consola","Command","consola","Command","consola","Command","writeFileSync","resolve","consola","Command","resolve","writeFileSync","consola","Command"]}