kramscan 0.1.1 → 0.3.0

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 (91) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +419 -236
  3. package/dist/agent/confirmation.d.ts +5 -1
  4. package/dist/agent/confirmation.js +29 -9
  5. package/dist/agent/context.js +2 -3
  6. package/dist/agent/orchestrator.d.ts +2 -0
  7. package/dist/agent/orchestrator.js +50 -8
  8. package/dist/agent/prompts/system.d.ts +1 -1
  9. package/dist/agent/prompts/system.js +5 -7
  10. package/dist/agent/skills/health-check.js +22 -2
  11. package/dist/agent/skills/index.d.ts +1 -0
  12. package/dist/agent/skills/index.js +3 -1
  13. package/dist/agent/skills/verify-finding.d.ts +17 -0
  14. package/dist/agent/skills/verify-finding.js +91 -0
  15. package/dist/agent/skills/web-scan.js +46 -0
  16. package/dist/cli.js +156 -149
  17. package/dist/commands/agent.js +38 -38
  18. package/dist/commands/ai.d.ts +2 -0
  19. package/dist/commands/ai.js +112 -0
  20. package/dist/commands/analyze.js +103 -54
  21. package/dist/commands/config.js +55 -29
  22. package/dist/commands/dev.d.ts +2 -0
  23. package/dist/commands/dev.js +236 -0
  24. package/dist/commands/doctor.js +20 -15
  25. package/dist/commands/gate.d.ts +2 -0
  26. package/dist/commands/gate.js +109 -0
  27. package/dist/commands/onboard.js +188 -141
  28. package/dist/commands/report.js +68 -76
  29. package/dist/commands/scan.js +262 -81
  30. package/dist/commands/scans.d.ts +2 -0
  31. package/dist/commands/scans.js +55 -0
  32. package/dist/core/ai-client.d.ts +6 -1
  33. package/dist/core/ai-client.js +80 -12
  34. package/dist/core/ai-payloads.d.ts +17 -0
  35. package/dist/core/ai-payloads.js +54 -0
  36. package/dist/core/config-schema.d.ts +197 -0
  37. package/dist/core/config-schema.js +68 -0
  38. package/dist/core/config-schema.test.d.ts +1 -0
  39. package/dist/core/config-schema.test.js +151 -0
  40. package/dist/core/config.d.ts +8 -31
  41. package/dist/core/config.js +71 -14
  42. package/dist/core/diff-engine.d.ts +12 -0
  43. package/dist/core/diff-engine.js +47 -0
  44. package/dist/core/errors.d.ts +71 -0
  45. package/dist/core/errors.js +162 -0
  46. package/dist/core/scan-index.d.ts +20 -0
  47. package/dist/core/scan-index.js +52 -0
  48. package/dist/core/scan-storage.d.ts +11 -0
  49. package/dist/core/scan-storage.js +69 -0
  50. package/dist/core/scanner.d.ts +95 -13
  51. package/dist/core/scanner.js +342 -248
  52. package/dist/core/server-probe.d.ts +20 -0
  53. package/dist/core/server-probe.js +109 -0
  54. package/dist/core/vulnerability-detector.d.ts +9 -0
  55. package/dist/core/vulnerability-detector.js +46 -15
  56. package/dist/core/vulnerability-detector.test.d.ts +1 -0
  57. package/dist/core/vulnerability-detector.test.js +210 -0
  58. package/dist/index.js +3 -0
  59. package/dist/plugins/PluginManager.d.ts +27 -0
  60. package/dist/plugins/PluginManager.js +166 -0
  61. package/dist/plugins/index.d.ts +12 -0
  62. package/dist/plugins/index.js +29 -0
  63. package/dist/plugins/types.d.ts +55 -0
  64. package/dist/plugins/types.js +25 -0
  65. package/dist/plugins/vulnerabilities/CORSAnalyzerPlugin.d.ts +10 -0
  66. package/dist/plugins/vulnerabilities/CORSAnalyzerPlugin.js +67 -0
  67. package/dist/plugins/vulnerabilities/CSRFPlugin.d.ts +8 -0
  68. package/dist/plugins/vulnerabilities/CSRFPlugin.js +34 -0
  69. package/dist/plugins/vulnerabilities/CookieSecurityPlugin.d.ts +10 -0
  70. package/dist/plugins/vulnerabilities/CookieSecurityPlugin.js +91 -0
  71. package/dist/plugins/vulnerabilities/DebugEndpointPlugin.d.ts +15 -0
  72. package/dist/plugins/vulnerabilities/DebugEndpointPlugin.js +222 -0
  73. package/dist/plugins/vulnerabilities/DirectoryTraversalPlugin.d.ts +13 -0
  74. package/dist/plugins/vulnerabilities/DirectoryTraversalPlugin.js +110 -0
  75. package/dist/plugins/vulnerabilities/OpenRedirectPlugin.d.ts +10 -0
  76. package/dist/plugins/vulnerabilities/OpenRedirectPlugin.js +69 -0
  77. package/dist/plugins/vulnerabilities/SQLInjectionPlugin.d.ts +11 -0
  78. package/dist/plugins/vulnerabilities/SQLInjectionPlugin.js +109 -0
  79. package/dist/plugins/vulnerabilities/SecurityHeadersPlugin.d.ts +11 -0
  80. package/dist/plugins/vulnerabilities/SecurityHeadersPlugin.js +63 -0
  81. package/dist/plugins/vulnerabilities/SensitiveDataPlugin.d.ts +9 -0
  82. package/dist/plugins/vulnerabilities/SensitiveDataPlugin.js +32 -0
  83. package/dist/plugins/vulnerabilities/XSSPlugin.d.ts +15 -0
  84. package/dist/plugins/vulnerabilities/XSSPlugin.js +81 -0
  85. package/dist/reports/PdfGenerator.d.ts +36 -0
  86. package/dist/reports/PdfGenerator.js +404 -0
  87. package/dist/utils/logger.d.ts +33 -1
  88. package/dist/utils/logger.js +127 -8
  89. package/dist/utils/theme.d.ts +56 -0
  90. package/dist/utils/theme.js +201 -0
  91. package/package.json +6 -3
