vibe-guard 1.2.0 → 2.1.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 (49) hide show
  1. package/README.md +38 -74
  2. package/dist/bin/vibe-guard.js +93 -264
  3. package/dist/bin/vibe-guard.js.map +1 -1
  4. package/dist/index.d.ts +4 -9
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +36 -69
  7. package/dist/index.js.map +1 -1
  8. package/dist/reporter.d.ts +4 -11
  9. package/dist/reporter.d.ts.map +1 -1
  10. package/dist/reporter.js +125 -461
  11. package/dist/reporter.js.map +1 -1
  12. package/dist/rules/exposed-secrets.d.ts.map +1 -1
  13. package/dist/rules/exposed-secrets.js +27 -8
  14. package/dist/rules/exposed-secrets.js.map +1 -1
  15. package/dist/rules/hardcoded-sensitive-data.js +1 -1
  16. package/dist/rules/hardcoded-sensitive-data.js.map +1 -1
  17. package/dist/rules/index.d.ts +3 -1
  18. package/dist/rules/index.d.ts.map +1 -1
  19. package/dist/rules/index.js +7 -1
  20. package/dist/rules/index.js.map +1 -1
  21. package/dist/rules/insecure-deserialization.js +1 -1
  22. package/dist/rules/insecure-deserialization.js.map +1 -1
  23. package/dist/rules/insecure-error-handling.js +1 -1
  24. package/dist/rules/insecure-error-handling.js.map +1 -1
  25. package/dist/rules/insecure-file-upload.js +1 -1
  26. package/dist/rules/insecure-file-upload.js.map +1 -1
  27. package/dist/rules/insecure-http.js +1 -1
  28. package/dist/rules/insecure-http.js.map +1 -1
  29. package/dist/rules/insecure-logging.js +1 -1
  30. package/dist/rules/insecure-logging.js.map +1 -1
  31. package/dist/rules/kubernetes-security.js +3 -3
  32. package/dist/rules/kubernetes-security.js.map +1 -1
  33. package/dist/rules/unpinned-supply-chain-dependencies.d.ts +12 -0
  34. package/dist/rules/unpinned-supply-chain-dependencies.d.ts.map +1 -0
  35. package/dist/rules/unpinned-supply-chain-dependencies.js +56 -0
  36. package/dist/rules/unpinned-supply-chain-dependencies.js.map +1 -0
  37. package/dist/rules/unsafe-llm-prompt-construction.d.ts +9 -0
  38. package/dist/rules/unsafe-llm-prompt-construction.d.ts.map +1 -0
  39. package/dist/rules/unsafe-llm-prompt-construction.js +31 -0
  40. package/dist/rules/unsafe-llm-prompt-construction.js.map +1 -0
  41. package/dist/rules/xss-detection.js +1 -1
  42. package/dist/rules/xss-detection.js.map +1 -1
  43. package/dist/scanner.d.ts +1 -2
  44. package/dist/scanner.d.ts.map +1 -1
  45. package/dist/scanner.js +43 -116
  46. package/dist/scanner.js.map +1 -1
  47. package/dist/types/version.d.ts +1 -1
  48. package/dist/types/version.js +1 -1
  49. package/package.json +20 -18
package/README.md CHANGED
@@ -1,45 +1,43 @@
1
1
  # ██ Vibe-Guard Security Scanner
2
2
 
3
- **Professional Security Scanner** - Zero dependencies, instant setup, works everywhere. Optimized performance for security scanning. Current ruleset: 28 essential security rules including container security.
3
+ Vibe-Guard gives you a quick security pass over source code and configuration files, with 30 pattern-based rules covering common application, AI, dependency, and container risks. Findings include a suggested next step, so scans can also help you learn what to look for.
4
+
5
+ It is a heuristic scanner, not a substitute for code review or a full security audit. It requires Node.js 20 or newer; npm installs its declared third-party runtime dependencies for you.
4
6
 
