vibe-guard 1.1.5 → 1.2.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.
package/README.md CHANGED
@@ -1,17 +1,20 @@
1
1
  # ██ Vibe-Guard Security Scanner
2
2
 
3
- **Security Scanner** - Zero dependencies, instant setup, works everywhere. Optimized performance for security scanning. Current ruleset: 25 essential security rules.
3
+ **Professional Security Scanner** - Zero dependencies, instant setup, works everywhere. Optimized performance for security scanning. Current ruleset: 28 essential security rules including container security.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/vibe-guard.svg)](https://www.npmjs.com/package/vibe-guard)
6
6
  [![Downloads (total)](https://img.shields.io/npm/dt/vibe-guard.svg)](https://www.npmjs.com/package/vibe-guard)
7
7
  [![License](https://img.shields.io/npm/l/vibe-guard.svg)](https://github.com/Devjosef/vibe-guard/blob/main/LICENSE)
8
8
 
9
- ## 🚀 Quick Start
9
+ ## Quick Start
10
10
 
11
11
  ```bash
12
12
  # Install globally
13
13
  npm install -g vibe-guard
14
14
 
15
+ # Start interactive session
16
+ vibe-guard start
17
+
15
18
  # Scan your project
16
19
  vibe-guard scan .
17
20
 
@@ -22,18 +25,18 @@ vibe-guard learn xss-detection
22
25
  vibe-guard demo
23
26
  ```
24
27
 
25
- ## Learning Security
28
+ ## Interactive Security Learning
26
29
 
27
- Vibe-Guard is more than a scanner, it's an educational tool that teaches you about web security:
30
+ Vibe-Guard is more than a scanner—it's an educational platform that teaches you about web security through hands-on experience:
28
31
 
29
- ### **Understanding Vulnerabilities**
32
+ ### Understanding Vulnerabilities
30
33
 
31
34
  **XSS (Cross-Site Scripting):**
32
35
  ```javascript
33
36
  // ❌ Vulnerable code
34
37
  app.get('/user', (req, res) => {
35
38
  const userInput = req.query.name;
36
- res.send('<h1>Hello ' + userInput + '</h1>'); // XSS!
39
+ res.send('<h1>Hello ' + userInput + '</h1>'); // XSS vulnerability!
37
40
  });
38
41
 
39
42
  // ✅ Secure code
@@ -46,7 +49,7 @@ app.get('/user', (req, res) => {
46
49
  **SQL Injection:**
47
50
  ```javascript
48
51
  // ❌ Vulnerable code
49
- const query = 'SELECT * FROM users WHERE id = ' + userId; // SQL injection!
52
+ const query = 'SELECT * FROM users WHERE id = ' + userId; // SQL injection risk!
50
53
 
51
54
  // ✅ Secure code
52
55
  const query = 'SELECT * FROM users WHERE id = ?';
@@ -56,36 +59,64 @@ db.query(query, [userId]);
56
59
  **Exposed Secrets:**
57
60
  ```javascript
58
61
  // ❌ Vulnerable code
59
- const API_KEY = 'sk-1234567890abcdef'; // Exposed in code!
62
+ const API_KEY = 'sk-1234567890abcdef'; // Secret exposed in source code!
60
63
 
61
64
  // ✅ Secure code
62
65
  const API_KEY = process.env.API_KEY; // Environment variable
63
66
  ```
64
67
 
65
- ### **Security Best Practices**
68
+ **Container Security:**
69
+ ```yaml
70
+ # ❌ Vulnerable Kubernetes manifest
71
+ apiVersion: apps/v1
72
+ kind: Deployment
73
+ spec:
74
+ template:
75
+ spec:
76
+ containers:
77
+ - name: app
78
+ image: nginx:latest # Latest tag vulnerability
79
+ securityContext:
80
+ runAsUser: 0 # Root user vulnerability
81
+ privileged: true # Privileged container vulnerability
82
+
83
+ # ✅ Secure Kubernetes manifest
84
+ apiVersion: apps/v1
85
+ kind: Deployment
86
+ spec:
87
+ template:
88
+ spec:
89
+ containers:
90
+ - name: app
91
+ image: nginx:1.21.6@sha256:abc123... # Pinned digest
92
+ securityContext:
93
+ runAsUser: 1000 # Non-root user
94
+ runAsNonRoot: true
95
+ allowPrivilegeEscalation: false
96
+ ```
97
+
98
+ ### Security Best Practices
66
99
 
67
100
  1. **Input Validation** - Always validate and sanitize user input
68
- 2. **Output Encoding** - Encode output to prevent XSS
69
- 3. **Parameterized Queries** - Use prepared statements for SQL
70
- 4. **Environment Variables** - Never hardcode secrets
101
+ 2. **Output Encoding** - Encode output to prevent XSS attacks
102
+ 3. **Parameterized Queries** - Use prepared statements for database operations
103
+ 4. **Environment Variables** - Never hardcode secrets in source code
71
104
  5. **Security Headers** - Implement proper HTTP security headers
105
+ 6. **Container Security** - Use non-root users, pinned image digests, and proper security contexts
72
106
 
73
- ## Security Rules
107
+ ## Comprehensive Security Coverage
74
108
 
75
- Vibe-Guard detects 25 types of vulnerabilities:
109
+ Vibe-Guard detects 28 types of vulnerabilities across multiple categories:
76
110
 
77
- - **Authentication & Authorization**: Missing authentication, broken access control
78
- - **Input Validation**: SQL injection, XSS, unvalidated input
79
- - **Data Protection**: Exposed secrets, hardcoded sensitive data
80
- - **Configuration**: Insecure configuration, missing security headers
81
- - **Session Management**: Insecure session handling
82
- - **Error Handling**: Information disclosure through errors
83
- - **File Operations**: Directory traversal, insecure file uploads
84
- - **Dependencies**: Insecure dependencies, outdated packages
85
- - **AI/ML Security**: AI-generated code validation, prompt injection
86
- - **Modern Threats**: CSRF, CORS issues, insecure logging
111
+ - **Authentication & Authorization**: Missing authentication, broken access control, session management
112
+ - **Input Validation**: SQL injection, XSS, unvalidated input, directory traversal
113
+ - **Data Protection**: Exposed secrets, hardcoded sensitive data, insecure logging
114
+ - **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
117
+ - **Container Security**: Kubernetes security, Dockerfile vulnerabilities, container registry issues
87
118
 
88
- ## Use Cases
119
+ ## Professional Use Cases
89
120
 
90
121
  **CI/CD Integration:**
91
122
  ```yaml
@@ -101,9 +132,12 @@ Vibe-Guard detects 25 types of vulnerabilities:
101
132
  vibe-guard scan . || exit 1
102
133
  ```
103
134
 
104
- **Educational Tool:**
135
+ **Interactive Learning:**
105
136
  ```bash
106
- # Learn about security concepts
137
+ # Start interactive session
138
+ vibe-guard start
139
+
140
+ # Learn specific security concepts
107
141
  vibe-guard learn sql-injection
108
142
  vibe-guard learn xss-detection
109
143
 
@@ -111,9 +145,9 @@ vibe-guard learn xss-detection
111
145
  vibe-guard demo
112
146
  ```
113
147
 
114
- ## Installation
148
+ ## Installation Options
115
149
 
116
- **NPM:**
150
+ **NPM (Recommended):**
117
151
  ```bash
118
152
  npm install -g vibe-guard
119
153
  ```
@@ -137,46 +171,50 @@ chmod +x vibe-guard
137
171
  curl -L https://github.com/Devjosef/vibe-guard/releases/latest/download/vibe-guard-windows-x64.exe -o vibe-guard.exe
138
172
  ```
139
173
 
140
- ## Documentation
174
+ ## Documentation & Resources
141
175
 
142
- - **[Getting Started](https://devjosef.github.io/vibe-guard/getting-started.html)** - Complete setup guide
143
- - **[Security Rules](https://devjosef.github.io/vibe-guard/rules.html)** - Detailed rule explanations
144
- - **[Performance Guide](https://devjosef.github.io/vibe-guard/performance.html)** - Optimization tips
145
- - **[API Reference](https://devjosef.github.io/vibe-guard/docs.html)** - Programmatic usage
176
+ - **[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
178
+ - **[Performance Guide](https://devjosef.github.io/vibe-guard/performance.html)** - Optimization and best practices
179
+ - **[API Reference](https://devjosef.github.io/vibe-guard/docs.html)** - Programmatic usage and integration
146
180
 
147
- ## 🤝 Community
181
+ ## Community & Support
148
182
 
149
- **Join us in making the web more secure:**
183
+ **Join our community of security professionals and developers:**
150
184
 
151
- - **Learn**: `vibe-guard learn [topic]` - Understand security concepts
152
- - **Demo**: `vibe-guard demo` - Try with example vulnerabilities
153
- - **Stats**: `vibe-guard stats` - See your security impact
154
- - **Discuss**: [GitHub Discussions](https://github.com/Devjosef/vibe-guard/discussions)
155
- - **Report**: [GitHub Issues](https://github.com/Devjosef/vibe-guard/issues)
156
- - **Star**: [GitHub Repository](https://github.com/Devjosef/vibe-guard)
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
189
+ - **Community Discussion**: [GitHub Discussions](https://github.com/Devjosef/vibe-guard/discussions)
190
+ - **Issue Reporting**: [GitHub Issues](https://github.com/Devjosef/vibe-guard/issues)
191
+ - **Repository**: [GitHub Repository](https://github.com/Devjosef/vibe-guard)
157
192
 
158
- ## Why Vibe-Guard?
193
+ ## Why Choose Vibe-Guard?
159
194
 
160
195
  **Built for developers who code fast and need security that keeps up:**
161
196
 
162
- - **Zero dependencies** - Lightweight and fast
163
- - **25 security rules** - Comprehensive coverage
164
- - **Cross-platform** - Works everywhere
165
- - **Educational** - Learn while you scan
166
- - **OWASP aligned** - Industry best practices
167
- - **Developer-friendly** - Simple CLI interface
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
168
205
 
169
- ## Impact
206
+ ## Impact & Adoption
170
207
 
171
- Every scan makes the web a little more secure:
208
+ Every scan contributes to a more secure web ecosystem:
172
209
 
173
- - **600+ total downloads** on NPM
174
- - **25 security rules** covering modern threats
175
- - **Cross-platform** support (Linux, macOS, Windows)
176
- - **Zero dependencies** for maximum compatibility
177
- - **Educational focus** - teaching security concepts
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
178
216
 
179
- ## License
217
+ ## License
180
218
 
181
219
  MIT License - see [LICENSE](LICENSE) for details.
182
220
 
@@ -0,0 +1,21 @@
1
+ import { BaseRule, FileContent, SecurityIssue } from '../types';
2
+ export declare class ContainerRegistrySecurityRule extends BaseRule {
3
+ readonly name = "container-registry-security";
4
+ readonly description = "Detects container registry security misconfigurations and vulnerabilities";
5
+ readonly severity: "medium";
6
+ private readonly registryPatterns;
7
+ check(fileContent: FileContent): SecurityIssue[];
8
+ private isContainerFile;
9
+ private analyzeRegistryContext;
10
+ private extractRegistryType;
11
+ private extractImageName;
12
+ private extractImageTag;
13
+ private extractPullPolicyType;
14
+ private extractRegistryUrls;
15
+ private extractImageReferences;
16
+ private shouldSkipMatch;
17
+ private determineSeverity;
18
+ private enhanceSuggestion;
19
+ private checkMissingPractices;
20
+ }
21
+ //# sourceMappingURL=container-registry-security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container-registry-security.d.ts","sourceRoot":"","sources":["../../src/rules/container-registry-security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAiB,MAAM,UAAU,CAAC;AAoC/E,qBAAa,6BAA8B,SAAQ,QAAQ;IACzD,QAAQ,CAAC,IAAI,iCAAiC;IAC9C,QAAQ,CAAC,WAAW,+EAA+E;IACnG,QAAQ,CAAC,QAAQ,EAAG,QAAQ,CAAU;IAEtC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAgE/B;IAEF,KAAK,CAAC,WAAW,EAAE,WAAW,GAAG,aAAa,EAAE;IAsChD,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,sBAAsB;IAuB9B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,iBAAiB;IAkDzB,OAAO,CAAC,qBAAqB;CA8E9B"}
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContainerRegistrySecurityRule = void 0;
4
+ const types_1 = require("../types");
5
+ class ContainerRegistrySecurityRule extends types_1.BaseRule {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.name = 'container-registry-security';
9
+ this.description = 'Detects container registry security misconfigurations and vulnerabilities';
10
+ this.severity = 'medium';
11
+ this.registryPatterns = [
12
+ {
13
+ pattern: /image:\s*([^:]+):latest/gm,
14
+ type: 'Latest Tag Usage',
15
+ severity: 'high',
16
+ description: 'Using latest tag can lead to unpredictable deployments',
17
+ suggestion: 'Use specific version tags (e.g., nginx:1.21.6 instead of nginx:latest)'
18
+ },
19
+ {
20
+ pattern: /image:\s*([^:]+):([^\s]+)(?!@sha256:)(?!@sha512:)/gm,
21
+ type: 'Missing Image Digest',
22
+ severity: 'high',
23
+ description: 'Image reference without @sha256 digest can lead to supply chain attacks',
24
+ suggestion: 'Use pinned digest: image@sha256:abc123... for immutable references'
25
+ },
26
+ {
27
+ pattern: /image:\s*([^:]+):([^\s]+)@sha256:([a-f0-9]{64})/gm,
28
+ type: 'Image Digest Present',
29
+ severity: 'low',
30
+ description: 'Image digest provides immutable reference - good practice',
31
+ suggestion: 'Good practice: Image digest ensures consistent deployments'
32
+ },
33
+ {
34
+ pattern: /image:\s*([^:]+):([^\s]+)(?!@sha256:)(?!@sha512:)/gm,
35
+ type: 'Missing Image Signature',
36
+ severity: 'medium',
37
+ description: 'Image without signature verification',
38
+ suggestion: 'Use signed images and verify signatures in CI/CD pipeline'
39
+ },
40
+ {
41
+ pattern: /image:\s*([^:]+):([^\s]+)(?!@sha256:)(?!@sha512:)/gm,
42
+ type: 'Insecure Image Pull',
43
+ severity: 'high',
44
+ description: 'Image pull without authentication or verification',
45
+ suggestion: 'Use imagePullSecrets and verify image integrity'
46
+ },
47
+ {
48
+ pattern: /image:\s*([^:]+):([^\s]+)(?!@sha256:)(?!@sha512:)/gm,
49
+ type: 'Public Registry Usage',
50
+ severity: 'medium',
51
+ description: 'Using public registry (Docker Hub, GCR, etc.) without verification',
52
+ suggestion: 'Use private registry or verify public images before deployment'
53
+ },
54
+ {
55
+ pattern: /image:\s*([^:]+):([^\s]+)(?!@sha256:)(?!@sha512:)/gm,
56
+ type: 'Missing Image Scanning',
57
+ severity: 'medium',
58
+ description: 'No vulnerability scanning detected in workflow',
59
+ suggestion: 'Implement image vulnerability scanning in CI/CD pipeline'
60
+ },
61
+ {
62
+ pattern: /imagePullPolicy:\s*Always/gm,
63
+ type: 'Always Pull Policy',
64
+ severity: 'low',
65
+ description: 'Always pulling images can slow deployments and increase security risk',
66
+ suggestion: 'Use IfNotPresent or specific version tags with IfNotPresent policy'
67
+ },
68
+ {
69
+ pattern: /insecure-registry|http:/gm,
70
+ type: 'Insecure Registry',
71
+ severity: 'critical',
72
+ description: 'Using insecure registry over HTTP',
73
+ suggestion: 'Use HTTPS registry endpoints for secure communication'
74
+ }
75
+ ];
76
+ }
77
+ check(fileContent) {
78
+ const issues = [];
79
+ if (!this.isContainerFile(fileContent.path)) {
80
+ return issues;
81
+ }
82
+ const context = this.analyzeRegistryContext(fileContent.content);
83
+ for (const { pattern, type, severity, description, suggestion } of this.registryPatterns) {
84
+ const matches = this.findMatches(fileContent.content, pattern);
85
+ for (const { line, column, lineContent } of matches) {
86
+ if (this.shouldSkipMatch(type, context)) {
87
+ continue;
88
+ }
89
+ const finalSeverity = this.determineSeverity(severity, context, type);
90
+ const enhancedSuggestion = this.enhanceSuggestion(suggestion, context, type);
91
+ issues.push(this.createIssue(fileContent.path, line, column, lineContent, `${type}: ${description}`, enhancedSuggestion, finalSeverity));
92
+ }
93
+ }
94
+ const missingPractices = this.checkMissingPractices(context);
95
+ issues.push(...missingPractices);
96
+ return issues;
97
+ }
98
+ isContainerFile(filePath) {
99
+ const lowerPath = filePath.toLowerCase();
100
+ return lowerPath.includes('dockerfile') ||
101
+ lowerPath.endsWith('docker-compose.yml') ||
102
+ lowerPath.endsWith('docker-compose.yaml') ||
103
+ lowerPath.endsWith('.dockerfile') ||
104
+ lowerPath.endsWith('.yaml') ||
105
+ lowerPath.endsWith('.yml') ||
106
+ lowerPath.includes('k8s') ||
107
+ lowerPath.includes('kubernetes') ||
108
+ lowerPath.includes('deployment') ||
109
+ lowerPath.includes('service') ||
110
+ lowerPath.includes('pod');
111
+ }
112
+ analyzeRegistryContext(content) {
113
+ return {
114
+ hasImagePullSecrets: /imagePullSecrets:/m.test(content),
115
+ hasImageDigest: /@sha256:|@sha512:/m.test(content),
116
+ hasImageSignature: /@sha256:|@sha512:/m.test(content),
117
+ hasImagePullPolicy: /imagePullPolicy:/m.test(content),
118
+ registryType: this.extractRegistryType(content),
119
+ imageName: this.extractImageName(content),
120
+ imageTag: this.extractImageTag(content),
121
+ hasInsecureRegistry: /insecure-registry|http:/m.test(content),
122
+ hasPublicRegistry: /docker\.io|gcr\.io|quay\.io|registry\.k8s\.io/m.test(content),
123
+ hasPrivateRegistry: /\.local|\.internal|private/m.test(content),
124
+ hasImageScanning: /scan|vulnerability|security/m.test(content),
125
+ hasImageSigning: /sign|signature|cosign/m.test(content),
126
+ pullPolicyType: this.extractPullPolicyType(content),
127
+ hasTrivyScanning: /trivy|aquasec/m.test(content),
128
+ hasCosignSigning: /cosign|signature/m.test(content),
129
+ hasVulnerabilityScanning: /vulnerability|scan|security/m.test(content),
130
+ registryUrls: this.extractRegistryUrls(content),
131
+ imageReferences: this.extractImageReferences(content)
132
+ };
133
+ }
134
+ extractRegistryType(content) {
135
+ if (/docker\.io/m.test(content))
136
+ return 'docker-hub';
137
+ if (/gcr\.io/m.test(content))
138
+ return 'gcr';
139
+ if (/quay\.io/m.test(content))
140
+ return 'quay';
141
+ if (/registry\.k8s\.io/m.test(content))
142
+ return 'k8s-registry';
143
+ if (/\.local|\.internal/m.test(content))
144
+ return 'private';
145
+ return 'unknown';
146
+ }
147
+ extractImageName(content) {
148
+ const imageMatch = content.match(/image:\s*([^:]+):/m);
149
+ return imageMatch?.[1] ?? 'unknown';
150
+ }
151
+ extractImageTag(content) {
152
+ const tagMatch = content.match(/image:\s*[^:]+:([^\s@]+)/m);
153
+ return tagMatch?.[1] ?? 'latest';
154
+ }
155
+ extractPullPolicyType(content) {
156
+ const policyMatch = content.match(/imagePullPolicy:\s*(\w+)/m);
157
+ return policyMatch?.[1] ?? 'unknown';
158
+ }
159
+ extractRegistryUrls(content) {
160
+ const urlMatches = content.match(/(?:registry|repository):\s*([^\s\n]+)/gm);
161
+ if (!urlMatches)
162
+ return [];
163
+ return urlMatches.map(match => {
164
+ const urlMatch = match.match(/(?:registry|repository):\s*(.+)/);
165
+ return urlMatch?.[1]?.trim() ?? '';
166
+ }).filter(url => url.length > 0);
167
+ }
168
+ extractImageReferences(content) {
169
+ const imageMatches = content.match(/image:\s*([^\s\n]+)/gm);
170
+ if (!imageMatches)
171
+ return [];
172
+ return imageMatches.map(match => {
173
+ const imageMatch = match.match(/image:\s*(.+)/);
174
+ return imageMatch?.[1]?.trim() ?? '';
175
+ }).filter(image => image.length > 0);
176
+ }
177
+ shouldSkipMatch(type, context) {
178
+ if (type === 'Missing Image Digest' && context.hasImageDigest) {
179
+ return true;
180
+ }
181
+ if (type === 'Missing Image Signature' && context.hasImageSignature) {
182
+ return true;
183
+ }
184
+ return false;
185
+ }
186
+ determineSeverity(baseSeverity, context, type) {
187
+ if (type === 'Missing Image Digest' && !context.hasImageDigest) {
188
+ return 'high';
189
+ }
190
+ if (type === 'Insecure Registry' && context.hasInsecureRegistry) {
191
+ return 'critical';
192
+ }
193
+ if (type === 'Public Registry Usage' && context.hasPublicRegistry && !context.hasVulnerabilityScanning) {
194
+ return 'high';
195
+ }
196
+ if (type === 'Latest Tag Usage' && context.hasPublicRegistry) {
197
+ return 'high';
198
+ }
199
+ if (type === 'Missing Image Scanning' && context.hasPublicRegistry) {
200
+ return 'high';
201
+ }
202
+ if (type === 'Insecure Image Pull' && context.hasPrivateRegistry && !context.hasImagePullSecrets) {
203
+ return 'critical';
204
+ }
205
+ return baseSeverity;
206
+ }
207
+ enhanceSuggestion(baseSuggestion, context, type) {
208
+ let suggestion = baseSuggestion;
209
+ if (type === 'Missing Image Digest') {
210
+ suggestion += '\n\n**Complete secure image reference example:**\n```yaml\nimage: nginx@sha256:abc123def456...\nimagePullPolicy: IfNotPresent\nimagePullSecrets:\n - name: registry-secret\n```';
211
+ suggestion += '\n\n**Security benefit:** Pinned digests prevent supply chain attacks and ensure immutable images';
212
+ }
213
+ if (type === 'Latest Image Tag') {
214
+ suggestion += `\n\n**Current image:** ${context.imageName}:${context.imageTag}`;
215
+ suggestion += '\n**Recommended:** Use specific version tags for reproducible deployments';
216
+ suggestion += '\n**Example:** Replace `nginx:latest` with `nginx:1.21.6`';
217
+ }
218
+ if (type === 'Missing Image Scanning') {
219
+ suggestion += '\n\n**Implement image scanning with Trivy:**\n```yaml\n# In CI/CD pipeline\n- name: Scan image\n run: |\n docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \\\n aquasec/trivy image ${IMAGE_NAME}:${IMAGE_TAG}\n```';
220
+ suggestion += '\n\n**Alternative tools:** Snyk, Clair, or built-in registry scanning';
221
+ }
222
+ if (type === 'Insecure Image Pull') {
223
+ suggestion += '\n\n**Secure image pull configuration:**\n```yaml\nimagePullSecrets:\n - name: registry-secret\nimagePullPolicy: IfNotPresent\n```';
224
+ suggestion += '\n\n**For private registries:** Always use imagePullSecrets for authentication';
225
+ }
226
+ if (type === 'Public Registry Usage') {
227
+ suggestion += `\n\n**Registry type detected:** ${context.registryType}`;
228
+ suggestion += '\n**Security risk:** Public registries can be compromised or contain malicious images';
229
+ suggestion += '\n**Solution:** Use private registry or verify public images before deployment';
230
+ }
231
+ if (type === 'Missing Image Signature') {
232
+ suggestion += '\n\n**Implement image signing with cosign:**\n```bash\n# Sign image\ncosign sign --key cosign.key ${IMAGE_NAME}:${IMAGE_TAG}\n\n# Verify signature\ncosign verify --key cosign.pub ${IMAGE_NAME}:${IMAGE_TAG}\n```';
233
+ suggestion += '\n\n**Security benefit:** Image signatures ensure integrity and authenticity';
234
+ }
235
+ if (type === 'Insecure Registry') {
236
+ suggestion += '\n\n**Security risk:** HTTP registries are vulnerable to man-in-the-middle attacks';
237
+ suggestion += '\n**Solution:** Use HTTPS registry endpoints for secure communication';
238
+ suggestion += '\n**Example:** Replace `http://registry.example.com` with `https://registry.example.com`';
239
+ }
240
+ if (type === 'Always Pull Policy') {
241
+ suggestion += '\n\n**Current pull policy:** ' + context.pullPolicyType;
242
+ suggestion += '\n**Security risk:** Always pulling can slow deployments and increase attack surface';
243
+ suggestion += '\n**Recommended:** Use `IfNotPresent` with specific version tags';
244
+ }
245
+ return suggestion;
246
+ }
247
+ checkMissingPractices(context) {
248
+ const issues = [];
249
+ if (!context.hasImagePullSecrets && context.hasPrivateRegistry) {
250
+ issues.push(this.createIssue('Container Manifest', 1, 1, 'image: ...', 'Missing image pull secrets: Cannot authenticate with private registry', 'Add imagePullSecrets to authenticate with private registry:\n```yaml\nimagePullSecrets:\n - name: registry-secret\n```', 'high'));
251
+ }
252
+ if (!context.hasImageDigest && context.imageReferences.length > 0) {
253
+ issues.push(this.createIssue('Container Manifest', 1, 1, 'image: ...', 'Missing image digest: Image references are mutable', 'Use image digest for immutable references: image@sha256:abc123...\n**Security benefit:** Prevents supply chain attacks', 'high'));
254
+ }
255
+ if (!context.hasVulnerabilityScanning && context.hasPublicRegistry) {
256
+ issues.push(this.createIssue('Container Manifest', 1, 1, 'image: ...', 'Missing image scanning: No vulnerability assessment for public registry images', 'Implement image vulnerability scanning in CI/CD pipeline:\n```yaml\n# Trivy scanning\n- name: Scan image\n run: docker run --rm aquasec/trivy image ${IMAGE_NAME}:${IMAGE_TAG}\n```', 'high'));
257
+ }
258
+ if (!context.hasImageSigning && context.hasPublicRegistry) {
259
+ issues.push(this.createIssue('Container Manifest', 1, 1, 'image: ...', 'Missing image signing: No integrity verification for public registry images', 'Implement image signing and verification in CI/CD pipeline:\n```bash\n# Sign with cosign\ncosign sign --key cosign.key ${IMAGE_NAME}:${IMAGE_TAG}\n```', 'medium'));
260
+ }
261
+ if (!context.hasImagePullPolicy && context.imageReferences.length > 0) {
262
+ issues.push(this.createIssue('Container Manifest', 1, 1, 'image: ...', 'Missing image pull policy: No pull policy specified', 'Add imagePullPolicy for better control:\n```yaml\nimagePullPolicy: IfNotPresent\n```', 'low'));
263
+ }
264
+ if (context.hasInsecureRegistry) {
265
+ issues.push(this.createIssue('Container Manifest', 1, 1, 'registry: ...', 'Insecure registry detected: Using HTTP instead of HTTPS', 'Use HTTPS registry endpoints for secure communication:\n```yaml\n# Replace http:// with https://\nregistry: https://registry.example.com\n```', 'critical'));
266
+ }
267
+ return issues;
268
+ }
269
+ }
270
+ exports.ContainerRegistrySecurityRule = ContainerRegistrySecurityRule;
271
+ //# sourceMappingURL=container-registry-security.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container-registry-security.js","sourceRoot":"","sources":["../../src/rules/container-registry-security.ts"],"names":[],"mappings":";;;AAAA,oCAA+E;AAoC/E,MAAa,6BAA8B,SAAQ,gBAAQ;IAA3D;;QACW,SAAI,GAAG,6BAA6B,CAAC;QACrC,gBAAW,GAAG,2EAA2E,CAAC;QAC1F,aAAQ,GAAG,QAAiB,CAAC;QAErB,qBAAgB,GAAsB;YACrD;gBACE,OAAO,EAAE,2BAA2B;gBACpC,IAAI,EAAE,kBAAkB;gBACxB,QAAQ,EAAE,MAAM;gBAChB,WAAW,EAAE,wDAAwD;gBACrE,UAAU,EAAE,wEAAwE;aACrF;YACD;gBACE,OAAO,EAAE,qDAAqD;gBAC9D,IAAI,EAAE,sBAAsB;gBAC5B,QAAQ,EAAE,MAAM;gBAChB,WAAW,EAAE,yEAAyE;gBACtF,UAAU,EAAE,oEAAoE;aACjF;YACD;gBACE,OAAO,EAAE,mDAAmD;gBAC5D,IAAI,EAAE,sBAAsB;gBAC5B,QAAQ,EAAE,KAAK;gBACf,WAAW,EAA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B,EACpB,CAAC,EACD,CAAC,EACD,YAAY,EACZ,oDAAoD,EACpD,wHAAwH,EACxH,MAAM,CACP,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,wBAAwB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YACnE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAC1B,oBAAoB,EACpB,CAAC,EACD,CAAC,EACD,YAAY,EACZ,gFAAgF,EAChF,sLAAsL,EACtL,MAAM,CACP,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC1D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAC1B,oBAAoB,EACpB,CAAC,EACD,CAAC,EACD,YAAY,EACZ,6EAA6E,EAC7E,wJAAwJ,EACxJ,QAAQ,CACT,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAC1B,oBAAoB,EACpB,CAAC,EACD,CAAC,EACD,YAAY,EACZ,qDAAqD,EACrD,sFAAsF,EACtF,KAAK,CACN,CAAC,CAAC;QACL,CAAC;QAED,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAC1B,oBAAoB,EACpB,CAAC,EACD,CAAC,EACD,eAAe,EACf,yDAAyD,EACzD,+IAA+I,EAC/I,UAAU,CACX,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF;AAvWD,sEAuWC"}
@@ -0,0 +1,20 @@
1
+ import { BaseRule, FileContent, SecurityIssue } from '../types';
2
+ export declare class DockerfileSecurityRule extends BaseRule {
3
+ readonly name = "dockerfile-security";
4
+ readonly description = "Detects common Dockerfile security vulnerabilities and misconfigurations";
5
+ readonly severity: "high";
6
+ private readonly dockerfilePatterns;
7
+ check(fileContent: FileContent): SecurityIssue[];
8
+ private isDockerfile;
9
+ private analyzeDockerfileContext;
10
+ private extractBaseImage;
11
+ private extractExposedPorts;
12
+ private checkDockerignoreExists;
13
+ private extractUserDirectiveOrder;
14
+ private hasPublicPorts;
15
+ private shouldSkipMatch;
16
+ private determineSeverity;
17
+ private enhanceSuggestion;
18
+ private checkMissingPractices;
19
+ }
20
+ //# sourceMappingURL=dockerfile-security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dockerfile-security.d.ts","sourceRoot":"","sources":["../../src/rules/dockerfile-security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAiB,MAAM,UAAU,CAAC;AAmC/E,qBAAa,sBAAuB,SAAQ,QAAQ;IAClD,QAAQ,CAAC,IAAI,yBAAyB;IACtC,QAAQ,CAAC,WAAW,8EAA8E;IAClG,QAAQ,CAAC,QAAQ,EAAG,MAAM,CAAU;IAEpC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAqFjC;IAEF,KAAK,CAAC,WAAW,EAAE,WAAW,GAAG,aAAa,EAAE;IAsChD,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,wBAAwB;IAyBhC,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,iBAAiB;IAiDzB,OAAO,CAAC,qBAAqB;CAuG9B"}