@aws/nx-plugin 0.49.0 → 0.50.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 (137) hide show
  1. package/generators.json +22 -1
  2. package/package.json +1 -1
  3. package/sdk/ts.d.ts +2 -0
  4. package/sdk/ts.js +6 -3
  5. package/sdk/ts.js.map +1 -1
  6. package/src/api-connection/generator.d.ts +2 -2
  7. package/src/api-connection/generator.js +20 -0
  8. package/src/api-connection/generator.js.map +1 -1
  9. package/src/infra/app/__snapshots__/generator.spec.ts.snap +124 -14
  10. package/src/infra/app/files/app/README.md.template +5 -5
  11. package/src/infra/app/files/app/checkov.yml.template +12 -0
  12. package/src/infra/app/files/app/src/main.ts.template +2 -4
  13. package/src/infra/app/generator.js +13 -8
  14. package/src/infra/app/generator.js.map +1 -1
  15. package/src/infra/app/schema.d.ts +0 -8
  16. package/src/infra/app/schema.json +0 -16
  17. package/src/license/config.js +3 -3
  18. package/src/license/config.js.map +1 -1
  19. package/src/open-api/ts-hooks/__snapshots__/generator.spec.tsx.snap +114 -0
  20. package/src/open-api/ts-hooks/generator.spec.tsx +176 -0
  21. package/src/open-api/utils/codegen-data.js +42 -5
  22. package/src/open-api/utils/codegen-data.js.map +1 -1
  23. package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
  24. package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +55 -2
  25. package/src/py/fast-api/generator.js +8 -55
  26. package/src/py/fast-api/generator.js.map +1 -1
  27. package/src/py/fast-api/react/generator.js +9 -111
  28. package/src/py/fast-api/react/generator.js.map +1 -1
  29. package/src/py/lambda-function/generator.js +1 -1
  30. package/src/py/lambda-function/generator.js.map +1 -1
  31. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +3 -2
  32. package/src/py/mcp-server/generator.js +1 -1
  33. package/src/py/mcp-server/generator.js.map +1 -1
  34. package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +3 -2
  35. package/src/py/strands-agent/generator.js +1 -1
  36. package/src/py/strands-agent/generator.js.map +1 -1
  37. package/src/smithy/project/__snapshots__/generator.spec.ts.snap +576 -0
  38. package/src/smithy/project/files/build.Dockerfile.template +97 -0
  39. package/src/smithy/project/files/smithy-build.json.template +25 -0
  40. package/src/smithy/project/files/src/main.smithy.template +19 -0
  41. package/src/smithy/project/files/src/operations/echo.smithy.template +18 -0
  42. package/src/smithy/project/generator.d.ts +10 -0
  43. package/src/smithy/project/generator.js +70 -0
  44. package/src/smithy/project/generator.js.map +1 -0
  45. package/src/smithy/project/schema.d.ts +11 -0
  46. package/src/smithy/project/schema.json +42 -0
  47. package/src/smithy/react-connection/__snapshots__/generator.spec.ts.snap +270 -0
  48. package/src/smithy/react-connection/files/model/extensions.smithy.template +33 -0
  49. package/src/smithy/react-connection/generator.d.ts +10 -0
  50. package/src/smithy/react-connection/generator.js +100 -0
  51. package/src/smithy/react-connection/generator.js.map +1 -0
  52. package/src/smithy/react-connection/schema.d.ts +8 -0
  53. package/src/smithy/react-connection/schema.json +26 -0
  54. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +3023 -0
  55. package/src/smithy/ts/api/files/context.ts.template +12 -0
  56. package/src/smithy/ts/api/files/handler.ts.template +50 -0
  57. package/src/smithy/ts/api/files/index.ts.template +0 -0
  58. package/src/smithy/ts/api/files/local-server.ts.template +41 -0
  59. package/src/smithy/ts/api/files/operations/echo.ts.template +7 -0
  60. package/src/smithy/ts/api/files/service.ts.template +8 -0
  61. package/src/smithy/ts/api/generator.d.ts +10 -0
  62. package/src/smithy/ts/api/generator.js +154 -0
  63. package/src/smithy/ts/api/generator.js.map +1 -0
  64. package/src/smithy/ts/api/schema.d.ts +14 -0
  65. package/src/smithy/ts/api/schema.json +56 -0
  66. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +61 -2
  67. package/src/trpc/backend/generator.js +6 -20
  68. package/src/trpc/backend/generator.js.map +1 -1
  69. package/src/trpc/backend/schema.d.ts +2 -1
  70. package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +3 -3
  71. package/src/ts/lambda-function/generator.js +10 -10
  72. package/src/ts/lambda-function/generator.js.map +1 -1
  73. package/src/ts/lib/eslint.d.ts +7 -0
  74. package/src/ts/lib/eslint.js +37 -29
  75. package/src/ts/lib/eslint.js.map +1 -1
  76. package/src/ts/lib/generator.js +2 -2
  77. package/src/ts/lib/generator.js.map +1 -1
  78. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +3 -2
  79. package/src/ts/mcp-server/files/Dockerfile.template +1 -1
  80. package/src/ts/mcp-server/generator.js +20 -14
  81. package/src/ts/mcp-server/generator.js.map +1 -1
  82. package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +6 -6
  83. package/src/ts/nx-generator/generator.js +3 -2
  84. package/src/ts/nx-generator/generator.js.map +1 -1
  85. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +264 -3
  86. package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +10 -0
  87. package/src/utils/__snapshots__/shared-constructs.spec.ts.snap +49 -0
  88. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +1 -1
  89. package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +1 -1
  90. package/src/utils/api-connection/open-api/react.d.ts +43 -0
  91. package/src/utils/api-connection/open-api/react.js +132 -0
  92. package/src/utils/api-connection/open-api/react.js.map +1 -0
  93. package/src/utils/api-constructs/api-constructs.d.ts +6 -2
  94. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  95. package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +4 -4
  96. package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +7 -4
  97. package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +37 -2
  98. package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +15 -0
  99. package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -1
  100. package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -1
  101. package/src/utils/api-constructs/open-api-metadata.d.ts +17 -0
  102. package/src/utils/api-constructs/open-api-metadata.js +68 -0
  103. package/src/utils/api-constructs/open-api-metadata.js.map +1 -0
  104. package/src/utils/bundle/bundle.d.ts +35 -0
  105. package/src/utils/bundle/bundle.js +107 -0
  106. package/src/utils/bundle/bundle.js.map +1 -0
  107. package/src/utils/bundle/files/ts/rolldown.config.ts.template +3 -0
  108. package/src/utils/files/common/constructs/src/core/checkov.ts.template +44 -0
  109. package/src/utils/files/common/constructs/src/core/index.ts.template +1 -0
  110. package/src/utils/fs.d.ts +16 -0
  111. package/src/utils/fs.js +32 -0
  112. package/src/utils/fs.js.map +1 -0
  113. package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +8 -0
  114. package/src/utils/nx.d.ts +10 -3
  115. package/src/utils/nx.js +18 -3
  116. package/src/utils/nx.js.map +1 -1
  117. package/src/utils/versions.d.ts +6 -2
  118. package/src/utils/versions.js +5 -1
  119. package/src/utils/versions.js.map +1 -1
  120. package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +56 -2
  121. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/aws-prototyping.guard +0 -1282
  122. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/cfn-nag.guard +0 -6839
  123. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/hipaa-security.guard +0 -2807
  124. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/nist-csf.guard +0 -2585
  125. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/pci-dss-3-2-1.guard +0 -2236
  126. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-reliability-pillar.guard +0 -885
  127. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-security-pillar.guard +0 -2205
  128. package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +0 -67
  129. package/src/utils/bundle.d.ts +0 -16
  130. package/src/utils/bundle.js +0 -48
  131. package/src/utils/bundle.js.map +0 -1
  132. package/src/utils/esbuild.d.ts +0 -15
  133. package/src/utils/esbuild.js +0 -46
  134. package/src/utils/esbuild.js.map +0 -1
  135. /package/src/{py/fast-api/react/files/website → utils/api-connection/open-api/files}/components/__apiNameClassName__Provider.tsx.template +0 -0
  136. /package/src/{py/fast-api/react/files/website → utils/api-connection/open-api/files}/hooks/use__apiNameClassName__.tsx.template +0 -0
  137. /package/src/{py/fast-api/react/files/website → utils/api-connection/open-api/files}/hooks/use__apiNameClassName__Client.tsx.template +0 -0