5
7
  [![npm version](https://img.shields.io/npm/v/vibe-guard.svg)](https://www.npmjs.com/package/vibe-guard)
6
8
  [![Downloads (total)](https://img.shields.io/npm/dt/vibe-guard.svg)](https://www.npmjs.com/package/vibe-guard)
7
9
  [![License](https://img.shields.io/npm/l/vibe-guard.svg)](https://github.com/Devjosef/vibe-guard/blob/main/LICENSE)
8
10
 
11
+
9
12
  ## Quick Start
10
13
 
11
14
  ```bash
12
15
  # Install globally
13
16
  npm install -g vibe-guard
14
17
 
15
- # Start interactive session
18
+ # Interactive menu (scan and view rules)
16
19
  vibe-guard start
17
20
 
18
21
  # Scan your project
19
22
  vibe-guard scan .
20
23
 
21
- # Learn about security concepts
22
- vibe-guard learn xss-detection
23
-
24
- # Try with demo files
25
- vibe-guard demo
24
+ # Export a SARIF report
25
+ vibe-guard scan . --format sarif --output-file security-report.sarif
26
26
  ```
27
27
 
28
- ## Interactive Security Learning
28
+ `vibe-guard scan` requires a target path. Supported formats are `table`, `json`, `sarif`, and `html`. A scan with findings exits with code 1; scan errors exit with code 2. The interactive `start` menu lets you scan, view the rule list, and create or view a configuration file. There are no separate `learn`, `demo`, or `stats` commands.
29
29
 
30
- Vibe-Guard is more than a scanner—it's an educational platform that teaches you about web security through hands-on experience:
31
-
32
- ### Understanding Vulnerabilities
30
+ ## Common issues and safer patterns
33
31
 
34
32
  **XSS (Cross-Site Scripting):**
35
33
  ```javascript
36
- // ❌ Vulnerable code
34
+ // Vulnerable code
37
35
  app.get('/user', (req, res) => {
38
36
  const userInput = req.query.name;
39
37
  res.send('<h1>Hello ' + userInput + '</h1>'); // XSS vulnerability!
40
38
  });
41
39
 
42
- // ✅ Secure code
40
+ // Secure code
43
41
  app.get('/user', (req, res) => {
44
42
  const userInput = req.query.name;
45
43
  res.send('<h1>Hello ' + escapeHtml(userInput) + '</h1>');
@@ -48,26 +46,26 @@ app.get('/user', (req, res) => {
48
46
 
49
47
  **SQL Injection:**
50
48
  ```javascript
51
- // ❌ Vulnerable code
49
+ // Vulnerable code
52
50
  const query = 'SELECT * FROM users WHERE id = ' + userId; // SQL injection risk!
53
51
 
54
- // ✅ Secure code
52
+ // Secure code
55
53
  const query = 'SELECT * FROM users WHERE id = ?';
56
54
  db.query(query, [userId]);
57
55
  ```
58
56
 
59
57
  **Exposed Secrets:**
60
58
  ```javascript
61
- // ❌ Vulnerable code
59
+ // Vulnerable code
62
60
  const API_KEY = 'sk-1234567890abcdef'; // Secret exposed in source code!
63
61
 
64
- // ✅ Secure code
62
+ // Secure code
65
63
  const API_KEY = process.env.API_KEY; // Environment variable
66
64
  ```
67
65
 
68
66
  **Container Security:**
69
67
  ```yaml
70
- # ❌ Vulnerable Kubernetes manifest
68
+ # Vulnerable Kubernetes manifest
71
69
  apiVersion: apps/v1
72
70
  kind: Deployment
73
71
  spec:
@@ -80,7 +78,7 @@ spec:
80
78
  runAsUser: 0 # Root user vulnerability
81
79
  privileged: true # Privileged container vulnerability
82
80
 
83
- # ✅ Secure Kubernetes manifest
81
+ # Secure Kubernetes manifest
84
82
  apiVersion: apps/v1
85
83
  kind: Deployment
86
84
  spec:
@@ -88,7 +86,7 @@ spec:
88
86
  spec:
89
87
  containers:
90
88
  - name: app
91
- image: nginx:1.21.6@sha256:abc123... # Pinned digest
89
+ image: nginx:1.21.6@sha256:<real-image-digest> # Replace with the registry's actual digest
92
90
  securityContext:
93
91
  runAsUser: 1000 # Non-root user
94
92
  runAsNonRoot: true
@@ -102,21 +100,22 @@ spec:
102
100
  3. **Parameterized Queries** - Use prepared statements for database operations
103
101
  4. **Environment Variables** - Never hardcode secrets in source code
104
102
  5. **Security Headers** - Implement proper HTTP security headers
103
+
105
104
  6. **Container Security** - Use non-root users, pinned image digests, and proper security contexts
106
105
 
107
106
  ## Comprehensive Security Coverage
108
107
 
109
- Vibe-Guard detects 28 types of vulnerabilities across multiple categories:
108
+ Vibe-Guard detects 30 types of vulnerabilities across multiple categories:
110
109
 
111
110
  - **Authentication & Authorization**: Missing authentication, broken access control, session management
112
111
  - **Input Validation**: SQL injection, XSS, unvalidated input, directory traversal
113
112
  - **Data Protection**: Exposed secrets, hardcoded sensitive data, insecure logging
114
113
  - **Configuration**: Insecure configuration, missing security headers, CORS issues
115
- - **Modern Threats**: CSRF protection, AI-generated code validation, prompt injection
116
- - **Dependencies**: Insecure dependencies, outdated packages, vulnerability assessment
114
+ - **Modern Threats**: AI provider tokens, unsafe LLM prompt construction, prompt injection, MCP security
115
+ - **Dependencies**: Known vulnerable packages, floating versions, and mutable Git references
117
116
  - **Container Security**: Kubernetes security, Dockerfile vulnerabilities, container registry issues
118
117
 
119
- ## Professional Use Cases
118
+ ## Use it in your workflow
120
119
 
121
120
  **CI/CD Integration:**
122
121
  ```yaml
@@ -125,6 +124,10 @@ Vibe-Guard detects 28 types of vulnerabilities across multiple categories:
125
124
  run: vibe-guard scan . --format sarif --output-file security-report.sarif
126
125
  ```
127
126
 
127
+ ## SARIF test reporting
128
+
129
+ For local Jest test-result reporting, see [TEST_SCANNING.md](docs/TEST_SCANNING.md); that utility is separate from scanning project code.
130
+
128
131
  **Pre-commit Hook:**
129
132
  ```bash
130
133
  # .git/hooks/pre-commit
@@ -132,17 +135,9 @@ Vibe-Guard detects 28 types of vulnerabilities across multiple categories:
132
135
  vibe-guard scan . || exit 1
133
136
  ```
134
137
 
135
- **Interactive Learning:**
138
+ **Interactive menu:**
136
139
  ```bash
137
- # Start interactive session
138
140
  vibe-guard start
139
-
140
- # Learn specific security concepts
141
- vibe-guard learn sql-injection
142
- vibe-guard learn xss-detection
143
-
144
- # Practice with demo files
145
- vibe-guard demo
146
141
  ```
147
142
 
148
143
  ## Installation Options
@@ -157,62 +152,31 @@ npm install -g vibe-guard
157
152
  brew install devjosef/tap/vibe-guard
158
153
  ```
159
154
 
160
- **Direct Download:**
161
- ```bash
162
- # Linux
163
- curl -L https://github.com/Devjosef/vibe-guard/releases/latest/download/vibe-guard-linux-x64 -o vibe-guard
164
- chmod +x vibe-guard
165
-
166
- # macOS
167
- curl -L https://github.com/Devjosef/vibe-guard/releases/latest/download/vibe-guard-macos-x64 -o vibe-guard
168
- chmod +x vibe-guard
169
-
170
- # Windows
171
- curl -L https://github.com/Devjosef/vibe-guard/releases/latest/download/vibe-guard-windows-x64.exe -o vibe-guard.exe
172
- ```
155
+ Standalone binaries for Linux x64/arm64, macOS x64/arm64, and Windows x64 are built in CI and uploaded as workflow artifacts. They are not currently published as GitHub release downloads.
173
156
 
174
157
  ## Documentation & Resources
175
158
 
176
159
  - **[Getting Started](https://devjosef.github.io/vibe-guard/getting-started.html)** - Complete setup and configuration guide
177
- - **[Security Rules](https://devjosef.github.io/vibe-guard/rules.html)** - Detailed rule explanations and examples
160
+ - **[Security Rules](https://devjosef.github.io/vibe-guard/features.html)** - Rule coverage and descriptions
178
161
  - **[Performance Guide](https://devjosef.github.io/vibe-guard/performance.html)** - Optimization and best practices
179
162
  - **[API Reference](https://devjosef.github.io/vibe-guard/docs.html)** - Programmatic usage and integration
180
163
 
181
164
  ## Community & Support
182
165
 
183
- **Join our community of security professionals and developers:**
166
+ **Questions, feedback, or a finding that looks wrong?**
184
167
 
185
- - **Interactive Learning**: `vibe-guard start` - Begin your security journey
186
- - **Educational Commands**: `vibe-guard learn [topic]` - Master security concepts
187
- - **Hands-on Practice**: `vibe-guard demo` - Test with example vulnerabilities
188
- - **Performance Insights**: `vibe-guard stats` - Track your security impact
168
+ - **Interactive menu**: `vibe-guard start` - Scan or view available rules
169
+ - **SARIF export**: `vibe-guard scan . --format sarif --output-file report.sarif`
189
170
  - **Community Discussion**: [GitHub Discussions](https://github.com/Devjosef/vibe-guard/discussions)
190
171
  - **Issue Reporting**: [GitHub Issues](https://github.com/Devjosef/vibe-guard/issues)
191
172
  - **Repository**: [GitHub Repository](https://github.com/Devjosef/vibe-guard)
192
173
 
193
- ## Why Choose Vibe-Guard?
194
-
195
- **Built for developers who code fast and need security that keeps up:**
196
-
197
- - **Zero Dependencies** - Lightweight, fast, and reliable
198
- - **28 Security Rules** - Comprehensive coverage of modern threats including container security
199
- - **Cross-Platform** - Works seamlessly across all operating systems
200
- - **Educational Focus** - Learn security while you scan
201
- - **OWASP Aligned** - Industry best practices and standards
202
- - **Developer-Friendly** - Simple, intuitive CLI interface
203
- - **Interactive Mode** - Guided learning with `vibe-guard start`
204
- - **Container Security** - Kubernetes, Dockerfile, and registry security scanning
205
-
206
- ## Impact & Adoption
207
-
208
- Every scan contributes to a more secure web ecosystem:
174
+ ## What to expect
209
175
 
210
- - **500+ total downloads** on NPM with growing adoption
211
- - **28 security rules** covering contemporary threat vectors including container security
212
- - **Cross-platform support** for Linux, macOS, and Windows
213
- - **Zero dependencies** ensuring maximum compatibility
214
- - **Educational approach** - building security awareness
215
- - **Container security** - Kubernetes, Dockerfile, and registry vulnerability detection
176
+ - Findings include the rule, severity, file and line, explanation, and suggested remediation.
177
+ - Pattern-based checks can miss issues or flag safe code; review findings in context and do not treat a clean scan as proof that code is secure.
178
+ - `start` is a small interactive menu for scanning and browsing rule descriptions, not a guided course.
179
+ - CI runs the Jest suite on Node.js 20 and 22. Binary builds are CI artifacts until attached to a release.
216
180
 
217
181
  ## License
218
182
 
@@ -41,10 +41,11 @@ const commander_1 = require("commander");
41
41
  const chalk_1 = __importDefault(require("chalk"));
42
42
  const index_1 = __importDefault(require("../index"));
43
43
  const version_1 = require("../types/version");
44
+ const fs = __importStar(require("fs"));
45
+ const readline = __importStar(require("readline"));
44
46
  const program = new commander_1.Command();
45
47
  // ASCII Art Logo
46
48
  function displayLogo() {
47
- // Professional blue gradient effect
48
49
  const logo = [
49
50
  '██╗ ██╗██╗██████╗ ███████╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ██████╗ ',
50
51
  '╚██╗ ██╔╝██║██╔══██╗██╔════╝ ██╔════╝ ██║ ██║██╔══██╗██╔══██╗██╔══██╗',
@@ -53,7 +54,6 @@ function displayLogo() {
53
54
  ' ██║ ██║██████╔╝███████╗ ╚██████╔╝╚██████╔╝██║ ██║██║ ██║██████╔╝',
54
55
  ' ╚═╝ ╚═╝╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ '
55
56
  ];
56
- // Subtle gradient from dark blue to lighter blue
57
57
  logo.forEach((line, index) => {
58
58
  let color;
59
59
  switch (index) {
@@ -79,294 +79,123 @@ function displayLogo() {
79
79
  }
80
80
  console.log(color.bold(line));
81
81
  });
82
- // Clean subtitle with subtle accent
83
82
  console.log(chalk_1.default.blue.bold(' ██ SECURITY SCANNER ██\n'));
84
83
  }
85
- program
86
- .name('vibe-guard')
87
- .description('██ Vibe-Guard Security Scanner - Catch security issues before they catch you!')
88
- .version(version_1.VERSION)
89
- .hook('preAction', () => {
90
- displayLogo();
91
- });
92
- const fs = __importStar(require("fs"));
84
+ /**
85
+ * Run a scan and return an exit code instead of terminating the process.
86
+ * Returns: 0 = success (no issues), 1 = issues found, 2 = error/invalid args
87
+ */
93
88
  async function handleScan(target, options) {
94
89
  try {
95
- console.log(chalk_1.default.blue.bold('╔══════════════════════════════════════════════════════════════════════════════╗'));
96
- console.log(chalk_1.default.blue.bold('║ STARTING VIBE-GUARD SECURITY SCAN ║'));
97
- console.log(chalk_1.default.blue.bold('║ THREAT DETECTION ACTIVE ║'));
98
- console.log(chalk_1.default.blue.bold('╚══════════════════════════════════════════════════════════════════════════════╝\n'));
99
- // Validate severity level if provided
100
- if (options.severity && !['critical', 'high', 'medium', 'low'].includes(options.severity)) {
101
- console.error(chalk_1.default.red.bold('❌ Error: Invalid severity level. Must be one of: critical, high, medium, low'));
102
- process.exit(1);
103
- }
104
90
  const scanOptions = {
105
91
  target,
106
- format: options.format,
107
- verbose: options.verbose,
108
- exclude: options.exclude,
109
- include: options.include
92
+ format: options.format ?? 'table',
93
+ verbose: false
110
94
  };
111
- // Add optional properties only when they have values
112
- if (options.severity)
113
- scanOptions.severity = options.severity;
114
- if (options.config)
115
- scanOptions.config = options.config;
116
- if (options.parallel)
117
- scanOptions.parallel = options.parallel;
118
- if (options.maxFiles)
119
- scanOptions.maxFiles = parseInt(options.maxFiles);
120
95
  const vibeGuard = new index_1.default();
121
- const output = await vibeGuard.scanAndFormat(scanOptions);
96
+ const result = await vibeGuard.scan(scanOptions);
97
+ const output = vibeGuard.formatResults(result, scanOptions.format);
122
98
  if (options.outputFile) {
123
99
  fs.writeFileSync(options.outputFile, output);
124
- console.log(chalk_1.default.green(`✅ Results written to: ${options.outputFile}`));
100
+ console.error(chalk_1.default.green(`Results written to: ${options.outputFile}`));
125
101
  }
126
102
  else {
127
103
  console.log(output);
128
104
  }
129
- const result = await vibeGuard.scan(scanOptions);
130
105
  if (result.issuesFound > 0) {
131
- process.exit(1);
106
+ return 1;
132
107
  }
108
+ return 0;
133
109
  }
134
110
  catch (error) {
135
- console.error(chalk_1.default.red.bold('❌ Error:'), error instanceof Error ? error.message : 'Unknown error');
136
- process.exit(1);
111
+ console.error(chalk_1.default.red.bold('Error:'), error instanceof Error ? error.message : 'Unknown error');
112
+ return 2;
137
113
  }
138
114
  }
139
115
  program
140
- .command('scan')
141
- .description('Scan files or directories for security issues')
142
- .argument('<target>', 'File or directory to scan')
143
- .option('-f, --format <format>', 'Output format (table, json, sarif, html)')
144
- .option('-o, --output-file <file>', 'Write output to file')
145
- .option('-v, --verbose', 'Verbose output', false)
146
- .option('-s, --severity <level>', 'Minimum severity level (critical, high, medium, low)')
147
- .option('-c, --config <file>', 'Path to configuration file')
148
- .option('--parallel', 'Enable parallel processing for better performance')
149
- .option('--max-files <number>', 'Maximum files to process concurrently')
150
- .option('--exclude <patterns...>', 'Exclude patterns')
151
- .option('--include <patterns...>', 'Include patterns')
152
- .action(handleScan);
153
- program
154
- .command('rules')
155
- .description('List all available security rules')
156
- .action(() => {
157
- const vibeGuard = new index_1.default();
158
- const rules = vibeGuard.getRules();
159
- console.log(chalk_1.default.blue.bold('╔══════════════════════════════════════════════════════════════════════════════╗'));
160
- console.log(chalk_1.default.blue.bold('║ AVAILABLE SECURITY RULES ║'));
161
- console.log(chalk_1.default.blue.bold('║ THREAT DETECTION MATRIX ║'));
162
- console.log(chalk_1.default.blue.bold('╚══════════════════════════════════════════════════════════════════════════════╝\n'));
163
- rules.forEach(rule => {
164
- const severityColor = rule.severity === 'critical' ? chalk_1.default.red.bold :
165
- rule.severity === 'high' ? chalk_1.default.red :
166
- rule.severity === 'medium' ? chalk_1.default.yellow :
167
- chalk_1.default.blue;
168
- console.log(`${chalk_1.default.bold(rule.name)} ${severityColor(`[${rule.severity.toUpperCase()}]`)}`);
169
- console.log(` ${chalk_1.default.gray(rule.description)}\n`);
170
- });
171
- });
172
- program
173
- .command('version')
174
- .description('Show version information')
175
- .action(() => {
176
- console.log(chalk_1.default.blue.bold('╔══════════════════════════════════════════════════════════════════════════════╗'));
177
- console.log(chalk_1.default.blue.bold('║ VIBE-GUARD SECURITY SCANNER ║'));
178
- console.log(chalk_1.default.blue.bold('║ THREAT DETECTION ENGINE ║'));
179
- console.log(chalk_1.default.blue.bold('╚══════════════════════════════════════════════════════════════════════════════╝'));
180
- const vibeGuard = new index_1.default();
181
- console.log(chalk_1.default.blue.bold(`\nVERSION: ${vibeGuard.getVersion()}`));
182
- console.log(chalk_1.default.gray('Built for developers who code fast and need security that keeps up! 🚀'));
183
- console.log(chalk_1.default.gray('TypeScript-powered, zero-dependency security scanning'));
184
- });
185
- program
186
- .command('init')
187
- .description('Create a default vibe-guard.json configuration file')
188
- .action(() => {
189
- const vibeGuard = new index_1.default();
190
- vibeGuard.createConfigFile();
191
- });
116
+ .name('vibe-guard')
117
+ .description('██ Vibe-Guard Security Scanner - Catch security issues before they catch you!')
118
+ .version(version_1.VERSION);
192
119
  program
193
120
  .command('start')
194
121
  .description('Start interactive Vibe-Guard session')
195
- .action(async () => {
196
- console.log(chalk_1.default.blue.bold('╔══════════════════════════════════════════════════════════════════════════════╗'));
197
- console.log(chalk_1.default.blue.bold('║ WELCOME TO VIBE-GUARD INTERACTIVE ║'));
198
- console.log(chalk_1.default.blue.bold('║ INTERACTIVE SECURITY SCANNING ║'));
199
- console.log(chalk_1.default.blue.bold('╚══════════════════════════════════════════════════════════════════════════════╝\n'));
200
- console.log(chalk_1.default.cyan.bold('Choose an option:\n'));
201
- console.log(chalk_1.default.white('1. 🔍 Scan a file or directory'));
202
- console.log(chalk_1.default.white('2. 📋 View all security rules'));
203
- console.log(chalk_1.default.white('3. ⚙️ Create configuration file'));
204
- console.log(chalk_1.default.white('4. 📊 Show sample configuration'));
205
- console.log(chalk_1.default.white('5. ℹ️ About Vibe-Guard'));
206
- console.log(chalk_1.default.white('6. 🚪 Exit\n'));
207
- // For now, just show the menu and exit
208
- // In a full implementation, you'd use a library like 'inquirer' for interactive prompts
209
- console.log(chalk_1.default.yellow('💡 Tip: Use specific commands for direct access:'));
210
- console.log(chalk_1.default.gray(' vibe-guard scan <target> - Scan files/directories'));
211
- console.log(chalk_1.default.gray(' vibe-guard rules - View security rules'));
212
- console.log(chalk_1.default.gray(' vibe-guard init - Create config file'));
213
- console.log(chalk_1.default.gray(' vibe-guard config - Show sample config'));
214
- console.log(chalk_1.default.gray(' vibe-guard version - Show version info\n'));
215
- console.log(chalk_1.default.blue.bold('╔══════════════════════════════════════════════════════════════════════════════╗'));
216
- console.log(chalk_1.default.blue.bold('║ THANK YOU FOR USING VIBE-GUARD ║'));
217
- console.log(chalk_1.default.blue.bold('║ STAY SECURE! 🚀 ║'));
218
- console.log(chalk_1.default.blue.bold('╚══════════════════════════════════════════════════════════════════════════════╝'));
219
- });
220
- program
221
- .command('config')
222
- .description('Show sample configuration')
223
122
  .action(() => {
224
- const vibeGuard = new index_1.default();
225
- console.log(chalk_1.default.blue.bold('📝 Sample vibe-guard.json Configuration:\n'));
226
- console.log(vibeGuard.generateConfig());
227
- });
228
- program
229
- .command('learn')
230
- .description('Learn about security concepts and vulnerabilities')
231
- .argument('[topic]', 'Security topic to learn about (xss, sql-injection, csrf, etc.)')
232
- .action((topic) => {
233
- const vibeGuard = new index_1.default();
234
- if (topic) {
235
- const rule = vibeGuard.getRuleByName(topic);
236
- if (rule) {
237
- console.log(chalk_1.default.blue.bold(`📚 Learning about: ${rule.name}\n`));
238
- console.log(chalk_1.default.white(rule.description));
239
- console.log(chalk_1.default.yellow(`\nSeverity: ${rule.severity.toUpperCase()}`));
240
- console.log(chalk_1.default.gray(`\nThis rule helps detect ${rule.name.toLowerCase()} vulnerabilities.`));
241
- }
242
- else {
243
- console.log(chalk_1.default.red(`❌ Unknown topic: ${topic}`));
244
- console.log(chalk_1.default.gray('Use "vibe-guard rules" to see available topics.'));
245
- }
246
- }
247
- else {
248
- console.log(chalk_1.default.blue.bold('📚 Vibe-Guard Security Learning Center\n'));
249
- console.log(chalk_1.default.white('Learn about security vulnerabilities and how to prevent them.\n'));
250
- console.log(chalk_1.default.yellow('Available topics:'));
251
- const rules = vibeGuard.getRules();
252
- rules.forEach(rule => {
253
- console.log(` • ${rule.name.toLowerCase().replace(/-/g, ' ')}`);
254
- });
255
- console.log(chalk_1.default.gray('\nExample: vibe-guard learn xss-detection'));
256
- }
257
- });
258
- program
259
- .command('demo')
260
- .description('Run security scan on demo files to see how it works')
261
- .action(async () => {
262
- console.log(chalk_1.default.blue.bold('🎯 Vibe-Guard Security Demo\n'));
263
- console.log(chalk_1.default.white('Creating demo files with security vulnerabilities...\n'));
264
- const demoDir = './vibe-guard-demo';
265
- if (!fs.existsSync(demoDir)) {
266
- fs.mkdirSync(demoDir);
267
- }
268
- const xssDemo = `${demoDir}/vulnerable-app.js`;
269
- fs.writeFileSync(xssDemo, `
270
- // Demo file with XSS vulnerability
271
- app.get('/user', (req, res) => {
272
- const userInput = req.query.name;
273
- res.send('<h1>Hello ' + userInput + '</h1>'); // XSS vulnerability
274
- });
275
-
276
- // SQL Injection demo
277
- app.get('/users', (req, res) => {
278
- const id = req.query.id;
279
- const query = 'SELECT * FROM users WHERE id = ' + id; // SQL injection
280
- db.query(query);
281
- });
282
-
283
- // Hardcoded secrets
284
- const API_KEY = 'sk-1234567890abcdef'; // Exposed secret
285
- const PASSWORD = 'admin123'; // Hardcoded password
286
- `);
287
- console.log(chalk_1.default.green('✅ Created demo files with security vulnerabilities'));
288
- console.log(chalk_1.default.gray(`Location: ${demoDir}`));
289
- console.log(chalk_1.default.white('\nRunning security scan...\n'));
290
- try {
291
- const vibeGuard = new index_1.default();
292
- const output = await vibeGuard.scanAndFormat({
293
- target: demoDir,
294
- format: 'table',
295
- verbose: true
123
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
124
+ const menu = `\nChoose an option:\n1. Scan a file or directory\n2. View all security rules\n3. Create configuration file\n4. Show sample configuration\n5. About Vibe-Guard\n6. Exit\n\nPlease enter your choice (1-6): `;
125
+ displayLogo();
126
+ const pause = (next) => rl.question(chalk_1.default.gray('\nPress Enter to continue...'), () => next());
127
+ const showMenu = () => {
128
+ rl.question(menu, (answer) => {
129
+ const choice = answer.trim();
130
+ switch (choice) {
131
+ case '1': {
132
+ rl.question('Enter file or directory to scan (default: .): ', (target) => {
133
+ Promise.resolve(handleScan(target || '.', {}))
134
+ .catch(err => console.error(chalk_1.default.red('Scan error:'), err))
135
+ .finally(() => pause(() => showMenu()));
136
+ });
137
+ break;
138
+ }
139
+ case '2': {
140
+ const vibeGuard = new index_1.default();
141
+ const rules = vibeGuard.getRules();
142
+ console.log(chalk_1.default.blue.bold('\nAvailable Security Rules:\n'));
143
+ rules.forEach(rule => {
144
+ const severityColor = rule.severity === 'critical' ? chalk_1.default.red.bold :
145
+ rule.severity === 'high' ? chalk_1.default.red :
146
+ rule.severity === 'medium' ? chalk_1.default.yellow :
147
+ chalk_1.default.blue;
148
+ console.log(`${chalk_1.default.bold(rule.name)} ${severityColor(`[${rule.severity.toUpperCase()}]`)}`);
149
+ console.log(` ${chalk_1.default.gray(rule.description)}\n`);
150
+ });
151
+ pause(() => showMenu());
152
+ break;
153
+ }
154
+ case '3': {
155
+ const vibeGuard = new index_1.default();
156
+ vibeGuard.createConfigFile();
157
+ pause(() => showMenu());
158
+ break;
159
+ }
160
+ case '4': {
161
+ const vibeGuard = new index_1.default();
162
+ console.log(chalk_1.default.blue.bold('\nSample vibe-guard.json Configuration:\n'));
163
+ console.log(vibeGuard.generateConfig());
164
+ pause(() => showMenu());
165
+ break;
166
+ }
167
+ case '5': {
168
+ console.log(chalk_1.default.white('\nVibe-Guard Security Scanner - Designed for fast and secure development with AI-powered scanning.\n'));
169
+ pause(() => showMenu());
170
+ break;
171
+ }
172
+ case '6': {
173
+ console.log(chalk_1.default.green('\nExiting Vibe-Guard. Stay secure!'));
174
+ rl.close();
175
+ break;
176
+ }
177
+ default: {
178
+ console.log(chalk_1.default.red('\nInvalid choice. Please select 1-6.'));
179
+ showMenu();
180
+ }
181
+ }
296
182
  });
297
- console.log(output);
298
- console.log(chalk_1.default.blue('\n🎓 What you learned:'));
299
- console.log(chalk_1.default.white('• XSS vulnerabilities in user input'));
300
- console.log(chalk_1.default.white('• SQL injection in database queries'));
301
- console.log(chalk_1.default.white('• Exposed secrets and hardcoded credentials'));
302
- console.log(chalk_1.default.gray('\nClean up: rm -rf vibe-guard-demo'));
303
- }
304
- catch (error) {
305
- console.error(chalk_1.default.red('Error running demo:', error));
306
- }
307
- });
308
- program
309
- .command('community')
310
- .description('Join the Vibe-Guard community and contribute')
311
- .action(() => {
312
- console.log(chalk_1.default.blue.bold('🤝 Vibe-Guard Community\n'));
313
- console.log(chalk_1.default.white('Join us in making the web more secure!\n'));
314
- console.log(chalk_1.default.yellow('📚 Learn:'));
315
- console.log(chalk_1.default.white(' • vibe-guard learn [topic] - Learn about security concepts'));
316
- console.log(chalk_1.default.white(' • vibe-guard demo - Try the tool with demo files\n'));
317
- console.log(chalk_1.default.yellow('🔧 Contribute:'));
318
- console.log(chalk_1.default.white(' • GitHub: https://github.com/Devjosef/vibe-guard'));
319
- console.log(chalk_1.default.white(' • Issues: https://github.com/Devjosef/vibe-guard/issues'));
320
- console.log(chalk_1.default.white(' • Discussions: https://github.com/Devjosef/vibe-guard/discussions\n'));
321
- console.log(chalk_1.default.yellow('📖 Resources:'));
322
- console.log(chalk_1.default.white(' • Documentation: https://devjosef.github.io/vibe-guard/'));
323
- console.log(chalk_1.default.white(' • Security Rules: vibe-guard rules'));
324
- console.log(chalk_1.default.white(' • Examples: vibe-guard demo\n'));
325
- console.log(chalk_1.default.gray('Built for developers who code fast and need security that keeps up!'));
326
- });
327
- program
328
- .command('stats')
329
- .description('Show Vibe-Guard usage statistics and impact')
330
- .action(() => {
331
- console.log(chalk_1.default.blue.bold('📊 Vibe-Guard Impact Statistics\n'));
332
- console.log(chalk_1.default.white('Your security scanning impact:\n'));
333
- console.log(chalk_1.default.yellow('██ Security Rules: 25'));
334
- console.log(chalk_1.default.white(' • Covers OWASP Top 10'));
335
- console.log(chalk_1.default.white(' • Modern web vulnerabilities'));
336
- console.log(chalk_1.default.white(' • AI/ML security concerns\n'));
337
- console.log(chalk_1.default.yellow('🌍 Global Reach:'));
338
- console.log(chalk_1.default.white(' • Cross-platform (Linux, macOS, Windows)'));
339
- console.log(chalk_1.default.white(' • Multiple package managers'));
340
- console.log(chalk_1.default.white(' • Zero dependencies\n'));
341
- console.log(chalk_1.default.yellow('🎯 Use Cases:'));
342
- console.log(chalk_1.default.white(' • CI/CD security scanning'));
343
- console.log(chalk_1.default.white(' • Pre-commit hooks'));
344
- console.log(chalk_1.default.white(' • Security audits'));
345
- console.log(chalk_1.default.white(' • Educational tool\n'));
346
- console.log(chalk_1.default.gray('Every scan makes the web a little more secure! 🚀'));
347
- });
348
- process.on('unhandledRejection', (reason, promise) => {
349
- console.error(chalk_1.default.red.bold('❌ Unhandled Rejection at:'), promise, chalk_1.default.red('reason:'), reason);
350
- process.exit(1);
351
- });
352
- process.on('uncaughtException', (error) => {
353
- console.error(chalk_1.default.red.bold('❌ Uncaught Exception:'), error);
354
- process.exit(1);
183
+ };
184
+ showMenu();
185
+ rl.on('close', () => {
186
+ process.exit(0);
187
+ });
355
188
  });
356
189
  program
357
- .argument('[target]', 'File or directory to scan')
358
- .option('-f, --format <format>', 'Output format (table, json, sarif, html)')
359
- .option('-o, --output-file <file>', 'Write output to file')
360
- .option('-v, --verbose', 'Verbose output', false)
361
- .option('--exclude <patterns...>', 'Exclude patterns')
362
- .option('--include <patterns...>', 'Include patterns')
363
- .action((target, options) => {
364
- if (target) {
365
- handleScan(target, options);
366
- }
367
- else {
368
- program.help();
369
- }
370
- });
371
- program.parse();
190
+ .command('scan')
191
+ .description('Scan files or directories for security issues')
192
+ .argument('<target>', 'File or directory to scan')
193
+ .addOption(new commander_1.Option('-f, --format <format>', 'Output format')
194
+ .choices(['table', 'json', 'sarif', 'html'])
195
+ .default('table'))
196
+ .option('-o, --output-file <file>', 'Write output to a file')
197
+ .action(async (target, options) => {
198
+ process.exitCode = await handleScan(target, options);
199
+ });
200
+ void program.parseAsync(process.argv);
372
201
  //# sourceMappingURL=vibe-guard.js.map