cdk-insights 0.2.0-beta.8 → 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 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
- You can add convenience scripts to your `package.json` to make commands shorter:
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
- Then you can run:
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. You can also add convenience scripts to your `package.json` (see section above).
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**
@@ -713,4 +717,6 @@ CDK Insights is licensed under the MIT License. Some functionality integrates wi
713
717
 
714
718
  ---
715
719
 
716
- **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.js CHANGED
@@ -83185,68 +83185,71 @@ var isGeneratedByCDK = (cdkPath, constructType) => {
83185
83185
  };
83186
83186
  var enrichRecommendations = (originalMap, pathToLogicalId, unifiedResourceMap, stack, resourceIdMetadata) => {
83187
83187
  const manifest = loadManifest("cdk.out");
83188
- return Object.entries(originalMap).reduce((acc, [resourceId, group]) => {
83189
- const cdkPath = Object.keys(pathToLogicalId).find(
83190
- (p3) => pathToLogicalId[p3] === resourceId
83191
- ) ?? group.cdkPath;
83192
- const constructType = unifiedResourceMap[resourceId]?.__constructType ?? stack.Resources[resourceId]?.Type ?? "";
83193
- const githubUrl = resourceIdMetadata[resourceId]?.githubUrl;
83194
- const docUrl = resourceIdMetadata[resourceId]?.docUrl;
83195
- const constructName = resourceIdMetadata[resourceId]?.constructName;
83196
- const isGenerated = isGeneratedByCDK(cdkPath, constructType);
83197
- const displayName = unifiedResourceMap[resourceId]?.displayName;
83198
- const friendlyName = displayName ?? unifiedResourceMap[resourceId]?.__friendlyName ?? cdkPath.split("/").pop() ?? resourceId;
83199
- const locationHint = displayName ?? cdkPath ?? group.locationHint;
83200
- const enhancedFileHint = findEnhancedFileFromPath(manifest, resourceId);
83201
- const allIssues = [
83202
- ...group.sources.cdkInsights.issues,
83203
- ...group.sources.cdkNag.issues
83204
- ].map((issue) => ({
83205
- ...issue,
83206
- locationHint,
83207
- githubUrl,
83208
- docUrl,
83209
- constructName,
83210
- // Add source location if available
83211
- ...enhancedFileHint?.filePath && {
83212
- sourceLocation: {
83213
- filePath: enhancedFileHint.filePath,
83214
- line: enhancedFileHint.line || 1,
83215
- column: enhancedFileHint.column || 1,
83216
- confidence: enhancedFileHint.confidence || "low"
83217
- }
83218
- },
83219
- // Add additional metadata
83220
- stackName: enhancedFileHint?.stackName,
83221
- stackId: enhancedFileHint?.stackName,
83222
- // Using stackName as stackId for now
83223
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
83224
- }));
83225
- const cdkInsightsIssues = allIssues.filter(
83226
- (issue) => issue.foundBy !== "cdkNag"
83227
- );
83228
- const cdkNagIssues = allIssues.filter(
83229
- (issue) => issue.foundBy === "cdkNag"
83230
- );
83231
- acc[resourceId] = {
83232
- ...group,
83233
- resourceId,
83234
- displayName,
83235
- cdkPath,
83236
- friendlyName,
83237
- locationHint,
83238
- constructName,
83239
- githubUrl,
83240
- docUrl,
83241
- isGenerated,
83242
- type: constructType,
83243
- sources: {
83244
- cdkInsights: { issues: cdkInsightsIssues },
83245
- cdkNag: { issues: cdkNagIssues }
83246
- }
83247
- };
83248
- return acc;
83249
- }, {});
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
+ );
83250
83253
  };
83251
83254
 
83252
83255
  // src/helpers/extractInlineNagFindings/nagToWAFMap.ts