@@ -1259,9 +1259,58 @@ class MetricsAspect implements IAspect {
1259
1259
  "
1260
1260
  `;
1261
1261
 
1262
+ exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/src/core/checkov.ts 1`] = `
1263
+ "import { IConstruct } from 'constructs';
1264
+ import { CfnResource } from 'aws-cdk-lib';
1265
+
1266
+ /**
1267
+ * Suppresses a set of rules for a construct tree.
1268
+ *
1269
+ * @param construct The root construct to suppress the rule for.
1270
+ * @param ids The ids of the rules to suppress.
1271
+ * @param comment The reason for suppressing the rule
1272
+ * @param predicate A predicate function that determines whether the rule should be suppressed for the given construct or any of its descendants.
1273
+ *
1274
+ * @example
1275
+ * The following example suppresses the CKV_AWS_XXX rule for the given construct.
1276
+ * suppressRules(construct, ['CKV_AWS_XXX'], 'Not required for this use case')
1277
+ *
1278
+ * @example
1279
+ * The following example suppresses the CKV_AWS_XXX rule for the construct or any of its descendants if it is an instance of Bucket:
1280
+ * suppressRules(construct, ['CKV_AWS_XXX'], 'Not required for this use case', (construct) => construct instanceof Bucket)
1281
+ */
1282
+ export const suppressRules = (
1283
+ construct: IConstruct,
1284
+ ids: string[],
1285
+ comment: string,
1286
+ predicate?: (construct: IConstruct) => boolean,
1287
+ ) => {
1288
+ const resources = (
1289
+ predicate ? construct.node.findAll().filter(predicate) : [construct]
1290
+ )
1291
+ .map((resource) => {
1292
+ if (CfnResource.isCfnResource(resource)) {
1293
+ return resource;
1294
+ } else return resource.node.defaultChild;
1295
+ })
1296
+ .filter((resource) => CfnResource.isCfnResource(resource));
1297
+
1298
+ resources.forEach((resource) => {
1299
+ const metadata = resource.getMetadata('checkov') || {};
1300
+ metadata['skip'] = [
1301
+ ...(metadata['skip'] ?? []),
1302
+ ...ids.map((id) => ({ id, comment })),
1303
+ ];
1304
+ resource.addMetadata('checkov', metadata);
1305
+ });
1306
+ };
1307
+ "
1308
+ `;
1309
+
1262
1310
  exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/src/core/index.ts 1`] = `
