cdk-insights 0.17.1 → 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.
- package/README.md +110 -94
- package/dist/analysis/static/staticAnalysis.d.ts +4 -1
- package/dist/cli/config/userConfig.d.ts +4 -0
- package/dist/cli/types/cli.types.d.ts +3 -1
- package/dist/entry.js +199 -198
- package/dist/index.js +124 -124
- package/dist/rules/customRuleEvaluator.d.ts +7 -0
- package/dist/rules/customRuleLoader.d.ts +6 -0
- package/dist/rules/customRules.types.d.ts +53 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,35 +1,55 @@
|
|
|
1
1
|
# CDK Insights 🔍
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
Scan your AWS CDK stacks for **security vulnerabilities, cost optimization opportunities, and best practice issues**.
|
|
5
|
-
Integrating and building upon tool like **cdk-nag**, CDK Insights adds **AI-powered recommendations** for smarter cloud infrastructure improvements.
|
|
3
|
+
**Catch security issues in your AWS CDK before they reach production.**
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
Scan your CDK stacks for security vulnerabilities, cost waste, compliance violations, and best practice issues — across 100+ rules and 35+ AWS services. Your source code never leaves your machine.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/cdk-insights)
|
|
8
|
+
[](https://www.npmjs.com/package/cdk-insights)
|
|
9
|
+
|
|
10
|
+
👉 **[cdkinsights.dev](https://cdkinsights.dev)** | **[Full Documentation](https://cdkinsights.dev/docs)**
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Why CDK Insights?
|
|
15
|
+
|
|
16
|
+
Existing tools (Checkov, cfn-lint, cfn_nag) scan raw CloudFormation. They don't understand CDK constructs, L2/L3 patterns, or developer intent.
|
|
17
|
+
|
|
18
|
+
CDK Insights is **purpose-built for CDK** — it synthesizes your stacks and analyzes them with CDK context, integrating CDK Nag alongside 100+ custom rules.
|
|
19
|
+
|
|
20
|
+
**Key differences:**
|
|
21
|
+
- **Local-first** — static analysis runs entirely on your machine, no code uploaded
|
|
22
|
+
- **Zero friction** — no signup, no account, no API keys
|
|
23
|
+
- **Free forever** — static analysis with 100+ rules, JSON/Table/Markdown output, no limits
|
|
24
|
+
- **CDK-native** — understands constructs and patterns, not just CloudFormation
|
|
25
|
+
- **CI/CD ready** — GitHub Action with PR comments and merge blocking
|
|
8
26
|
|
|
9
27
|
---
|
|
10
28
|
|
|
11
29
|
## 🚀 Quick Start
|
|
12
30
|
|
|
13
31
|
```bash
|
|
14
|
-
#
|
|
32
|
+
# Run instantly — no install needed
|
|
15
33
|
npx cdk-insights scan
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
That's it. CDK Insights will synthesize your stacks and scan them.
|
|
37
|
+
|
|
38
|
+
### Install in your project
|
|
16
39
|
|
|
17
|
-
|
|
40
|
+
```bash
|
|
41
|
+
# Add to your project
|
|
18
42
|
npm install --save-dev cdk-insights
|
|
19
43
|
|
|
20
|
-
#
|
|
44
|
+
# Set up npm scripts automatically
|
|
21
45
|
npx cdk-insights init
|
|
22
46
|
|
|
23
|
-
# Then use familiar
|
|
47
|
+
# Then use familiar commands
|
|
24
48
|
npm run cdk-insights
|
|
25
|
-
npm run cdk-insights:all
|
|
26
|
-
npm run cdk-insights:ci
|
|
27
49
|
```
|
|
28
50
|
|
|
29
51
|
### What `cdk-insights init` adds
|
|
30
52
|
|
|
31
|
-
The `init` command adds these npm scripts to your `package.json`:
|
|
32
|
-
|
|
33
53
|
```json
|
|
34
54
|
{
|
|
35
55
|
"scripts": {
|
|
@@ -44,47 +64,68 @@ The `init` command adds these npm scripts to your `package.json`:
|
|
|
44
64
|
|
|
45
65
|
Use `npx cdk-insights init --all` to include additional scripts for GitHub issues and summary output.
|
|
46
66
|
|
|
47
|
-
|
|
67
|
+
---
|
|
48
68
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
## 🔍 What It Catches
|
|
70
|
+
|
|
71
|
+
CDK Insights scans for real problems across **35+ AWS services**:
|
|
72
|
+
|
|
73
|
+
| Category | Examples |
|
|
74
|
+
|----------|---------|
|
|
75
|
+
| **Security** | Public S3 buckets, wildcard IAM policies, unencrypted RDS/DynamoDB/SQS, open security groups |
|
|
76
|
+
| **Cost** | Over-provisioned Lambda memory, missing S3 lifecycle policies, unused resources |
|
|
77
|
+
| **Best Practices** | Missing CloudWatch alarms, no VPC flow logs, missing point-in-time recovery |
|
|
78
|
+
| **Compliance** | Encryption at rest, logging enabled, backup configuration |
|
|
79
|
+
|
|
80
|
+
**Services covered:** S3, IAM, Lambda, RDS, EC2, DynamoDB, SQS, SNS, CloudFront, ECS/Fargate, API Gateway, Cognito, KMS, Secrets Manager, Step Functions, CloudTrail, EventBridge, EBS, WAF, CloudWatch, Route53, ElastiCache, ECR, OpenSearch, VPC, EKS, and more.
|
|
53
81
|
|
|
54
82
|
---
|
|
55
83
|
|
|
56
|
-
##
|
|
84
|
+
## 📊 Output Formats
|
|
57
85
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
86
|
+
| Format | Use Case | Command |
|
|
87
|
+
|--------|----------|---------|
|
|
88
|
+
| **Table** | Terminal review (default) | `npx cdk-insights scan` |
|
|
89
|
+
| **JSON** | CI/CD pipelines, automation | `--output json` |
|
|
90
|
+
| **Markdown** | Reports, documentation | `--output markdown` |
|
|
91
|
+
| **Summary** | Quick overview | `--output summary` |
|
|
92
|
+
| **SARIF** | GitHub Code Scanning | `--output sarif` |
|
|
65
93
|
|
|
66
94
|
---
|
|
67
95
|
|
|
68
|
-
## 💡 Usage Examples
|
|
96
|
+
## 💡 Usage Examples
|
|
69
97
|
|
|
70
|
-
| Scenario
|
|
71
|
-
|
|
72
|
-
| Full project scan
|
|
73
|
-
| Security-only focus
|
|
74
|
-
| Markdown report
|
|
75
|
-
| CI/CD
|
|
76
|
-
| Create GitHub issue
|
|
98
|
+
| Scenario | Command |
|
|
99
|
+
|----------|---------|
|
|
100
|
+
| Full project scan | `npx cdk-insights scan --all --output summary` |
|
|
101
|
+
| Security-only focus | `npx cdk-insights scan --services IAM,S3,KMS --rule-filter Security` |
|
|
102
|
+
| Markdown report | `npx cdk-insights scan --output markdown > report.md` |
|
|
103
|
+
| CI/CD with fail gate | `npx cdk-insights scan --all --output json --fail-on-critical` |
|
|
104
|
+
| Create GitHub issue | `npx cdk-insights scan --output markdown --with-issue` |
|
|
77
105
|
|
|
78
106
|
---
|
|
79
107
|
|
|
80
108
|
## 🔄 CI/CD Integration
|
|
81
109
|
|
|
82
|
-
CDK Insights automatically detects CI environments (GitHub Actions, GitLab CI, Jenkins,
|
|
110
|
+
CDK Insights automatically detects CI environments (GitHub Actions, GitLab CI, Jenkins, CircleCI, AWS CodeBuild, and more) and adjusts behavior accordingly.
|
|
111
|
+
|
|
112
|
+
### GitHub Action
|
|
113
|
+
|
|
114
|
+
```yaml
|
|
115
|
+
- name: Run CDK Insights
|
|
116
|
+
uses: instance-labs/cdk-insights-action@v1
|
|
117
|
+
with:
|
|
118
|
+
license-key: ${{ secrets.CDK_INSIGHTS_LICENSE_KEY }}
|
|
119
|
+
fail-on-critical: true
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The GitHub Action posts findings as **PR comments**, uploads **SARIF for Code Scanning**, and supports **configurable severity thresholds** for merge blocking.
|
|
123
|
+
|
|
124
|
+
### Manual CI Setup
|
|
83
125
|
|
|
84
126
|
```yaml
|
|
85
|
-
# GitHub Actions example
|
|
86
127
|
- name: Run CDK Insights
|
|
87
|
-
run: npx cdk-insights scan --fail-on-critical
|
|
128
|
+
run: npx cdk-insights scan --all --output json --fail-on-critical
|
|
88
129
|
env:
|
|
89
130
|
CDK_INSIGHTS_LICENSE_KEY: ${{ secrets.CDK_INSIGHTS_LICENSE_KEY }}
|
|
90
131
|
```
|
|
@@ -95,19 +136,17 @@ In CI mode, CDK Insights will:
|
|
|
95
136
|
- Skip interactive prompts
|
|
96
137
|
- Exit with code 1 on critical issues (with `--fail-on-critical`)
|
|
97
138
|
|
|
98
|
-
👉 [Full CI/CD Setup Guide →](https://github.com/instancelabs/cdk-insights/blob/main/docs/ci-setup.md)
|
|
99
|
-
|
|
100
139
|
---
|
|
101
140
|
|
|
102
|
-
## ⚙️ Configuration
|
|
141
|
+
## ⚙️ Configuration
|
|
103
142
|
|
|
104
|
-
|
|
143
|
+
Create a `.cdk-insights.json` in your project root, or run:
|
|
105
144
|
|
|
106
145
|
```bash
|
|
107
146
|
npx cdk-insights config setup
|
|
108
147
|
```
|
|
109
148
|
|
|
110
|
-
### Enhanced Analysis
|
|
149
|
+
### CDK Aspect (Enhanced Analysis)
|
|
111
150
|
|
|
112
151
|
For precise file/line metadata and richer context, add the aspect in your CDK app:
|
|
113
152
|
|
|
@@ -123,47 +162,49 @@ app.synth();
|
|
|
123
162
|
|
|
124
163
|
---
|
|
125
164
|
|
|
126
|
-
## 💰
|
|
165
|
+
## 💰 Pricing
|
|
166
|
+
|
|
167
|
+
| Plan | Price | What's Included |
|
|
168
|
+
|------|-------|-----------------|
|
|
169
|
+
| **Free** | £0 forever | Static analysis (100+ rules), JSON/Table/Markdown/SARIF output, multi-stack analysis, CLI access |
|
|
170
|
+
| **Pro** | £9.99/mo | Everything in Free + AI analysis (Bedrock), GitHub integration, dashboard, PDF reports, 10,000 resources/mo |
|
|
171
|
+
| **Team** | £7.99/member/mo | Everything in Pro + team management, shared configs, audit trails, 15,000 resources/member |
|
|
127
172
|
|
|
128
|
-
|
|
173
|
+
Static analysis is **free forever** — no trial, no credit card, no signup required.
|
|
129
174
|
|
|
130
|
-
|
|
131
|
-
- 🚀 **Pro** — AI-powered insights, unlimited scanning, team features
|
|
132
|
-
- 🏢 **Enterprise** — Advanced compliance, unlimited usage, and dedicated support
|
|
175
|
+
The AI tier adds deep analysis via AWS Bedrock: security analysis, findings categorised by Well-Architected Framework pillar, and context-aware recommendations.
|
|
133
176
|
|
|
134
|
-
👉 [View full pricing
|
|
177
|
+
👉 [View full pricing](https://cdkinsights.dev/pricing)
|
|
135
178
|
|
|
136
179
|
---
|
|
137
180
|
|
|
138
181
|
## 🧰 Requirements
|
|
139
182
|
|
|
140
|
-
- Node.js
|
|
183
|
+
- Node.js 22 or later
|
|
141
184
|
- AWS CDK v2 project
|
|
142
185
|
|
|
186
|
+
### Quick Compatibility Check
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
node --version # Should be 22+
|
|
190
|
+
ls cdk.json # Should exist in CDK project
|
|
191
|
+
```
|
|
192
|
+
|
|
143
193
|
---
|
|
144
194
|
|
|
145
195
|
## 🔧 Troubleshooting
|
|
146
196
|
|
|
147
197
|
### Cache Management
|
|
148
198
|
|
|
149
|
-
CDK Insights caches analysis results to speed up subsequent runs:
|
|
150
|
-
|
|
151
199
|
```bash
|
|
152
|
-
# Clear all caches
|
|
153
|
-
npx cdk-insights
|
|
154
|
-
|
|
155
|
-
# Check cache status
|
|
156
|
-
npx cdk-insights cache-status
|
|
157
|
-
|
|
158
|
-
# Run analysis without using cache
|
|
159
|
-
npx cdk-insights scan --no-cache
|
|
200
|
+
npx cdk-insights clear-cache # Clear all caches
|
|
201
|
+
npx cdk-insights cache-status # Check cache status
|
|
202
|
+
npx cdk-insights scan --no-cache # Run without cache
|
|
160
203
|
```
|
|
161
204
|
|
|
162
205
|
### Authentication Issues
|
|
163
206
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
1. Check your license key is correctly set: `echo $CDK_INSIGHTS_LICENSE_KEY`
|
|
207
|
+
1. Check your license key: `echo $CDK_INSIGHTS_LICENSE_KEY`
|
|
167
208
|
2. Clear the auth cache: `npx cdk-insights clear-cache`
|
|
168
209
|
3. Verify your internet connection
|
|
169
210
|
|
|
@@ -172,41 +213,16 @@ If you encounter license validation errors:
|
|
|
172
213
|
CDK Insights detects potentially sensitive data in your CloudFormation templates:
|
|
173
214
|
|
|
174
215
|
```bash
|
|
175
|
-
# Fail on sensitive data
|
|
176
|
-
npx cdk-insights scan --
|
|
177
|
-
|
|
178
|
-
# Warn but continue on sensitive data
|
|
179
|
-
npx cdk-insights scan --warn-sensitive
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
Configure detection in `.cdk-insights.json`:
|
|
183
|
-
|
|
184
|
-
```json
|
|
185
|
-
{
|
|
186
|
-
"sensitiveDataDetection": {
|
|
187
|
-
"enabled": true,
|
|
188
|
-
"warnOnly": false,
|
|
189
|
-
"allowPatterns": ["^test-"],
|
|
190
|
-
"ignoreProperties": ["Description"]
|
|
191
|
-
}
|
|
192
|
-
}
|
|
216
|
+
npx cdk-insights scan --fail-on-critical # Fail on sensitive data (default)
|
|
217
|
+
npx cdk-insights scan --warn-sensitive # Warn but continue
|
|
193
218
|
```
|
|
194
219
|
|
|
195
220
|
---
|
|
196
221
|
|
|
197
|
-
## 📚 Links
|
|
198
|
-
|
|
199
|
-
- [GitHub Repository & Issues](https://github.com/instancelabs/cdk-insights)
|
|
200
|
-
- [Documentation](https://github.com/instancelabs/cdk-insights/tree/main/docs)
|
|
201
|
-
- [Pricing & Tiers](https://cdkinsights.dev/#pricing)
|
|
202
|
-
- License: MIT
|
|
203
|
-
|
|
204
|
-
---
|
|
205
|
-
|
|
206
|
-
Start with:
|
|
207
|
-
|
|
208
|
-
```bash
|
|
209
|
-
npx cdk-insights scan
|
|
210
|
-
```
|
|
222
|
+
## 📚 Links
|
|
211
223
|
|
|
212
|
-
|
|
224
|
+
- **Website:** [cdkinsights.dev](https://cdkinsights.dev)
|
|
225
|
+
- **Documentation:** [cdkinsights.dev/docs](https://cdkinsights.dev/docs)
|
|
226
|
+
- **Pricing:** [cdkinsights.dev/pricing](https://cdkinsights.dev/pricing)
|
|
227
|
+
- **npm:** [npmjs.com/package/cdk-insights](https://www.npmjs.com/package/cdk-insights)
|
|
228
|
+
- **License:** MIT
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnalysisResults, CloudFormationStack, CreateFindingFunction, ServiceName, Severity } from '../../types/analysis.types';
|
|
2
2
|
import type { ConstructMetadata } from './solutionConstructs/loadConstructMetadata';
|
|
3
|
+
import type { CustomRuleDefinition } from '../../rules/customRules.types';
|
|
3
4
|
export type AnalysisStatistics = {
|
|
4
5
|
totalResources: number;
|
|
5
6
|
analyzedResources: number;
|
|
@@ -19,12 +20,14 @@ export type StaticAnalysisOptions = {
|
|
|
19
20
|
deduplicateFindings?: boolean;
|
|
20
21
|
/** Whether to include statistics in result (default: false) */
|
|
21
22
|
includeStatistics?: boolean;
|
|
23
|
+
/** User-defined custom rules to evaluate */
|
|
24
|
+
customRules?: CustomRuleDefinition[];
|
|
22
25
|
};
|
|
23
26
|
export type StaticAnalysisResultWithStats = {
|
|
24
27
|
findings: AnalysisResults;
|
|
25
28
|
statistics: AnalysisStatistics;
|
|
26
29
|
};
|
|
27
|
-
export declare const runStaticAnalysis: (cloudformationTemplate: CloudFormationStack, createFinding: CreateFindingFunction, selectedServices?: ServiceName[], solutionsRegistry?: Record<string, ConstructMetadata
|
|
30
|
+
export declare const runStaticAnalysis: (cloudformationTemplate: CloudFormationStack, createFinding: CreateFindingFunction, selectedServices?: ServiceName[], solutionsRegistry?: Record<string, ConstructMetadata>, customRules?: CustomRuleDefinition[]) => AnalysisResults;
|
|
28
31
|
export declare const runStaticAnalysisWithOptions: (cloudformationTemplate: CloudFormationStack, createFinding: CreateFindingFunction, options?: StaticAnalysisOptions) => StaticAnalysisResultWithStats;
|
|
29
32
|
export type BatchAnalysisResult = {
|
|
30
33
|
results: Record<string, AnalysisResults>;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { UserConfig } from '../types/cli.types';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively strip dangerous keys from an object to prevent prototype pollution.
|
|
4
|
+
*/
|
|
5
|
+
export declare function sanitizeObject<T extends Record<string, unknown>>(obj: T): T;
|
|
2
6
|
export declare const loadUserConfig: () => UserConfig;
|
|
3
7
|
export declare const saveUserConfig: (config: UserConfig) => void;
|
|
4
8
|
export declare const resetUserConfig: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Issue, ServiceName } from '../../types/analysis.types';
|
|
2
|
-
export type OutputFormat = 'json' | 'table' | 'markdown' | 'summary' | 'sarif' | 'github-actions';
|
|
2
|
+
export type OutputFormat = 'json' | 'table' | 'markdown' | 'summary' | 'sarif' | 'github-actions' | 'pdf';
|
|
3
3
|
export interface AnalyzeCommandArgs {
|
|
4
4
|
stackName?: string;
|
|
5
5
|
ci?: boolean;
|
|
@@ -56,6 +56,8 @@ export interface UserConfig {
|
|
|
56
56
|
local?: boolean;
|
|
57
57
|
warnSensitive?: boolean;
|
|
58
58
|
allowSensitive?: boolean;
|
|
59
|
+
/** Disable the interactive feedback prompt after analysis (default: true) */
|
|
60
|
+
feedback?: boolean;
|
|
59
61
|
/** Sensitive data detection configuration */
|
|
60
62
|
sensitiveDataDetection?: SensitiveDataDetectionConfig;
|
|
61
63
|
cache?: {
|