package/README.md CHANGED
@@ -1,236 +1,419 @@
1
- <div align="center">
2
- <img src="https://github.com/user-attachments/assets/6439c670-8d73-4bdd-b8fa-c74de949a31e" width="500" alt="KramScan Logo" />
3
-
4
- <h3 align="center">AI-Powered Web Application Security Testing CLI</h3>
5
-
6
- <br />
7
-
8
- [![npm version](https://img.shields.io/npm/v/kramscan?style=for-the-badge&logo=npm&logoColor=white&color=cb3837)](https://www.npmjs.com/package/kramscan)
9
- [![npm downloads](https://img.shields.io/npm/dm/kramscan?style=for-the-badge&logo=npm&logoColor=white&color=blue)](https://www.npmjs.com/package/kramscan)
10
- [![License](https://img.shields.io/github/license/shaikhakramshakil/kramscan?style=for-the-badge&logo=github&logoColor=white&color=green)](https://github.com/shaikhakramshakil/kramscan/blob/main/LICENSE)
11
- [![Stars](https://img.shields.io/github/stars/shaikhakramshakil/kramscan?style=for-the-badge&logo=github&logoColor=white&color=yellow)](https://github.com/shaikhakramshakil/kramscan)
12
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.4-3178c6?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org)
13
- [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18-brightgreen?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org)
14
-
15
- <br />
16
-
17
- 🔬 **A next-generation security auditing tool that combines automated vulnerability scanning with multi-provider AI analysis.**
18
-
19
- *Empowering developers and security researchers with institutional-grade insights and an interactive AI agent.*
20
-
21
- <br />
22
-
23
- [🌐 NPM Package](https://www.npmjs.com/package/kramscan) · [📖 Documentation](#-usage) · [🐞 Report Bug](https://github.com/shaikhakramshakil/kramscan/issues)
24
-
25
- </div>
26
-
27
- ---
28
-
29
- <br />
30
-
31
- ## 🚀 The Problem We Solve
32
- Web security is complex and often fragmented. Developers rely on multiple disjointed tools for scanning, manual testing, and reporting. Traditional automated scanners generate noise without context, and manual pentesting is time-consuming and expensive.
33
-
34
- **KramScan bridges this gap.** We provide a unified command-line interface that orchestrates headless browser scanning, scrapes critical security headers, and leverages **Generative AI** (OpenAI, Gemini, Anthropic) to analyze findings. It delivers actionable, human-readable insights alongside raw vulnerability data—all in seconds.
35
-
36
- <br />
37
-
38
- ---
39
-
40
- <br />
41
-
42
- ## ✨ Key Features
43
- | Feature | Description |
44
- | :--- | :--- |
45
- | 🔍 **Automated Vulnerability Engine** | Detects XSS, SQL Injection, CSRF, and insecure headers using Puppeteer-powered crawling. |
46
- | 🤖 **Interactive AI Agent** | A conversational security assistant that understands natural language commands like "scan example.com". |
47
- | 🧠 **Multi-Provider AI Analysis** | Supports OpenAI, Anthropic, Google Gemini, Mistral, OpenRouter, and Kimi (Moonshot). |
48
- | 📄 **Professional Reporting** | Generates detailed DOCX, TXT, and JSON reports with executive summaries and remediation steps. |
49
- | 🌐 **Headless Browser Testing** | Renders modern SPAs (Single Page Applications) to find vulnerabilities in dynamic content. |
50
- | **CLI-First Architecture** | Optimized for speed, scriptability, and seamless integration into CI/CD pipelines. |
51
-
52
- <br />
53
-
54
- ---
55
-
56
- <br />
57
-
58
- ## 🏗️ Architecture & Workflow
59
-
60
- ```mermaid
61
- graph LR
62
- A[User Command] --> B{CLI Controller};
63
- B --> C[Scanner Module<br/>Puppeteer / Cheerio];
64
- B --> D[AI Agent<br/>NLP Processing];
65
-
66
- C --> E[Vulnerability Detection<br/>XSS / SQLi / Headers];
67
- C --> F[Data Aggregation];
68
-
69
- E & F --> G[AI Analysis Engine<br/>LLM Provider];
70
-
71
- G --> H[Risk Assessment<br/>Confidence Scoring];
72
- H --> I[Report Generator<br/>DOCX / JSON / TXT];
73
- I --> J((Final Output));
74
- ```
75
-
76
- <br />
77
-
78
- ---
79
-
80
- <br />
81
-
82
- ## 🧪 Tech Stack
83
- <div align="center">
84
-
85
- | Component | Technology |
86
- | :--- | :--- |
87
- | **Runtime** | Node.js 18 |
88
- | **Language** | TypeScript 5.4 |
89
- | **CLI Framework** | Commander.js, Inquirer.js |
90
- | **Browser Automation** | Puppeteer (Headless Chrome) |
91
- | **AI Integration** | OpenAI SDK, Google Generative AI, Anthropic SDK |
92
- | **Reporting** | Docx, Chalk|
93
- | **Package Manager** | NPM / Yarn / PNPM |
94
-
95
- </div>
96
-
97
- <br />
98
-
99
- ---
100
-
101
- <br />
102
-
103
- ## 🧠 Supported AI Providers
104
-
105
- | Provider | SDK / Integration | Default Model |
106
- | :--- | :--- | :--- |
107
- | **OpenAI** | `openai` | `gpt-4` |
108
- | **Anthropic** | `@anthropic-ai/sdk` | `claude-3-5-sonnet-20241022` |
109
- | **Google Gemini** | `@google/generative-ai` | `gemini-2.0-flash-exp` |
110
- | **Mistral** | `@mistralai/mistralai` | `mistral-large-latest` |
111
- | **OpenRouter** | OpenAI-compatible | `anthropic/claude-3.5-sonnet` |
112
- | **Kimi** | OpenAI-compatible | `moonshot-v1-8k` |
113
-
114
- > Switch providers instantly with `kramscan onboard` or by editing `~/.kramscan/config.json`.
115
-
116
- <br />
117
-
118
- ---
119
-
120
- <br />
121
-
122
- ## 🚀 Quick Start
123
-
124
- ### 1. Installation
125
- Install KramScan globally using npm:
126
-
127
- ```bash
128
- npm install -g kramscan
129
- ```
130
-
131
- ### 2. First-Time Setup
132
- Initialize the configuration wizard to set up your AI provider and API keys:
133
-
134
- ```bash
135
- kramscan onboard
136
- ```
137
-
138
- ### 3. Run a Scan
139
- Execute a full security scan on a target URL:
140
-
141
- ```bash
142
- kramscan scan https://example.com
143
- ```
144
-
145
- <br />
146
-
147
- ---
148
-
149
- <br />
150
-
151
- ## 📖 Usage & Commands
152
-
153
- | Command | Description | Status |
154
- | :--- | :--- | :---: |
155
- | `kramscan` | Launch the interactive dashboard menu. | ✅ Stable |
156
- | `kramscan scan <url>` | Run a comprehensive vulnerability scan. | ✅ Stable |
157
- | `kramscan agent` | Start the conversational AI security assistant. | ✅ Stable |
158
- | `kramscan analyze` | Analyze previous scan results using the configured AI. | ✅ Stable |
159
- | `kramscan report` | Generate a professional report from scan data. | ✅ Stable |
160
- | `kramscan onboard` | Run the configuration and setup wizard. | ✅ Stable |
161
- | `kramscan doctor` | Verify environment health and dependencies. | ✅ Stable |
162
- | `kramscan config` | View and edit current configuration settings. | ✅ Stable |
163
-
164
- <br />
165
-
166
- ### Example Agent Session
167
- ```bash
168
- $ kramscan agent
169
- > scan https://example.com
170
-
171
- Agent: I'll perform a comprehensive security scan of https://example.com.
172
- Checking for XSS, SQLi, and missing headers...
173
- [Scanning...]
174
-
175
- Agent: Scan complete! Found 2 High severity issues.
176
- Would you like me to generate a report?
177
- ```
178
-
179
- <br />
180
-
181
- ---
182
-
183
- <br />
184
-
185
- ## 🗺️ Roadmap
186
-
187
- - [x] Core vulnerability scanner (XSS, SQLi, CSRF, headers)
188
- - [x] Multi-provider AI analysis engine
189
- - [x] Interactive AI agent mode
190
- - [x] Professional report generation (DOCX, TXT, JSON)
191
- - [x] Configuration wizard & management
192
- - [ ] Plugin system for custom scan modules
193
- - [ ] CI/CD integration (GitHub Actions, GitLab CI)
194
- - [ ] PDF report generation
195
- - [ ] Web-based dashboard UI
196
-
197
- <br />
198
-
199
- ---
200
-
201
- <br />
202
-
203
- ## 🔒 Security & Privacy
204
- - **Local Execution:** All scanning logic runs locally on your machine.
205
- - **API Key Safety:** AI provider API keys are stored securely in your local home directory and are never sent to our servers.
206
- - **Data Privacy:** Scan data is sent only to your chosen AI provider for analysis and is not stored by KramScan.
207
-
208
- <br />
209
-
210
- ---
211
-
212
- <br />
213
-
214
- ## 👤 Author
215
- <div align="center">
216
-
217
- **Akram Shaikh**
218
-
219
- [![Website](https://img.shields.io/badge/Website-akramshaikh.me-blue?style=for-the-badge&logo=google-chrome&logoColor=white)](https://akramshaikh.me)
220
- [![GitHub](https://img.shields.io/badge/GitHub-shaikhakramshakil-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/shaikhakramshakil)
221
- [![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/shaikhakramshakil/)
222
-
223
- </div>
224
-
225
- <br />
226
-
227
- ---
228
-
229
- <br />
230
-
231
- ## 📄 License
232
- This project is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
233
-
234
- <div align="center">
235
- <sub>Made with ❤️ by Akram Shaikh</sub>
236
- </div>
1
+ <div align="center">
2
+ <img src="https://github.com/user-attachments/assets/6439c670-8d73-4bdd-b8fa-c74de949a31e" width="500" alt="KramScan Logo" />
3
+
4
+ <h3 align="center">AI-Powered Web Application Security Testing CLI</h3>
5
+
6
+ <br />
7
+
8
+ [![npm version](https://img.shields.io/npm/v/kramscan?style=for-the-badge&logo=npm&logoColor=white&color=cb3837)](https://www.npmjs.com/package/kramscan)
9
+ [![npm downloads](https://img.shields.io/npm/dm/kramscan?style=for-the-badge&logo=npm&logoColor=white&color=blue)](https://www.npmjs.com/package/kramscan)
10
+ [![License](https://img.shields.io/github/license/shaikhakramshakil/kramscan?style=for-the-badge&logo=github&logoColor=white&color=green)](https://github.com/shaikhakramshakil/kramscan/blob/main/LICENSE)
11
+ [![Stars](https://img.shields.io/github/stars/shaikhakramshakil/kramscan?style=for-the-badge&logo=github&logoColor=white&color=yellow)](https://github.com/shaikhakramshakil/kramscan)
12
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.4-3178c6?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org)
13
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18-brightgreen?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org)
14
+
15
+ <br />
16
+
17
+ 🔬 **A next-generation security auditing tool that combines automated vulnerability scanning with multi-provider AI analysis.**
18
+
19
+ *Empowering developers and security researchers with institutional-grade insights, modular plugin architecture, and an interactive AI agent.*
20
+
21
+ <br />
22
+
23
+ [🌐 NPM Package](https://www.npmjs.com/package/kramscan) · [📖 Documentation](#-usage) · [🐞 Report Bug](https://github.com/shaikhakramshakil/kramscan/issues)
24
+
25
+ </div>
26
+
27
+ ---
28
+
29
+ <br />
30
+
31
+ ## 🚀 The Problem We Solve
32
+ Web security is complex and often fragmented. Developers rely on multiple disjointed tools for scanning, manual testing, and reporting. Traditional automated scanners generate noise without context, and manual pentesting is time-consuming and expensive.
33
+
34
+ **KramScan bridges this gap.** We provide a unified command-line interface that orchestrates headless browser scanning, scrapes critical security headers, leverages **Generative AI** (OpenAI, Gemini, Anthropic) for analysis, and features a **modular plugin system** for extensibility. It delivers actionable, human-readable insights alongside raw vulnerability data—all in seconds.
35
+
36
+ <br />
37
+
38
+ ---
39
+
40
+ <br />
41
+
42
+ ## ✨ Key Features
43
+ | Feature | Description |
44
+ | :--- | :--- |
45
+ | 🔍 **Automated Vulnerability Engine** | Detects XSS, SQL Injection, CSRF, insecure headers, CORS misconfigs, open redirects, and more. |
46
+ | 🔌 **10 Built-in Security Plugins** | CORS, debug endpoints, directory traversal, cookie auditing, open redirects, sensitive data, and more. |
47
+ | 🛠️ **Dev Mode (Watch Scanner)** | Watch your localhost for file changes and auto re-scan with diff reports (new vs resolved vulns). |
48
+ | 🚧 **CI/CD Security Gate** | `kramscan gate` exits with code 1 if vulnerabilities exceed your threshold. Plug into any pipeline. |
49
+ | 🤖 **Interactive AI Agent** | A conversational security assistant with **Autonomous Verification** skills to confirm findings live. |
50
+ | 🧠 **Multi-Provider AI Analysis** | Supports OpenAI, Anthropic, Google Gemini, Mistral, OpenRouter, and more for results auditing. |
51
+ | 📝 **AI Executive Summaries** | Automatically generates business-oriented summaries for Word, JSON, and TXT reports. |
52
+ | 📊 **Event-Driven Feedback** | Real-time progress updates with dynamic spinners and live vulnerability alerts during scanning. |
53
+ | 📄 **Professional Reporting** | Generates detailed PDF, DOCX, TXT, and JSON reports with remediation steps and error tracking. |
54
+ | 🌐 **Headless Browser Testing** | Renders modern SPAs (Single Page Applications) to find vulnerabilities in dynamic content. |
55
+ | ⚡ **Smarter User Flow** | Interactive menu and post-scan "Golden Path" prompts for a guided experience. |
56
+ | 🛡️ **Error Resilience** | Robust configuration defaults and graceful recovery if individual URLs or plugins fail. |
57
+
58
+ <br />
59
+
60
+ ---
61
+
62
+ <br />
63
+
64
+ ## 🏗️ Architecture & Workflow
65
+
66
+ ```mermaid
67
+ graph LR
68
+ A[User Command] --> B{CLI Controller};
69
+ B --> C[Scanner Module<br/>Puppeteer / Plugin System];
70
+ B --> D[AI Agent<br/>NLP Processing];
71
+
72
+ C --> E[Plugin Manager<br/>XSS / SQLi / Headers / CSRF];
73
+ E --> F[Vulnerability Detection];
74
+ C --> G[Event System<br/>Progress / Results];
75
+
76
+ F & G --> H[AI Analysis Engine<br/>LLM Provider];
77
+
78
+ H --> I[Risk Assessment<br/>Confidence Scoring];
79
+ I --> J[Report Generator<br/>PDF / DOCX / JSON / TXT];
80
+ J --> K((Final Output<br/>+ Error Report));
81
+ ```
82
+
83
+ <br />
84
+
85
+ ### Plugin Architecture
86
+
87
+ KramScan is built on a modular plugin system that makes extending vulnerability detection effortless:
88
+
89
+ ```
90
+ src/plugins/
91
+ ├── types.ts # Base interfaces and types
92
+ ├── PluginManager.ts # Plugin orchestration
93
+ ├── index.ts # Plugin exports
94
+ └── vulnerabilities/ # Built-in plugins
95
+ ├── XSSPlugin.ts # Cross-Site Scripting
96
+ ├── SQLInjectionPlugin.ts # SQL Injection
97
+ ├── SecurityHeadersPlugin.ts # Missing security headers
98
+ ├── SensitiveDataPlugin.ts # Exposed secrets & API keys
99
+ ├── CSRFPlugin.ts # Cross-Site Request Forgery
100
+ ├── CORSAnalyzerPlugin.ts # CORS misconfiguration
101
+ ├── DebugEndpointPlugin.ts # Exposed debug/dev endpoints
102
+ ├── DirectoryTraversalPlugin.ts # Path traversal / LFI
103
+ ├── CookieSecurityPlugin.ts # Insecure cookie flags
104
+ └── OpenRedirectPlugin.ts # Open redirect detection
105
+ ```
106
+
107
+ **Creating a custom plugin:**
108
+
109
+ ```typescript
110
+ import { BaseVulnerabilityPlugin, PluginContext } from 'kramscan/plugins';
111
+
112
+ export class MyCustomPlugin extends BaseVulnerabilityPlugin {
113
+ readonly name = "Custom Detector";
114
+ readonly type = "custom";
115
+ readonly description = "Detects custom vulnerability";
116
+
117
+ async testParameter(context: PluginContext, param: string, value: string) {
118
+ // Your detection logic here
119
+ if (/* vulnerability found */) {
120
+ return this.success(this.createVulnerability(
121
+ "Custom Vulnerability",
122
+ "Description...",
123
+ context.url,
124
+ "high",
125
+ "Evidence...",
126
+ "Remediation..."
127
+ ));
128
+ }
129
+ return this.failure();
130
+ }
131
+ }
132
+ ```
133
+
134
+ <br />
135
+
136
+ ---
137
+
138
+ <br />
139
+
140
+ ## 🧪 Tech Stack
141
+ <div align="center">
142
+
143
+ | Component | Technology |
144
+ | :--- | :--- |
145
+ | **Runtime** | Node.js ≥ 18 |
146
+ | **Language** | TypeScript 5.4 |
147
+ | **CLI Framework** | Commander.js, Inquirer.js |
148
+ | **Browser Automation** | Puppeteer (Headless Chrome) |
149
+ | **AI Integration** | OpenAI SDK, Google Generative AI, Anthropic SDK |
150
+ | **Schema Validation** | Zod |
151
+ | **Reporting** | Docx, Puppeteer (PDF), Chalk |
152
+ | **Package Manager** | NPM / Yarn / PNPM |
153
+
154
+ </div>
155
+
156
+ <br />
157
+
158
+ ---
159
+
160
+ <br />
161
+
162
+ ## 🧠 Supported AI Providers
163
+
164
+ | Provider | SDK / Integration | Default Model |
165
+ | :--- | :--- | :--- |
166
+ | **OpenAI** | `openai` | `gpt-4` |
167
+ | **Anthropic** | `@anthropic-ai/sdk` | `claude-3-5-sonnet-20241022` |
168
+ | **Google Gemini** | `@google/generative-ai` | `gemini-2.0-flash` |
169
+ | **Mistral** | `@mistralai/mistralai` | `mistral-large-latest` |
170
+ | **OpenRouter** | OpenAI-compatible | `anthropic/claude-3.5-sonnet` |
171
+ | **Kimi** | OpenAI-compatible | `moonshot-v1-8k` |
172
+ | **Groq** | OpenAI-compatible | `llama-3.1-8b-instant` |
173
+
174
+ > Switch providers instantly with `kramscan onboard` or by editing `~/.kramscan/config.json`.
175
+
176
+ ### API Key Environment Variables
177
+ You can provide API keys via environment variables (useful for CI/CD) instead of saving them locally:
178
+
179
+ | Provider | Env Var |
180
+ | :--- | :--- |
181
+ | OpenAI | `OPENAI_API_KEY` |
182
+ | Anthropic | `ANTHROPIC_API_KEY` |
183
+ | Gemini | `GEMINI_API_KEY` |
184
+ | Mistral | `MISTRAL_API_KEY` |
185
+ | OpenRouter | `OPENROUTER_API_KEY` |
186
+ | Kimi | `KIMI_API_KEY` |
187
+ | Groq | `GROQ_API_KEY` |
188
+
189
+ ### Smart Environment Detection
190
+ KramScan automatically detects API keys in your environment variables. During `kramscan onboard`, the tool will identify and pre-configure providers like OpenAI, Anthropic, and Gemini if their keys are found in your session.
191
+
192
+ ### AI-Powered Context-Aware Payloads
193
+ The scanning engine utilizes AI to generate payloads tailored to the specific context of your application, significantly increasing detection rates against filtered inputs and complex WAFs.
194
+
195
+ ### Autonomous Finding Verification
196
+ The `kramscan agent` independently verifies reported vulnerabilities using non-destructive, context-aware payloads to differentiate between theoretical findings and exploitable risks.
197
+
198
+ <br />
199
+
200
+ ---
201
+
202
+ <br />
203
+
204
+ ## 🚀 Quick Start
205
+
206
+ ### 1. Installation
207
+ Install KramScan globally using npm:
208
+
209
+ ```bash
210
+ npm install -g kramscan
211
+ ```
212
+
213
+ ### 2. First-Time Setup
214
+ Initialize the configuration wizard to set up your AI provider and API keys:
215
+
216
+ ```bash
217
+ kramscan onboard
218
+ ```
219
+
220
+ ### 3. Run a Scan
221
+ Execute a full security scan on a target URL:
222
+
223
+ ```bash
224
+ kramscan scan https://example.com
225
+ ```
226
+
227
+ <br />
228
+
229
+ ---
230
+
231
+ <br />
232
+
233
+ ## 📖 Usage & Commands
234
+
235
+ | Command | Description |
236
+ | :--- | :--- |
237
+ | `kramscan` | Launch the interactive dashboard menu with smart argument prompting. |
238
+ | `kramscan scan <url>` | Run a comprehensive vulnerability scan with post-scan prompts. |
239
+ | `kramscan dev [url]` | Watch-mode localhost scanner with diff reports and desktop notifications. |
240
+ | `kramscan gate <url>` | CI/CD security quality gate — exits with code 1 on threshold breach. |
241
+ | `kramscan agent` | Start the AI security assistant with autonomous verification skills. |
242
+ | `kramscan analyze` | AI-powered analysis with proactive onboarding redirection. |
243
+ | `kramscan report` | Generate professional reports with optional AI executive summaries. |
244
+ | `kramscan onboard` | Smart setup wizard with environment key detection. |
245
+ | `kramscan doctor` | Verify environment health and check for Docker dependencies. |
246
+ | `kramscan config` | View and edit current configuration with robust schema defaults. |
247
+ | `kramscan scans` | List and inspect recent scans from the persistent index. |
248
+ | `kramscan ai` | AI helpers (model listing and connectivity test). |
249
+
250
+ <br />
251
+
252
+ ### 🛠️ Dev Mode — Localhost Watch Scanner
253
+
254
+ Scan your local dev server continuously. KramScan watches for file changes and **auto re-scans**, showing a diff of new vs. resolved vulnerabilities:
255
+
256
+ ```bash
257
+ # Watch-mode with port shorthand
258
+ kramscan dev --port 3000
259
+
260
+ # Full URL with notifications
261
+ kramscan dev http://localhost:3000 --watch-dir ./src --notify
262
+
263
+ # Single scan (no watching)
264
+ kramscan dev http://localhost:8080 --no-watch --fail-on high
265
+ ```
266
+
267
+ **How it works:**
268
+ 1. Probes your server until it's ready (auto-detects Express, Next.js, Django, etc.)
269
+ 2. Runs an initial security scan
270
+ 3. Watches `--watch-dir` for file changes (debounced)
271
+ 4. Re-scans and shows only **new** and **resolved** vulnerabilities
272
+
273
+ ### 🚧 CI/CD Security Gate
274
+
275
+ Block deployments with vulnerabilities above your threshold:
276
+
277
+ ```bash
278
+ # Fail if any high+ vulnerabilities found
279
+ kramscan gate http://localhost:3000 --fail-on high
280
+
281
+ # JSON output for pipeline processing
282
+ kramscan gate $APP_URL --fail-on medium --json
283
+
284
+ # Allow up to 3 low-severity findings
285
+ kramscan gate http://staging.example.com --fail-on low --max-vulns 3
286
+ ```
287
+
288
+ **Pipeline example (GitHub Actions):**
289
+ ```yaml
290
+ - name: Security Gate
291
+ run: npx kramscan gate http://localhost:3000 --fail-on high
292
+ ```
293
+
294
+ <br />
295
+
296
+ ### Scan Profiles and Limits
297
+ KramScan supports profiles for quick tuning:
298
+
299
+ ```bash
300
+ kramscan scan https://example.com --profile quick
301
+ kramscan scan https://example.com --profile balanced
302
+ kramscan scan https://example.com --profile deep
303
+ ```
304
+
305
+ You can also control crawl limits and URL scope:
306
+
307
+ ```bash
308
+ kramscan scan https://example.com --max-pages 30 --max-links-per-page 50
309
+ kramscan scan https://example.com --exclude "logout|signout"
310
+ kramscan scan https://example.com --include "^https://example\.com/docs"
311
+ ```
312
+
313
+ ### Automatic PDF Report After Scan
314
+ After each scan, KramScan automatically generates a PDF report (no separate command required).
315
+
316
+ The file is saved to:
317
+
318
+ - JSON: `~/.kramscan/scans/scan-<timestamp>.json`
319
+ - PDF: `~/.kramscan/reports/scanreport_<hostname>_<timestamp>.pdf`
320
+
321
+ You can disable it with:
322
+
323
+ ```bash
324
+ kramscan scan https://example.com --no-pdf
325
+ ```
326
+
327
+ ### Error Tracking and Recovery
328
+ KramScan features comprehensive error handling:
329
+
330
+ - **Continue on Failure**: Scan continues even if individual URLs fail to load
331
+ - **Plugin Error Isolation**: If one vulnerability plugin fails, others continue working
332
+ - **Error Reports**: PDF reports include a "⚠️ Scan Errors & Skipped Items" section
333
+ - **CLI Feedback**: Real-time error messages during scanning
334
+
335
+ ### Event-Driven Progress Feedback
336
+ Watch your scan progress in real-time:
337
+
338
+ ```
339
+ 🔍 Starting Security Scan
340
+ ──────────────────────────────────────────────────
341
+
342
+ ✔ Initializing scanner...
343
+ ⠴ Crawling: https://example.com (5/30)
344
+ ⚠️ Found high vulnerability: Reflected Cross-Site Scripting (XSS)
345
+ ⠴ Continuing scan (1 vulns found)...
346
+ ⠴ Testing forms on https://example.com/login (3 forms)...
347
+ ✔ Scan complete!
348
+ ```
349
+
350
+ ### Scan History
351
+ Every scan is indexed in `~/.kramscan/scans/index.json`.
352
+
353
+ ```bash
354
+ kramscan scans list -n 10
355
+ kramscan scans latest
356
+ ```
357
+
358
+ ### AI Diagnostics
359
+ List models and test your configured provider/model:
360
+
361
+ ```bash
362
+ kramscan ai models -n 10
363
+ kramscan ai test
364
+ ```
365
+
366
+ ### Example Agent Session
367
+ ```bash
368
+ $ kramscan agent
369
+ > scan https://example.com
370
+
371
+ Agent: I'll perform a comprehensive security scan of https://example.com.
372
+ Checking for XSS, SQLi, and missing headers...
373
+ [Scanning...]
374
+
375
+ Agent: Scan complete! Found 2 High severity issues.
376
+ Would you like me to generate a report?
377
+ ```
378
+
379
+ <br />
380
+
381
+ ---
382
+
383
+
384
+
385
+ ## 🔒 Security & Privacy
386
+ - **Local Execution:** All scanning logic runs locally on your machine.
387
+ - **API Key Safety:** AI provider API keys are stored securely in your local home directory and are never sent to our servers.
388
+ - **Data Privacy:** Scan data is sent only to your chosen AI provider for analysis and is not stored by KramScan.
389
+ - **Error Tracking:** Failed scan attempts are logged locally for debugging but never transmitted.
390
+
391
+ <br />
392
+
393
+ ---
394
+
395
+ <br />
396
+
397
+ ## 👤 Author
398
+ <div align="center">
399
+
400
+ **Akram Shaikh**
401
+
402
+ [![Website](https://img.shields.io/badge/Website-akramshaikh.me-blue?style=for-the-badge&logo=google-chrome&logoColor=white)](https://akramshaikh.me)
403
+ [![GitHub](https://img.shields.io/badge/GitHub-shaikhakramshakil-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/shaikhakramshakil)
404
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/shaikhakramshakil/)
405
+
406
+ </div>
407
+
408
+ <br />
409
+
410
+ ---
411
+
412
+ <br />
413
+
414
+ ## 📄 License
415
+ This project is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
416
+
417
+ <div align="center">
418
+ <sub>Made with ❤️ by Akram Shaikh</sub>
419
+ </div>