@@ -84693,7 +84696,10 @@ var TerminalOutput = class _TerminalOutput {
84693
84696
  const trialDuration = trialEnd - trialStart;
84694
84697
  const elapsed = now - trialStart;
84695
84698
  const remaining = trialEnd - now;
84696
- const trialProgress = Math.max(0, Math.min(100, elapsed / trialDuration * 100));
84699
+ const trialProgress = Math.max(
84700
+ 0,
84701
+ Math.min(100, elapsed / trialDuration * 100)
84702
+ );
84697
84703
  const trialFilledBars = Math.round(trialProgress / 100 * barWidth);
84698
84704
  const trialEmptyBars = Math.max(0, barWidth - trialFilledBars);
84699
84705
  const trialProgressBar = "\u2588".repeat(trialFilledBars) + "\u2591".repeat(trialEmptyBars);
@@ -89778,10 +89784,13 @@ var runStaticAnalysis = (cloudformationTemplate, createFinding2, selectedService
89778
89784
  const resourceFilter = createResourceFilter(selectedServices);
89779
89785
  const userResources = Object.entries(cloudformationTemplate.Resources || {}).filter(
89780
89786
  ([, cloudFormationResource]) => resourceFilter(cloudFormationResource)
89781
- ).reduce((accumulatedResources, [resourceId, cloudFormationResource]) => {
89782
- accumulatedResources[resourceId] = cloudFormationResource;
89783
- return accumulatedResources;
89784
- }, {});
89787
+ ).reduce(
89788
+ (accumulatedResources, [resourceId, cloudFormationResource]) => {
89789
+ accumulatedResources[resourceId] = cloudFormationResource;
89790
+ return accumulatedResources;
89791
+ },
89792
+ {}
89793
+ );
89785
89794
  for (const serviceName of servicesToAnalyze) {
89786
89795
  try {
89787
89796
  const serviceCheckFunction = serviceChecks[serviceName];
@@ -91909,11 +91918,7 @@ var createGithubIssue = async ({
91909
91918
  if (gistUrl) {
91910
91919
  terminal.githubGistCreated(gistUrl);
91911
91920
  if (recommendations && summary) {
91912
- bodyToWrite = generateMarkdownSummary(
91913
- stackName,
91914
- summary,
91915
- gistUrl
91916
- );
91921
+ bodyToWrite = generateMarkdownSummary(stackName, summary, gistUrl);
91917
91922
  } else {
91918
91923
  const summarySection = issueBody.split("\n---\n")[0];
91919
91924
  bodyToWrite = `${summarySection}
package/dist/index.js CHANGED
@@ -54753,10 +54753,13 @@ var runStaticAnalysis = (cloudformationTemplate, createFinding2, selectedService
54753
54753
  const resourceFilter = createResourceFilter(selectedServices);
54754
54754
  const userResources = Object.entries(cloudformationTemplate.Resources || {}).filter(
54755
54755
  ([, cloudFormationResource]) => resourceFilter(cloudFormationResource)
54756
- ).reduce((accumulatedResources, [resourceId, cloudFormationResource]) => {
54757
- accumulatedResources[resourceId] = cloudFormationResource;
54758
- return accumulatedResources;
54759
- }, {});
54756
+ ).reduce(
54757
+ (accumulatedResources, [resourceId, cloudFormationResource]) => {
54758
+ accumulatedResources[resourceId] = cloudFormationResource;
54759
+ return accumulatedResources;
54760
+ },
54761
+ {}
54762
+ );
54760
54763
  for (const serviceName of servicesToAnalyze) {
54761
54764
  try {
54762
54765
  const serviceCheckFunction = serviceChecks[serviceName];
@@ -57580,7 +57583,10 @@ var TerminalOutput = class _TerminalOutput {
57580
57583
  const trialDuration = trialEnd - trialStart;
57581
57584
  const elapsed = now - trialStart;
57582
57585
  const remaining = trialEnd - now;
57583
- const trialProgress = Math.max(0, Math.min(100, elapsed / trialDuration * 100));
57586
+ const trialProgress = Math.max(
57587
+ 0,
57588
+ Math.min(100, elapsed / trialDuration * 100)
57589
+ );
57584
57590
  const trialFilledBars = Math.round(trialProgress / 100 * barWidth);
57585
57591
  const trialEmptyBars = Math.max(0, barWidth - trialFilledBars);
57586
57592
  const trialProgressBar = "\u2588".repeat(trialFilledBars) + "\u2591".repeat(trialEmptyBars);
@@ -58465,11 +58471,7 @@ var createGithubIssue = async ({
58465
58471
  if (gistUrl) {
58466
58472
  terminal2.githubGistCreated(gistUrl);
58467
58473
  if (recommendations && summary) {
58468
- bodyToWrite = generateMarkdownSummary(
58469
- stackName,
58470
- summary,
58471
- gistUrl
58472
- );
58474
+ bodyToWrite = generateMarkdownSummary(stackName, summary, gistUrl);
58473
58475
  } else {
58474
58476
  const summarySection = issueBody.split("\n---\n")[0];
58475
58477
  bodyToWrite = `${summarySection}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdk-insights",
3
- "version": "0.2.0-beta.8",
3
+ "version": "0.3.0",
4
4
  "description": "AWS CDK security and cost analysis tool with AI-powered insights",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",