cdk-insights 0.2.0-beta.7 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -10
- package/dist/cli/cacheUtils.d.ts +3 -0
- package/dist/cli/entry.d.ts +1 -2
- package/dist/cli/entry.js +104 -106
- package/dist/index.js +9812 -44732
- package/dist/shared/config/environment.d.ts +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,9 +49,9 @@ npx cdk-insights scan
|
|
|
49
49
|
|
|
50
50
|
**That's it!** CDK Insights will analyze your infrastructure and show you what needs attention.
|
|
51
51
|
|
|
52
|
-
### Adding NPM Scripts for Convenience
|
|
52
|
+
### Adding NPM Scripts for Convenience (Recommended)
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
**We recommend adding these scripts to your `package.json`** for shorter, more convenient commands:
|
|
55
55
|
|
|
56
56
|
```json
|
|
57
57
|
{
|
|
@@ -66,7 +66,7 @@ You can add convenience scripts to your `package.json` to make commands shorter:
|
|
|
66
66
|
}
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
After adding these scripts, you can use shorter commands:
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
72
|
npm run scan # Interactive scan
|
|
@@ -77,6 +77,8 @@ npm run scan:summary # Scan with summary output
|
|
|
77
77
|
npm run scan:with-issues # Scan and create GitHub issues
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
> **💡 Why add scripts?** While `npx cdk-insights scan` works great, adding scripts makes commands shorter and more memorable. It's also the standard way most npm tools are used in projects.
|
|
81
|
+
|
|
80
82
|
## ✨ What CDK Insights Does
|
|
81
83
|
|
|
82
84
|
- **🔍 Static Analysis**: Automatically checks your CDK code for 20+ AWS services
|
|
@@ -103,7 +105,7 @@ npx cdk-insights scan --all
|
|
|
103
105
|
npx cdk-insights scan
|
|
104
106
|
```
|
|
105
107
|
|
|
106
|
-
> **💡 Tip**: After installing CDK Insights, you can use `npx cdk-insights <command>` for all commands.
|
|
108
|
+
> **💡 Tip**: After installing CDK Insights, you can use `npx cdk-insights <command>` for all commands. For convenience, we recommend adding scripts to your `package.json` (see section above) so you can use shorter commands like `npm run scan`.
|
|
107
109
|
|
|
108
110
|
### What You'll See
|
|
109
111
|
|
|
@@ -141,14 +143,16 @@ npx cdk-insights scan
|
|
|
141
143
|
|
|
142
144
|
```bash
|
|
143
145
|
# Focus on critical security issues
|
|
144
|
-
cdk-insights scan --rule-filter Security --output table
|
|
146
|
+
npx cdk-insights scan --rule-filter Security --output table
|
|
147
|
+
# Or if you added scripts: npm run scan
|
|
145
148
|
```
|
|
146
149
|
|
|
147
150
|
**2. Generate a Report for Your Team**
|
|
148
151
|
|
|
149
152
|
```bash
|
|
150
153
|
# Create a markdown report for documentation
|
|
151
|
-
cdk-insights scan --output markdown > security-report.md
|
|
154
|
+
npx cdk-insights scan --output markdown > security-report.md
|
|
155
|
+
# Or if you added scripts: npm run scan:markdown > security-report.md
|
|
152
156
|
```
|
|
153
157
|
|
|
154
158
|
**3. Set Up Regular Checks**
|
|
@@ -705,9 +709,7 @@ CDK Insights offers flexible plans for teams of all sizes:
|
|
|
705
709
|
- **🚀 Pro Tier**: AI-powered insights, unlimited scanning, and team features
|
|
706
710
|
- **🏢 Enterprise**: Advanced compliance, unlimited usage, and dedicated support
|
|
707
711
|
|
|
708
|
-
[**View all plans and pricing →**](https://cdkinsights.dev
|
|
709
|
-
|
|
710
|
-
[**Start free →**](https://cdkinsights.dev/signup) | [**Contact sales →**](https://cdkinsights.dev/enterprise)
|
|
712
|
+
[**View all plans and pricing →**](https://cdkinsights.dev/#pricing)
|
|
711
713
|
|
|
712
714
|
## 📄 License
|
|
713
715
|
|
|
@@ -715,4 +717,6 @@ CDK Insights is licensed under the MIT License. Some functionality integrates wi
|
|
|
715
717
|
|
|
716
718
|
---
|
|
717
719
|
|
|
718
|
-
**Ready to improve your CDK infrastructure?** Start with `npx cdk-insights scan` and discover what insights await!
|
|
720
|
+
**Ready to improve your CDK infrastructure?** Start with `npx cdk-insights scan` and discover what insights await!
|
|
721
|
+
|
|
722
|
+
> 💡 **Pro tip**: Add the convenience scripts to your `package.json` (see above) for shorter commands like `npm run scan` 🚀
|
package/dist/cli/entry.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const setGlobalCache: (cache: FileBasedCache<unknown>) => void;
|
|
1
|
+
export {};
|
package/dist/cli/entry.js
CHANGED
|
@@ -70795,11 +70795,6 @@ var require_emoji_regex2 = __commonJS({
|
|
|
70795
70795
|
});
|
|
70796
70796
|
|
|
70797
70797
|
// src/cli/entry.ts
|
|
70798
|
-
var entry_exports = {};
|
|
70799
|
-
__export(entry_exports, {
|
|
70800
|
-
setGlobalCache: () => setGlobalCache
|
|
70801
|
-
});
|
|
70802
|
-
module.exports = __toCommonJS(entry_exports);
|
|
70803
70798
|
var import_dotenv2 = __toESM(require_main());
|
|
70804
70799
|
var import_node_child_process6 = require("node:child_process");
|
|
70805
70800
|
var path12 = __toESM(require("node:path"));
|
|
@@ -83190,68 +83185,71 @@ var isGeneratedByCDK = (cdkPath, constructType) => {
|
|
|
83190
83185
|
};
|
|
83191
83186
|
var enrichRecommendations = (originalMap, pathToLogicalId, unifiedResourceMap, stack, resourceIdMetadata) => {
|
|
83192
83187
|
const manifest = loadManifest("cdk.out");
|
|
83193
|
-
return Object.entries(originalMap).reduce(
|
|
83194
|
-
|
|
83195
|
-
|
|
83196
|
-
|
|
83197
|
-
|
|
83198
|
-
|
|
83199
|
-
|
|
83200
|
-
|
|
83201
|
-
|
|
83202
|
-
|
|
83203
|
-
|
|
83204
|
-
|
|
83205
|
-
|
|
83206
|
-
|
|
83207
|
-
|
|
83208
|
-
|
|
83209
|
-
|
|
83210
|
-
|
|
83211
|
-
|
|
83212
|
-
|
|
83213
|
-
|
|
83214
|
-
|
|
83215
|
-
|
|
83216
|
-
|
|
83217
|
-
|
|
83218
|
-
|
|
83219
|
-
|
|
83220
|
-
|
|
83221
|
-
|
|
83222
|
-
|
|
83223
|
-
|
|
83224
|
-
|
|
83225
|
-
|
|
83226
|
-
|
|
83227
|
-
|
|
83228
|
-
|
|
83229
|
-
|
|
83230
|
-
|
|
83231
|
-
|
|
83232
|
-
|
|
83233
|
-
|
|
83234
|
-
|
|
83235
|
-
|
|
83236
|
-
|
|
83237
|
-
|
|
83238
|
-
|
|
83239
|
-
|
|
83240
|
-
|
|
83241
|
-
|
|
83242
|
-
|
|
83243
|
-
|
|
83244
|
-
|
|
83245
|
-
|
|
83246
|
-
|
|
83247
|
-
|
|
83248
|
-
|
|
83249
|
-
|
|
83250
|
-
|
|
83251
|
-
|
|
83252
|
-
|
|
83253
|
-
|
|
83254
|
-
|
|
83188
|
+
return Object.entries(originalMap).reduce(
|
|
83189
|
+
(acc, [resourceId, group]) => {
|
|
83190
|
+
const cdkPath = Object.keys(pathToLogicalId).find(
|
|
83191
|
+
(p3) => pathToLogicalId[p3] === resourceId
|
|
83192
|
+
) ?? group.cdkPath;
|
|
83193
|
+
const constructType = unifiedResourceMap[resourceId]?.__constructType ?? stack.Resources[resourceId]?.Type ?? "";
|
|
83194
|
+
const githubUrl = resourceIdMetadata[resourceId]?.githubUrl;
|
|
83195
|
+
const docUrl = resourceIdMetadata[resourceId]?.docUrl;
|
|
83196
|
+
const constructName = resourceIdMetadata[resourceId]?.constructName;
|
|
83197
|
+
const isGenerated = isGeneratedByCDK(cdkPath, constructType);
|
|
83198
|
+
const displayName = unifiedResourceMap[resourceId]?.displayName;
|
|
83199
|
+
const friendlyName = displayName ?? unifiedResourceMap[resourceId]?.__friendlyName ?? cdkPath.split("/").pop() ?? resourceId;
|
|
83200
|
+
const locationHint = displayName ?? cdkPath ?? group.locationHint;
|
|
83201
|
+
const enhancedFileHint = findEnhancedFileFromPath(manifest, resourceId);
|
|
83202
|
+
const allIssues = [
|
|
83203
|
+
...group.sources.cdkInsights.issues,
|
|
83204
|
+
...group.sources.cdkNag.issues
|
|
83205
|
+
].map((issue) => ({
|
|
83206
|
+
...issue,
|
|
83207
|
+
locationHint,
|
|
83208
|
+
githubUrl,
|
|
83209
|
+
docUrl,
|
|
83210
|
+
constructName,
|
|
83211
|
+
// Add source location if available
|
|
83212
|
+
...enhancedFileHint?.filePath && {
|
|
83213
|
+
sourceLocation: {
|
|
83214
|
+
filePath: enhancedFileHint.filePath,
|
|
83215
|
+
line: enhancedFileHint.line || 1,
|
|
83216
|
+
column: enhancedFileHint.column || 1,
|
|
83217
|
+
confidence: enhancedFileHint.confidence || "low"
|
|
83218
|
+
}
|
|
83219
|
+
},
|
|
83220
|
+
// Add additional metadata
|
|
83221
|
+
stackName: enhancedFileHint?.stackName,
|
|
83222
|
+
stackId: enhancedFileHint?.stackName,
|
|
83223
|
+
// Using stackName as stackId for now
|
|
83224
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
83225
|
+
}));
|
|
83226
|
+
const cdkInsightsIssues = allIssues.filter(
|
|
83227
|
+
(issue) => issue.foundBy !== "cdkNag"
|
|
83228
|
+
);
|
|
83229
|
+
const cdkNagIssues = allIssues.filter(
|
|
83230
|
+
(issue) => issue.foundBy === "cdkNag"
|
|
83231
|
+
);
|
|
83232
|
+
acc[resourceId] = {
|
|
83233
|
+
...group,
|
|
83234
|
+
resourceId,
|
|
83235
|
+
displayName,
|
|
83236
|
+
cdkPath,
|
|
83237
|
+
friendlyName,
|
|
83238
|
+
locationHint,
|
|
83239
|
+
constructName,
|
|
83240
|
+
githubUrl,
|
|
83241
|
+
docUrl,
|
|
83242
|
+
isGenerated,
|
|
83243
|
+
type: constructType,
|
|
83244
|
+
sources: {
|
|
83245
|
+
cdkInsights: { issues: cdkInsightsIssues },
|
|
83246
|
+
cdkNag: { issues: cdkNagIssues }
|
|
83247
|
+
}
|
|
83248
|
+
};
|
|
83249
|
+
return acc;
|
|
83250
|
+
},
|
|
83251
|
+
{}
|
|
83252
|
+
);
|
|
83255
83253
|
};
|
|
83256
83254
|
|
|
83257
83255
|
// src/helpers/extractInlineNagFindings/nagToWAFMap.ts
|
|
@@ -84698,7 +84696,10 @@ var TerminalOutput = class _TerminalOutput {
|
|
|
84698
84696
|
const trialDuration = trialEnd - trialStart;
|
|
84699
84697
|
const elapsed = now - trialStart;
|
|
84700
84698
|
const remaining = trialEnd - now;
|
|
84701
|
-
const trialProgress = Math.max(
|
|
84699
|
+
const trialProgress = Math.max(
|
|
84700
|
+
0,
|
|
84701
|
+
Math.min(100, elapsed / trialDuration * 100)
|
|
84702
|
+
);
|
|
84702
84703
|
const trialFilledBars = Math.round(trialProgress / 100 * barWidth);
|
|
84703
84704
|
const trialEmptyBars = Math.max(0, barWidth - trialFilledBars);
|
|
84704
84705
|
const trialProgressBar = "\u2588".repeat(trialFilledBars) + "\u2591".repeat(trialEmptyBars);
|
|
@@ -89783,10 +89784,13 @@ var runStaticAnalysis = (cloudformationTemplate, createFinding2, selectedService
|
|
|
89783
89784
|
const resourceFilter = createResourceFilter(selectedServices);
|
|
89784
89785
|
const userResources = Object.entries(cloudformationTemplate.Resources || {}).filter(
|
|
89785
89786
|
([, cloudFormationResource]) => resourceFilter(cloudFormationResource)
|
|
89786
|
-
).reduce(
|
|
89787
|
-
accumulatedResources[resourceId]
|
|
89788
|
-
|
|
89789
|
-
|
|
89787
|
+
).reduce(
|
|
89788
|
+
(accumulatedResources, [resourceId, cloudFormationResource]) => {
|
|
89789
|
+
accumulatedResources[resourceId] = cloudFormationResource;
|
|
89790
|
+
return accumulatedResources;
|
|
89791
|
+
},
|
|
89792
|
+
{}
|
|
89793
|
+
);
|
|
89790
89794
|
for (const serviceName of servicesToAnalyze) {
|
|
89791
89795
|
try {
|
|
89792
89796
|
const serviceCheckFunction = serviceChecks[serviceName];
|
|
@@ -91106,6 +91110,33 @@ var AnalysisProgressHandler = class _AnalysisProgressHandler {
|
|
|
91106
91110
|
};
|
|
91107
91111
|
var analysisProgress = AnalysisProgressHandler.getInstance();
|
|
91108
91112
|
|
|
91113
|
+
// src/cli/cacheUtils.ts
|
|
91114
|
+
var globalAnalysisCache = null;
|
|
91115
|
+
var setGlobalCache = (cache3) => {
|
|
91116
|
+
globalAnalysisCache = cache3;
|
|
91117
|
+
};
|
|
91118
|
+
var handleProcessExit = () => {
|
|
91119
|
+
if (globalAnalysisCache && !process.env.CI) {
|
|
91120
|
+
try {
|
|
91121
|
+
globalAnalysisCache.saveToDisk();
|
|
91122
|
+
cliLogger.info("\u{1F4BE} Cache saved to disk on exit");
|
|
91123
|
+
} catch (error2) {
|
|
91124
|
+
cliLogger.warn("\u26A0\uFE0F Could not save cache on exit", {
|
|
91125
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
91126
|
+
});
|
|
91127
|
+
}
|
|
91128
|
+
}
|
|
91129
|
+
};
|
|
91130
|
+
process.on("exit", handleProcessExit);
|
|
91131
|
+
process.on("SIGINT", () => {
|
|
91132
|
+
handleProcessExit();
|
|
91133
|
+
process.exit(0);
|
|
91134
|
+
});
|
|
91135
|
+
process.on("SIGTERM", () => {
|
|
91136
|
+
handleProcessExit();
|
|
91137
|
+
process.exit(0);
|
|
91138
|
+
});
|
|
91139
|
+
|
|
91109
91140
|
// src/cli/analysisJob.ts
|
|
91110
91141
|
var DEFAULT_CONCURRENCY_CONFIG = {
|
|
91111
91142
|
maxConcurrent: 5,
|
|
@@ -91887,11 +91918,7 @@ var createGithubIssue = async ({
|
|
|
91887
91918
|
if (gistUrl) {
|
|
91888
91919
|
terminal.githubGistCreated(gistUrl);
|
|
91889
91920
|
if (recommendations && summary) {
|
|
91890
|
-
bodyToWrite = generateMarkdownSummary(
|
|
91891
|
-
stackName,
|
|
91892
|
-
summary,
|
|
91893
|
-
gistUrl
|
|
91894
|
-
);
|
|
91921
|
+
bodyToWrite = generateMarkdownSummary(stackName, summary, gistUrl);
|
|
91895
91922
|
} else {
|
|
91896
91923
|
const summarySection = issueBody.split("\n---\n")[0];
|
|
91897
91924
|
bodyToWrite = `${summarySection}
|
|
@@ -94364,31 +94391,6 @@ var CONFIG_FIELDS = {
|
|
|
94364
94391
|
validation: "JSON object with enabled (boolean), ttl (number), maxSize (number)"
|
|
94365
94392
|
}
|
|
94366
94393
|
};
|
|
94367
|
-
var globalAnalysisCache = null;
|
|
94368
|
-
var setGlobalCache = (cache3) => {
|
|
94369
|
-
globalAnalysisCache = cache3;
|
|
94370
|
-
};
|
|
94371
|
-
var handleProcessExit = () => {
|
|
94372
|
-
if (globalAnalysisCache && !process.env.CI) {
|
|
94373
|
-
try {
|
|
94374
|
-
globalAnalysisCache.saveToDisk();
|
|
94375
|
-
cliLogger.info("\u{1F4BE} Cache saved to disk on exit");
|
|
94376
|
-
} catch (error2) {
|
|
94377
|
-
cliLogger.warn("\u26A0\uFE0F Could not save cache on exit", {
|
|
94378
|
-
error: error2 instanceof Error ? error2.message : String(error2)
|
|
94379
|
-
});
|
|
94380
|
-
}
|
|
94381
|
-
}
|
|
94382
|
-
};
|
|
94383
|
-
process.on("exit", handleProcessExit);
|
|
94384
|
-
process.on("SIGINT", () => {
|
|
94385
|
-
handleProcessExit();
|
|
94386
|
-
process.exit(0);
|
|
94387
|
-
});
|
|
94388
|
-
process.on("SIGTERM", () => {
|
|
94389
|
-
handleProcessExit();
|
|
94390
|
-
process.exit(0);
|
|
94391
|
-
});
|
|
94392
94394
|
var showConfigFieldHelp = (fieldName) => {
|
|
94393
94395
|
const field = CONFIG_FIELDS[fieldName];
|
|
94394
94396
|
if (!field) {
|
|
@@ -94781,10 +94783,6 @@ var setupCLI = () => {
|
|
|
94781
94783
|
).demandCommand(1, "Please specify a command.").strict().help().wrap(null).epilog(createHelpTable()).parse();
|
|
94782
94784
|
};
|
|
94783
94785
|
setupCLI();
|
|
94784
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
94785
|
-
0 && (module.exports = {
|
|
94786
|
-
setGlobalCache
|
|
94787
|
-
});
|
|
94788
94786
|
/*! Bundled license information:
|
|
94789
94787
|
|
|
94790
94788
|
tmp/lib/tmp.js:
|