@modular-intelligence/checkov 1.0.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 (3) hide show
  1. package/README.md +442 -0
  2. package/dist/index.js +44817 -0
  3. package/package.json +35 -0
package/README.md ADDED
@@ -0,0 +1,442 @@
1
+ # Checkov MCP Server
2
+
3
+ MCP server wrapping [Checkov](https://www.checkov.io/) for Infrastructure-as-Code (IaC) security scanning and Software Composition Analysis (SCA).
4
+
5
+ ## Overview
6
+
7
+ This MCP server provides a secure interface to Checkov, enabling automated security scanning of infrastructure code including Terraform, CloudFormation, Kubernetes, Dockerfiles, and more. It includes comprehensive security controls to prevent command injection and path traversal attacks.
8
+
9
+ ## Tools
10
+
11
+ | Tool | Description | Primary Use Case |
12
+ |------|-------------|------------------|
13
+ | `checkov_scan` | Scan IaC files for security misconfigurations | Daily security scans of infrastructure code |
14
+ | `checkov_scan_plan` | Scan Terraform plan files before apply | CI/CD pipeline validation |
15
+ | `checkov_list_checks` | List available security checks by framework | Discovery and compliance mapping |
16
+ | `checkov_check_detail` | Get detailed information about a specific check | Understanding and remediation guidance |
17
+ | `checkov_scan_sca` | Scan package dependencies for vulnerabilities | Software supply chain security |
18
+ | `checkov_baseline` | Run incremental scans against a baseline | Progressive security improvement |
19
+
20
+ ## Tool Details
21
+
22
+ ### checkov_scan
23
+
24
+ Scan IaC files or directories for security misconfigurations.
25
+
26
+ **Input:**
27
+ ```json
28
+ {
29
+ "path": "/path/to/terraform",
30
+ "framework": "terraform",
31
+ "severity": "HIGH",
32
+ "skip_checks": ["CKV_AWS_1", "CKV_AWS_2"],
33
+ "compact": false,
34
+ "timeout": 120
35
+ }
36
+ ```
37
+
38
+ **Output:**
39
+ ```json
40
+ {
41
+ "passed": 45,
42
+ "failed": 12,
43
+ "skipped": 3,
44
+ "parsing_errors": 0,
45
+ "results": [
46
+ {
47
+ "check_id": "CKV_AWS_1",
48
+ "check_name": "Ensure S3 bucket has versioning enabled",
49
+ "result": "FAILED",
50
+ "resource": "aws_s3_bucket.example",
51
+ "file_path": "/path/to/terraform/s3.tf",
52
+ "guideline": "https://docs.bridgecrew.io/docs/s3_16"
53
+ }
54
+ ]
55
+ }
56
+ ```
57
+
58
+ **Parameters:**
59
+ - `path` (string, required): Path to IaC file or directory
60
+ - `framework` (enum, default: "all"): One of terraform, cloudformation, kubernetes, dockerfile, helm, arm, bicep, serverless, ansible, all
61
+ - `severity` (enum, optional): Filter by minimum severity - LOW, MEDIUM, HIGH, CRITICAL
62
+ - `skip_checks` (array, optional): List of check IDs to skip
63
+ - `compact` (boolean, default: false): Enable compact output
64
+ - `timeout` (number, default: 120): Max scan duration in seconds (30-600)
65
+
66
+ ### checkov_scan_plan
67
+
68
+ Scan a Terraform plan JSON file for security issues before applying changes.
69
+
70
+ **Input:**
71
+ ```json
72
+ {
73
+ "plan_file": "/path/to/tfplan.json",
74
+ "timeout": 120
75
+ }
76
+ ```
77
+
78
+ **Output:**
79
+ ```json
80
+ {
81
+ "passed": 30,
82
+ "failed": 5,
83
+ "skipped": 1,
84
+ "parsing_errors": 0,
85
+ "results": [
86
+ {
87
+ "check_id": "CKV_AWS_23",
88
+ "check_name": "Ensure security group ingress is not open to 0.0.0.0/0",
89
+ "result": "FAILED",
90
+ "resource": "aws_security_group.allow_all",
91
+ "file_path": "/path/to/tfplan.json",
92
+ "guideline": "https://docs.bridgecrew.io/docs/networking_1"
93
+ }
94
+ ]
95
+ }
96
+ ```
97
+
98
+ **Parameters:**
99
+ - `plan_file` (string, required): Path to Terraform plan JSON file
100
+ - `timeout` (number, default: 120): Max scan duration in seconds (30-600)
101
+
102
+ ### checkov_list_checks
103
+
104
+ List all available Checkov security checks for a given framework.
105
+
106
+ **Input:**
107
+ ```json
108
+ {
109
+ "framework": "terraform"
110
+ }
111
+ ```
112
+
113
+ **Output:**
114
+ ```json
115
+ {
116
+ "checks": [
117
+ {
118
+ "id": "CKV_AWS_1",
119
+ "name": "Ensure S3 bucket has versioning enabled",
120
+ "framework": "terraform"
121
+ },
122
+ {
123
+ "id": "CKV_AWS_2",
124
+ "name": "Ensure S3 bucket has logging enabled",
125
+ "framework": "terraform"
126
+ }
127
+ ],
128
+ "total": 456
129
+ }
130
+ ```
131
+
132
+ **Parameters:**
133
+ - `framework` (enum, default: "all"): Framework to list checks for
134
+
135
+ ### checkov_check_detail
136
+
137
+ Get detailed information about a specific Checkov check.
138
+
139
+ **Input:**
140
+ ```json
141
+ {
142
+ "check_id": "CKV_AWS_1"
143
+ }
144
+ ```
145
+
146
+ **Output:**
147
+ ```json
148
+ {
149
+ "id": "CKV_AWS_1",
150
+ "name": "Ensure S3 bucket has versioning enabled",
151
+ "framework": "terraform",
152
+ "description": "S3 bucket versioning protects against accidental deletion",
153
+ "guideline_url": "https://docs.bridgecrew.io/docs/s3_16"
154
+ }
155
+ ```
156
+
157
+ **Parameters:**
158
+ - `check_id` (string, required): Checkov check ID (format: CKV_XXX_N, CKV2_XXX_N, or BC_XXX_N)
159
+
160
+ ### checkov_scan_sca
161
+
162
+ Scan package dependencies for known vulnerabilities using Software Composition Analysis.
163
+
164
+ **Input:**
165
+ ```json
166
+ {
167
+ "path": "/path/to/project",
168
+ "package_type": "npm",
169
+ "timeout": 120
170
+ }
171
+ ```
172
+
173
+ **Output:**
174
+ ```json
175
+ {
176
+ "total_vulnerabilities": 23,
177
+ "critical": 2,
178
+ "high": 8,
179
+ "medium": 10,
180
+ "low": 3,
181
+ "vulnerabilities": [
182
+ {
183
+ "cve_id": "CVE-2023-12345",
184
+ "severity": "CRITICAL",
185
+ "package_name": "lodash",
186
+ "package_version": "4.17.15",
187
+ "fixed_version": "4.17.21",
188
+ "description": "Prototype pollution vulnerability"
189
+ }
190
+ ]
191
+ }
192
+ ```
193
+
194
+ **Parameters:**
195
+ - `path` (string, required): Path to project directory
196
+ - `package_type` (enum, optional): One of npm, pip, go, maven, gradle, nuget, ruby
197
+ - `timeout` (number, default: 120): Max scan duration in seconds (30-600)
198
+
199
+ ### checkov_baseline
200
+
201
+ Run Checkov scan with baseline comparison for incremental scanning.
202
+
203
+ **Input:**
204
+ ```json
205
+ {
206
+ "path": "/path/to/terraform",
207
+ "framework": "terraform",
208
+ "baseline_path": "/path/to/.checkov.baseline",
209
+ "timeout": 120
210
+ }
211
+ ```
212
+
213
+ **Output:**
214
+ ```json
215
+ {
216
+ "baseline_exists": true,
217
+ "new_failures": 3,
218
+ "new_failures_details": [
219
+ {
220
+ "check_id": "CKV_AWS_45",
221
+ "check_name": "Ensure EBS volumes are encrypted",
222
+ "resource": "aws_ebs_volume.data",
223
+ "file_path": "/path/to/terraform/ebs.tf",
224
+ "guideline": "https://docs.bridgecrew.io/docs/general_13"
225
+ }
226
+ ],
227
+ "total_failures": 15
228
+ }
229
+ ```
230
+
231
+ **Parameters:**
232
+ - `path` (string, required): Path to IaC directory
233
+ - `framework` (enum, default: "all"): Framework to scan
234
+ - `baseline_path` (string, optional): Path to baseline file. If not provided, creates a new baseline
235
+ - `timeout` (number, default: 120): Max scan duration in seconds (30-600)
236
+
237
+ ## Security
238
+
239
+ This MCP server implements comprehensive security controls:
240
+
241
+ ### Path Validation
242
+ - Blocks path traversal attempts (`../`, `~`)
243
+ - Blocks null bytes in paths
244
+ - Blocks access to system directories (`/etc`, `/proc`, `/sys`, `/dev`)
245
+ - Validates all paths exist before execution
246
+ - Converts all paths to absolute paths
247
+
248
+ ### Framework Validation
249
+ - Whitelist-only validation for frameworks
250
+ - Allowed: terraform, cloudformation, kubernetes, dockerfile, helm, arm, bicep, serverless, ansible, all
251
+
252
+ ### Check ID Validation
253
+ - Pattern validation: `^(CKV|CKV2|BC)_[A-Z_]+_\d+$`
254
+ - Examples: `CKV_AWS_1`, `CKV2_AZURE_12`, `BC_AWS_GENERAL_45`
255
+
256
+ ### Blocked Flags
257
+ The following dangerous Checkov flags are blocked:
258
+ - `--external-checks-git` (prevents arbitrary code execution)
259
+ - `--external-checks-dir` (prevents arbitrary code execution)
260
+ - `--repo-id` (prevents unintended API calls)
261
+
262
+ ### Execution Controls
263
+ - Configurable timeouts (30-600 seconds)
264
+ - Hard kill after timeout + 5 seconds
265
+ - 10MB output buffer limit
266
+ - All commands executed with controlled argument arrays (no shell injection)
267
+
268
+ ## Prerequisites
269
+
270
+ ### Required
271
+ - **Checkov CLI**: Install via pip, brew, or docker
272
+ ```bash
273
+ # Option 1: pip
274
+ pip install checkov
275
+
276
+ # Option 2: brew (macOS)
277
+ brew install checkov
278
+
279
+ # Option 3: docker
280
+ docker pull bridgecrew/checkov
281
+ ```
282
+
283
+ - **Bun**: For running the MCP server
284
+ ```bash
285
+ curl -fsSL https://bun.sh/install | bash
286
+ ```
287
+
288
+ ### Optional
289
+ - **BC_API_KEY**: Bridgecrew API key for enhanced features
290
+ ```bash
291
+ export BC_API_KEY="your-api-key"
292
+ ```
293
+
294
+ ## Installation
295
+
296
+ 1. Clone or navigate to the checkov directory:
297
+ ```bash
298
+ cd /Users/ehenry/Documents/code/mcp-servers/checkov
299
+ ```
300
+
301
+ 2. Install dependencies:
302
+ ```bash
303
+ bun install
304
+ ```
305
+
306
+ 3. Build the server:
307
+ ```bash
308
+ bun run build
309
+ ```
310
+
311
+ 4. Run the server:
312
+ ```bash
313
+ bun run start
314
+ ```
315
+
316
+ ## Configuration
317
+
318
+ Add to your MCP client configuration (e.g., Claude Desktop):
319
+
320
+ ```json
321
+ {
322
+ "mcpServers": {
323
+ "checkov": {
324
+ "command": "bun",
325
+ "args": ["run", "/Users/ehenry/Documents/code/mcp-servers/checkov/src/index.ts"],
326
+ "env": {
327
+ "BC_API_KEY": "your-api-key-here"
328
+ }
329
+ }
330
+ }
331
+ }
332
+ ```
333
+
334
+ ## Usage Examples
335
+
336
+ ### Example 1: Scan Terraform Directory
337
+ ```json
338
+ {
339
+ "tool": "checkov_scan",
340
+ "input": {
341
+ "path": "/path/to/terraform",
342
+ "framework": "terraform",
343
+ "severity": "HIGH"
344
+ }
345
+ }
346
+ ```
347
+
348
+ ### Example 2: Scan Terraform Plan in CI/CD
349
+ ```json
350
+ {
351
+ "tool": "checkov_scan_plan",
352
+ "input": {
353
+ "plan_file": "/tmp/tfplan.json",
354
+ "timeout": 180
355
+ }
356
+ }
357
+ ```
358
+
359
+ ### Example 3: List All Kubernetes Checks
360
+ ```json
361
+ {
362
+ "tool": "checkov_list_checks",
363
+ "input": {
364
+ "framework": "kubernetes"
365
+ }
366
+ }
367
+ ```
368
+
369
+ ### Example 4: Get Check Details
370
+ ```json
371
+ {
372
+ "tool": "checkov_check_detail",
373
+ "input": {
374
+ "check_id": "CKV_AWS_18"
375
+ }
376
+ }
377
+ ```
378
+
379
+ ### Example 5: SCA Scan for NPM Vulnerabilities
380
+ ```json
381
+ {
382
+ "tool": "checkov_scan_sca",
383
+ "input": {
384
+ "path": "/path/to/nodejs-project",
385
+ "package_type": "npm"
386
+ }
387
+ }
388
+ ```
389
+
390
+ ### Example 6: Baseline Scanning
391
+ ```json
392
+ {
393
+ "tool": "checkov_baseline",
394
+ "input": {
395
+ "path": "/path/to/terraform",
396
+ "framework": "terraform",
397
+ "baseline_path": "/path/to/.checkov.baseline"
398
+ }
399
+ }
400
+ ```
401
+
402
+ ## Development
403
+
404
+ ### Build
405
+ ```bash
406
+ bun run build
407
+ ```
408
+
409
+ ### Run Locally
410
+ ```bash
411
+ bun run start
412
+ ```
413
+
414
+ ### Project Structure
415
+ ```
416
+ checkov/
417
+ ├── package.json # Dependencies and scripts
418
+ ├── tsconfig.json # TypeScript configuration
419
+ ├── README.md # This file
420
+ └── src/
421
+ ├── index.ts # MCP server entry point
422
+ ├── schemas.ts # Zod schemas for validation
423
+ ├── security.ts # Security validation functions
424
+ ├── cli-executor.ts # Checkov CLI execution wrapper
425
+ └── tools/
426
+ ├── checkov-scan.ts
427
+ ├── checkov-scan-plan.ts
428
+ ├── checkov-list-checks.ts
429
+ ├── checkov-check-detail.ts
430
+ ├── checkov-scan-sca.ts
431
+ └── checkov-baseline.ts
432
+ ```
433
+
434
+ ## License
435
+
436
+ MIT
437
+
438
+ ## Support
439
+
440
+ For issues and questions:
441
+ - Checkov documentation: https://www.checkov.io/
442
+ - MCP SDK: https://github.com/modelcontextprotocol/sdk