1263
1311
  "export * from './static-website.js';
1264
1312
  export * from './app.js';
1313
+ export * from './checkov.js';
1265
1314
  export * from './runtime-config.js';
1266
1315
  "
1267
1316
  `;
@@ -1301,7 +1350,7 @@ export class RuntimeConfig extends Construct {
1301
1350
  `;
1302
1351
 
1303
1352
  exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/src/core/static-website.ts 1`] = `
1304
- "import { CfnOutput, RemovalPolicy, Stack } from 'aws-cdk-lib';
1353
+ "import { CfnOutput, CfnResource, RemovalPolicy, Stack } from 'aws-cdk-lib';
1305
1354
  import { Distribution, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';
1306
1355
  import { S3BucketOrigin } from 'aws-cdk-lib/aws-cloudfront-origins';
1307
1356
  import {
@@ -1316,6 +1365,8 @@ import { Construct } from 'constructs';
1316
1365
  import { RuntimeConfig } from './runtime-config.js';
1317
1366
  import { Key } from 'aws-cdk-lib/aws-kms';
1318
1367
  import { CfnWebACL } from 'aws-cdk-lib/aws-wafv2';
1368
+ import { suppressRules } from './checkov.js';
1369
+
1319
1370
  const DEFAULT_RUNTIME_CONFIG_FILENAME = 'runtime-config.json';
1320
1371
 
1321
1372
  export interface StaticWebsiteProps {
@@ -1362,6 +1413,17 @@ export class StaticWebsite extends Construct {
1362
1413
  publicReadAccess: false,
1363
1414
  blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
1364
1415
  });
1416
+ suppressRules(
1417
+ accessLogsBucket,
1418
+ ['CKV_AWS_21'],
1419
+ 'Access log bucket does not need versioning enabled',
1420
+ );
1421
+ suppressRules(
1422
+ accessLogsBucket,
1423
+ ['CKV_AWS_18'],
1424
+ 'Access log bucket does not need an access log bucket',
1425
+ );
1426
+
1365
1427
  // S3 Bucket to hold website files
1366
1428
  this.websiteBucket = new Bucket(this, 'WebsiteBucket', {
1367
1429
  versioned: true,
@@ -1392,6 +1454,12 @@ export class StaticWebsite extends Construct {
1392
1454
  serverAccessLogsPrefix: 'distribution-access-logs',
1393
1455
  serverAccessLogsBucket: accessLogsBucket,
1394
1456
  });
1457
+ suppressRules(
1458
+ logBucket,
1459
+ ['CKV_AWS_21'],
1460
+ 'Distribution log bucket does not need versioning enabled',
1461
+ );
1462
+
1395
1463
  const defaultRootObject = 'index.html';
1396
1464
  this.cloudFrontDistribution = new Distribution(
1397
1465
  this,
@@ -1419,6 +1487,12 @@ export class StaticWebsite extends Construct {
1419
1487
  ],
1420
1488
  },
1421
1489
  );
1490
+ suppressRules(
1491
+ this.cloudFrontDistribution,
1492
+ ['CKV_AWS_174'],
1493
+ 'Cloudfront default certificate does not use TLS 1.2',
1494
+ );
1495
+
1422
1496
  // Deploy Website
1423
1497
  this.bucketDeployment = new BucketDeployment(this, 'WebsiteDeployment', {
1424
1498
  sources: [
@@ -1433,6 +1507,17 @@ export class StaticWebsite extends Construct {
1433
1507
  distribution: this.cloudFrontDistribution,
1434
1508
  memoryLimit: 1024,
1435
1509
  });
1510
+
1511
+ suppressRules(
1512
+ Stack.of(this),
1513
+ ['CKV_AWS_111'],
1514
+ 'CDK Bucket Deployment uses wildcard to deploy arbitrary assets',
1515
+ (c) =>
1516
+ CfnResource.isCfnResource(c) &&
1517
+ c.cfnResourceType === 'AWS::IAM::Policy' &&
1518
+ c.node.path.includes(\`/Custom::CDKBucketDeployment\`),
1519
+ );
1520
+
1436
1521
  new CfnOutput(this, 'DistributionDomainName', {
1437
1522
  value: this.cloudFrontDistribution.domainName,
1438
1523
  });
@@ -1480,6 +1565,24 @@ export class CloudfrontWebAcl extends Stack {
1480
1565
  none: {},
1481
1566
  },
1482
1567
  },
1568
+ {
1569
+ name: 'KnownBadInputsRule',
1570
+ priority: 1,
1571
+ statement: {
1572
+ managedRuleGroupStatement: {
1573
+ name: 'AWSManagedRulesKnownBadInputsRuleSet',
1574
+ vendorName: 'AWS',
1575
+ },
1576
+ },
1577
+ visibilityConfig: {
1578
+ cloudWatchMetricsEnabled: true,
1579
+ metricName: 'MetricForWebACLCDK-CRS',
1580
+ sampledRequestsEnabled: true,
1581
+ },
1582
+ overrideAction: {
1583
+ none: {},
1584
+ },
1585
+ },
1483
1586
  ],
1484
1587
  }).attrArn;
1485
1588
  }
@@ -2561,9 +2664,58 @@ class MetricsAspect implements IAspect {
2561
2664
  "
2562
2665
  `;
2563
2666
 
2667
+ exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/src/core/checkov.ts 1`] = `
2668
+ "import { IConstruct } from 'constructs';
2669
+ import { CfnResource } from 'aws-cdk-lib';
2670
+
2671
+ /**
2672
+ * Suppresses a set of rules for a construct tree.
2673
+ *
2674
+ * @param construct The root construct to suppress the rule for.
2675
+ * @param ids The ids of the rules to suppress.
2676
+ * @param comment The reason for suppressing the rule
2677
+ * @param predicate A predicate function that determines whether the rule should be suppressed for the given construct or any of its descendants.
2678
+ *
2679
+ * @example
2680
+ * The following example suppresses the CKV_AWS_XXX rule for the given construct.
2681
+ * suppressRules(construct, ['CKV_AWS_XXX'], 'Not required for this use case')
2682
+ *
2683
+ * @example
2684
+ * The following example suppresses the CKV_AWS_XXX rule for the construct or any of its descendants if it is an instance of Bucket:
2685
+ * suppressRules(construct, ['CKV_AWS_XXX'], 'Not required for this use case', (construct) => construct instanceof Bucket)
2686
+ */
2687
+ export const suppressRules = (
2688
+ construct: IConstruct,
2689
+ ids: string[],
2690
+ comment: string,
2691
+ predicate?: (construct: IConstruct) => boolean,
2692
+ ) => {
2693
+ const resources = (
2694
+ predicate ? construct.node.findAll().filter(predicate) : [construct]
2695
+ )
2696
+ .map((resource) => {
2697
+ if (CfnResource.isCfnResource(resource)) {
2698
+ return resource;
2699
+ } else return resource.node.defaultChild;
2700
+ })
2701
+ .filter((resource) => CfnResource.isCfnResource(resource));
2702
+
2703
+ resources.forEach((resource) => {
2704
+ const metadata = resource.getMetadata('checkov') || {};
2705
+ metadata['skip'] = [
2706
+ ...(metadata['skip'] ?? []),
2707
+ ...ids.map((id) => ({ id, comment })),
2708
+ ];
2709
+ resource.addMetadata('checkov', metadata);
2710
+ });
2711
+ };
2712
+ "
2713
+ `;
2714
+
2564
2715
  exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/src/core/index.ts 1`] = `
2565
2716
  "export * from './static-website.js';
2566
2717
  export * from './app.js';
2718
+ export * from './checkov.js';
2567
2719
  export * from './runtime-config.js';
2568
2720
  "
2569
2721
  `;
@@ -2603,7 +2755,7 @@ export class RuntimeConfig extends Construct {
2603
2755
  `;
2604
2756
 
2605
2757
  exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/src/core/static-website.ts 1`] = `
2606
- "import { CfnOutput, RemovalPolicy, Stack } from 'aws-cdk-lib';
2758
+ "import { CfnOutput, CfnResource, RemovalPolicy, Stack } from 'aws-cdk-lib';
2607
2759
  import { Distribution, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';
2608
2760
  import { S3BucketOrigin } from 'aws-cdk-lib/aws-cloudfront-origins';
2609
2761
  import {
@@ -2618,6 +2770,8 @@ import { Construct } from 'constructs';
2618
2770
  import { RuntimeConfig } from './runtime-config.js';
2619
2771
  import { Key } from 'aws-cdk-lib/aws-kms';
2620
2772
  import { CfnWebACL } from 'aws-cdk-lib/aws-wafv2';
2773
+ import { suppressRules } from './checkov.js';
2774
+
2621
2775
  const DEFAULT_RUNTIME_CONFIG_FILENAME = 'runtime-config.json';
2622
2776
 
2623
2777
  export interface StaticWebsiteProps {
@@ -2664,6 +2818,17 @@ export class StaticWebsite extends Construct {
2664
2818
  publicReadAccess: false,
2665
2819
  blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
2666
2820
  });
2821
+ suppressRules(
2822
+ accessLogsBucket,
2823
+ ['CKV_AWS_21'],
2824
+ 'Access log bucket does not need versioning enabled',
2825
+ );
2826
+ suppressRules(
2827
+ accessLogsBucket,
2828
+ ['CKV_AWS_18'],
2829
+ 'Access log bucket does not need an access log bucket',
2830
+ );
2831
+
2667
2832
  // S3 Bucket to hold website files
2668
2833
  this.websiteBucket = new Bucket(this, 'WebsiteBucket', {
2669
2834
  versioned: true,
@@ -2694,6 +2859,12 @@ export class StaticWebsite extends Construct {
2694
2859
  serverAccessLogsPrefix: 'distribution-access-logs',
2695
2860
  serverAccessLogsBucket: accessLogsBucket,
2696
2861
  });
2862
+ suppressRules(
2863
+ logBucket,
2864
+ ['CKV_AWS_21'],
2865
+ 'Distribution log bucket does not need versioning enabled',
2866
+ );
2867
+
2697
2868
  const defaultRootObject = 'index.html';
2698
2869
  this.cloudFrontDistribution = new Distribution(
2699
2870
  this,
@@ -2721,6 +2892,12 @@ export class StaticWebsite extends Construct {
2721
2892
  ],
2722
2893
  },
2723
2894
  );
2895
+ suppressRules(
2896
+ this.cloudFrontDistribution,
2897
+ ['CKV_AWS_174'],
2898
+ 'Cloudfront default certificate does not use TLS 1.2',
2899
+ );
2900
+
2724
2901
  // Deploy Website
2725
2902
  this.bucketDeployment = new BucketDeployment(this, 'WebsiteDeployment', {
2726
2903
  sources: [
@@ -2735,6 +2912,17 @@ export class StaticWebsite extends Construct {
2735
2912
  distribution: this.cloudFrontDistribution,
2736
2913
  memoryLimit: 1024,
2737
2914
  });
2915
+
2916
+ suppressRules(
2917
+ Stack.of(this),
2918
+ ['CKV_AWS_111'],
2919
+ 'CDK Bucket Deployment uses wildcard to deploy arbitrary assets',
2920
+ (c) =>
2921
+ CfnResource.isCfnResource(c) &&
2922
+ c.cfnResourceType === 'AWS::IAM::Policy' &&
2923
+ c.node.path.includes(\`/Custom::CDKBucketDeployment\`),
2924
+ );
2925
+
2738
2926
  new CfnOutput(this, 'DistributionDomainName', {
2739
2927
  value: this.cloudFrontDistribution.domainName,
2740
2928
  });
@@ -2782,6 +2970,24 @@ export class CloudfrontWebAcl extends Stack {
2782
2970
  none: {},
2783
2971
  },
2784
2972
  },
2973
+ {
2974
+ name: 'KnownBadInputsRule',
2975
+ priority: 1,
2976
+ statement: {
2977
+ managedRuleGroupStatement: {
2978
+ name: 'AWSManagedRulesKnownBadInputsRuleSet',
2979
+ vendorName: 'AWS',
2980
+ },
2981
+ },
2982
+ visibilityConfig: {
2983
+ cloudWatchMetricsEnabled: true,
2984
+ metricName: 'MetricForWebACLCDK-CRS',
2985
+ sampledRequestsEnabled: true,
2986
+ },
2987
+ overrideAction: {
2988
+ none: {},
2989
+ },
2990
+ },
2785
2991
  ],
2786
2992
  }).attrArn;
2787
2993
  }
@@ -4025,12 +4231,13 @@ exports[`react-website generator > should generate shared constructs > common/co
4025
4231
  exports[`react-website generator > should generate shared constructs > common/constructs-core-index.ts 1`] = `
4026
4232
  "export * from './static-website.js';
4027
4233
  export * from './app.js';
4234
+ export * from './checkov.js';
4028
4235
  export * from './runtime-config.js';
4029
4236
  "
4030
4237
  `;
4031
4238
 
4032
4239
  exports[`react-website generator > should generate shared constructs > common/constructs-core-static-website.ts 1`] = `
4033
- "import { CfnOutput, RemovalPolicy, Stack } from 'aws-cdk-lib';
4240
+ "import { CfnOutput, CfnResource, RemovalPolicy, Stack } from 'aws-cdk-lib';
4034
4241
  import { Distribution, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';
4035
4242
  import { S3BucketOrigin } from 'aws-cdk-lib/aws-cloudfront-origins';
4036
4243
  import {
@@ -4045,6 +4252,8 @@ import { Construct } from 'constructs';
4045
4252
  import { RuntimeConfig } from './runtime-config.js';
4046
4253
  import { Key } from 'aws-cdk-lib/aws-kms';
4047
4254
  import { CfnWebACL } from 'aws-cdk-lib/aws-wafv2';
4255
+ import { suppressRules } from './checkov.js';
4256
+
4048
4257
  const DEFAULT_RUNTIME_CONFIG_FILENAME = 'runtime-config.json';
4049
4258
 
4050
4259
  export interface StaticWebsiteProps {
@@ -4091,6 +4300,17 @@ export class StaticWebsite extends Construct {
4091
4300
  publicReadAccess: false,
4092
4301
  blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
4093
4302
  });
4303
+ suppressRules(
4304
+ accessLogsBucket,
4305
+ ['CKV_AWS_21'],
4306
+ 'Access log bucket does not need versioning enabled',
4307
+ );
4308
+ suppressRules(
4309
+ accessLogsBucket,
4310
+ ['CKV_AWS_18'],
4311
+ 'Access log bucket does not need an access log bucket',
4312
+ );
4313
+
4094
4314
  // S3 Bucket to hold website files
4095
4315
  this.websiteBucket = new Bucket(this, 'WebsiteBucket', {
4096
4316
  versioned: true,
@@ -4121,6 +4341,12 @@ export class StaticWebsite extends Construct {
4121
4341
  serverAccessLogsPrefix: 'distribution-access-logs',
4122
4342
  serverAccessLogsBucket: accessLogsBucket,
4123
4343
  });
4344
+ suppressRules(
4345
+ logBucket,
4346
+ ['CKV_AWS_21'],
4347
+ 'Distribution log bucket does not need versioning enabled',
4348
+ );
4349
+
4124
4350
  const defaultRootObject = 'index.html';
4125
4351
  this.cloudFrontDistribution = new Distribution(
4126
4352
  this,
@@ -4148,6 +4374,12 @@ export class StaticWebsite extends Construct {
4148
4374
  ],
4149
4375
  },
4150
4376
  );
4377
+ suppressRules(
4378
+ this.cloudFrontDistribution,
4379
+ ['CKV_AWS_174'],
4380
+ 'Cloudfront default certificate does not use TLS 1.2',
4381
+ );
4382
+
4151
4383
  // Deploy Website
4152
4384
  this.bucketDeployment = new BucketDeployment(this, 'WebsiteDeployment', {
4153
4385
  sources: [
@@ -4162,6 +4394,17 @@ export class StaticWebsite extends Construct {
4162
4394
  distribution: this.cloudFrontDistribution,
4163
4395
  memoryLimit: 1024,
4164
4396
  });
4397
+
4398
+ suppressRules(
4399
+ Stack.of(this),
4400
+ ['CKV_AWS_111'],
4401
+ 'CDK Bucket Deployment uses wildcard to deploy arbitrary assets',
4402
+ (c) =>
4403
+ CfnResource.isCfnResource(c) &&
4404
+ c.cfnResourceType === 'AWS::IAM::Policy' &&
4405
+ c.node.path.includes(\`/Custom::CDKBucketDeployment\`),
4406
+ );
4407
+
4165
4408
  new CfnOutput(this, 'DistributionDomainName', {
4166
4409
  value: this.cloudFrontDistribution.domainName,
4167
4410
  });
@@ -4209,6 +4452,24 @@ export class CloudfrontWebAcl extends Stack {
4209
4452
  none: {},
4210
4453
  },
4211
4454
  },
4455
+ {
4456
+ name: 'KnownBadInputsRule',
4457
+ priority: 1,
4458
+ statement: {
4459
+ managedRuleGroupStatement: {
4460
+ name: 'AWSManagedRulesKnownBadInputsRuleSet',
4461
+ vendorName: 'AWS',
4462
+ },
4463
+ },
4464
+ visibilityConfig: {
4465
+ cloudWatchMetricsEnabled: true,
4466
+ metricName: 'MetricForWebACLCDK-CRS',
4467
+ sampledRequestsEnabled: true,
4468
+ },
4469
+ overrideAction: {
4470
+ none: {},
4471
+ },
4472
+ },
4212
4473
  ],
4213
4474
  }).attrArn;
4214
4475
  }
@@ -72,6 +72,7 @@ export default CognitoAuth;
72
72
  exports[`cognito-auth generator > should generate files > identity-index 1`] = `
73
73
  "export * from './user-identity.js';
74
74
  export * from './app.js';
75
+ export * from './checkov.js';
75
76
  export * from './runtime-config.js';
76
77
  "
77
78
  `;
@@ -95,6 +96,7 @@ import {
95
96
  import { Construct } from 'constructs';
96
97
  import { RuntimeConfig } from './runtime-config.js';
97
98
  import { Distribution } from 'aws-cdk-lib/aws-cloudfront';
99
+ import { suppressRules } from './checkov.js';
98
100
 
99
101
  const WEB_CLIENT_ID = 'WebClient';
100
102
  /**
@@ -131,6 +133,13 @@ export class UserIdentity extends Construct {
131
133
  userPoolWebClientId: this.userPoolClient.userPoolClientId,
132
134
  };
133
135
 
136
+ suppressRules(
137
+ this.userPool,
138
+ ['CKV_AWS_111'],
139
+ 'SMS Role requires wildcard resource',
140
+ (c) => c.node.path.includes('/smsRole/'),
141
+ );
142
+
134
143
  new CfnOutput(this, \`\${id}-UserPoolId\`, {
135
144
  value: this.userPool.userPoolId,
136
145
  });
@@ -455,6 +464,7 @@ export function Main() {
455
464
  exports[`cognito-auth generator > should update shared constructs index.ts > common/constructs-index 1`] = `
456
465
  "export * from './user-identity.js';
457
466
  export * from './app.js';
467
+ export * from './checkov.js';
458
468
  export * from './runtime-config.js';
459
469
  "
460
470
  `;
@@ -31,8 +31,57 @@ class MetricsAspect implements IAspect {
31
31
  "
32
32
  `;
33
33
 
34
+ exports[`shared-constructs utils > sharedConstructsGenerator > should generate shared constructs when they do not exist > packages/common/constructs/src/core/checkov.ts 1`] = `
35
+ "import { IConstruct } from 'constructs';
36
+ import { CfnResource } from 'aws-cdk-lib';
37
+
38
+ /**
39
+ * Suppresses a set of rules for a construct tree.
40
+ *
41
+ * @param construct The root construct to suppress the rule for.
42
+ * @param ids The ids of the rules to suppress.
43
+ * @param comment The reason for suppressing the rule
44
+ * @param predicate A predicate function that determines whether the rule should be suppressed for the given construct or any of its descendants.
45
+ *
46
+ * @example
47
+ * The following example suppresses the CKV_AWS_XXX rule for the given construct.
48
+ * suppressRules(construct, ['CKV_AWS_XXX'], 'Not required for this use case')
49
+ *
50
+ * @example
51
+ * The following example suppresses the CKV_AWS_XXX rule for the construct or any of its descendants if it is an instance of Bucket:
52
+ * suppressRules(construct, ['CKV_AWS_XXX'], 'Not required for this use case', (construct) => construct instanceof Bucket)
53
+ */
54
+ export const suppressRules = (
55
+ construct: IConstruct,
56
+ ids: string[],
57
+ comment: string,
58
+ predicate?: (construct: IConstruct) => boolean,
59
+ ) => {
60
+ const resources = (
61
+ predicate ? construct.node.findAll().filter(predicate) : [construct]
62
+ )
63
+ .map((resource) => {
64
+ if (CfnResource.isCfnResource(resource)) {
65
+ return resource;
66
+ } else return resource.node.defaultChild;
67
+ })
68
+ .filter((resource) => CfnResource.isCfnResource(resource));
69
+
70
+ resources.forEach((resource) => {
71
+ const metadata = resource.getMetadata('checkov') || {};
72
+ metadata['skip'] = [
73
+ ...(metadata['skip'] ?? []),
74
+ ...ids.map((id) => ({ id, comment })),
75
+ ];
76
+ resource.addMetadata('checkov', metadata);
77
+ });
78
+ };
79
+ "
80
+ `;
81
+
34
82
  exports[`shared-constructs utils > sharedConstructsGenerator > should generate shared constructs when they do not exist > packages/common/constructs/src/core/index.ts 1`] = `
35
83
  "export * from './app.js';
84
+ export * from './checkov.js';
36
85
  export * from './runtime-config.js';
37
86
  "
38
87
  `;
@@ -24,7 +24,7 @@ export class <%- nameClassName %> extends Construct {
24
24
  platform: Platform.LINUX_ARM64,
25
25
  directory: path.dirname(url.fileURLToPath(new URL(import.meta.url))),
26
26
  extraHash: execSync(
27
- `docker inspect <%- dockerImageTag %> --format '{{.Descriptor.digest}}'`,
27
+ `docker inspect <%- dockerImageTag %> --format '{{.Id}}'`,
28
28
  { encoding: 'utf-8' },
29
29
  ).trim(),
30
30
  });
@@ -278,7 +278,7 @@ resource "aws_iam_role_policy_attachment" "agent_core_policy" {
278
278
  }
279
279
 
280
280
  data "external" "docker_digest" {
281
- program = ["sh", "-c", "echo '{\"digest\":\"'$(docker inspect ${var.docker_image_tag} --format '{{.Descriptor.digest}}')'\"}' "]
281
+ program = ["sh", "-c", "echo '{\"digest\":\"'$(docker inspect ${var.docker_image_tag} --format '{{.Id}}')'\"}' "]
282
282
  }
283
283
 
284
284
  # Null resource for Docker publish
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { ProjectConfiguration, Tree } from '@nx/devkit';
6
+ export interface AddOpenApiReactClientOptions {
7
+ /**
8
+ * The react project to add the openapi client and build targets to
9
+ */
10
+ frontendProjectConfig: ProjectConfiguration;
11
+ /**
12
+ * The backend project which serves the api
13
+ */
14
+ backendProjectConfig: ProjectConfiguration;
15
+ /**
16
+ * The project which builds/generates the openapi spec
17
+ */
18
+ specBuildProject: ProjectConfiguration;
19
+ /**
20
+ * Name of the api
21
+ */
22
+ apiName: string;
23
+ /**
24
+ * Path to the openapi spec from the workspace root
25
+ */
26
+ specPath: string;
27
+ /**
28
+ * Fully qualified target name for the target that builds/generates the openapi spec
29
+ */
30
+ specBuildTargetName: string;
31
+ /**
32
+ * Authentication method
33
+ */
34
+ auth: 'IAM' | 'Cognito' | 'None';
35
+ /**
36
+ * Port on which the backend project's local server listens
37
+ */
38
+ port: number;
39
+ }
40
+ /**
41
+ * Adds an OpenAPI React client to the frontend project along with supporting build targets
42
+ */
43
+ export declare const addOpenApiReactClient: (tree: Tree, { apiName, frontendProjectConfig, backendProjectConfig, specBuildProject, specPath, specBuildTargetName, auth, port, }: AddOpenApiReactClientOptions) => Promise<void>;