cdk-real-drift 0.6.2 → 0.7.1

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/dist/cli.js CHANGED
@@ -33,7 +33,7 @@ import { CognitoSyncClient, GetCognitoEventsCommand, SetCognitoEventsCommand } f
33
33
  import { BatchGetProjectsCommand, BatchGetReportGroupsCommand, CodeBuildClient, UpdateReportGroupCommand } from "@aws-sdk/client-codebuild";
34
34
  import { DescribeDBClustersCommand as DescribeDBClustersCommand$1, DescribeDBInstancesCommand as DescribeDBInstancesCommand$1, DocDBClient, ModifyDBClusterCommand, ModifyDBInstanceCommand } from "@aws-sdk/client-docdb";
35
35
  import { DAXClient, DescribeClustersCommand, DescribeParameterGroupsCommand, DescribeParametersCommand, DescribeSubnetGroupsCommand, UpdateClusterCommand, UpdateParameterGroupCommand } from "@aws-sdk/client-dax";
36
- import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetTableCommand, GetWorkflowCommand, GlueClient, UpdateClassifierCommand, UpdateConnectionCommand, UpdateJobCommand, UpdateTableCommand, UpdateWorkflowCommand } from "@aws-sdk/client-glue";
36
+ import { GetClassifierCommand, GetConnectionCommand, GetJobCommand, GetSecurityConfigurationCommand, GetTableCommand, GetWorkflowCommand, GlueClient, UpdateClassifierCommand, UpdateConnectionCommand, UpdateJobCommand, UpdateTableCommand, UpdateWorkflowCommand } from "@aws-sdk/client-glue";
37
37
  import { AttachGroupPolicyCommand, AttachRolePolicyCommand, AttachUserPolicyCommand, CreatePolicyVersionCommand, DeletePolicyVersionCommand, DeleteRolePolicyCommand, DetachGroupPolicyCommand, DetachRolePolicyCommand, DetachUserPolicyCommand, GetGroupPolicyCommand, GetPolicyCommand as GetPolicyCommand$1, GetPolicyVersionCommand, GetRolePolicyCommand, GetUserPolicyCommand, IAMClient, ListAccessKeysCommand, ListEntitiesForPolicyCommand, ListPolicyVersionsCommand, PutGroupPolicyCommand, PutRolePolicyCommand, PutUserPolicyCommand } from "@aws-sdk/client-iam";
38
38
  import { DeleteBucketPolicyCommand, GetBucketPolicyCommand, PutBucketPolicyCommand, S3Client } from "@aws-sdk/client-s3";
39
39
  import { DescribeCacheClustersCommand, DescribeCacheParameterGroupsCommand, DescribeCacheParametersCommand, DescribeReplicationGroupsCommand, DescribeUsersCommand, ElastiCacheClient, ModifyCacheParameterGroupCommand, ResetCacheParameterGroupCommand } from "@aws-sdk/client-elasticache";
@@ -5000,6 +5000,19 @@ function isSelfEchoTrivialEmpty(v, physicalId) {
5000
5000
  const rest = entries.filter(([, val]) => val !== physicalId);
5001
5001
  return rest.length < entries.length && rest.every(([, val]) => isTrivialEmpty(val));
5002
5002
  }
5003
+ const RDS_OPTION_SETTING_DEFAULTS = {
5004
+ SERVER_AUDIT: "FORCE_PLUS_PERMANENT",
5005
+ SERVER_AUDIT_LOGGING: "ON",
5006
+ SERVER_AUDIT_FILE_PATH: "/rdsdbdata/log/audit/"
5007
+ };
5008
+ function isIdentityOnlyHusk(el, idField) {
5009
+ return Object.entries(el).every(([k, v]) => k === idField || isTrivialEmpty(v));
5010
+ }
5011
+ function isRdsOptionSettingDefault(resourceType, el, name, value) {
5012
+ if (resourceType !== "AWS::RDS::OptionGroup") return false;
5013
+ if (isIdentityOnlyHusk(el, "Name")) return true;
5014
+ return name in RDS_OPTION_SETTING_DEFAULTS && value === RDS_OPTION_SETTING_DEFAULTS[name];
5015
+ }
5003
5016
  function isEmptyPolicyShell(v) {
5004
5017
  if (v === null || typeof v !== "object" || Array.isArray(v)) return false;
5005
5018
  const o = v;
@@ -5682,8 +5695,9 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
5682
5695
  const loName = String(loRec[nvSubsetSpec.nameField]);
5683
5696
  const loValue = loRec[nvSubsetSpec.valueField];
5684
5697
  const isFirehoseRetriesDefault = resourceType === "AWS::KinesisFirehose::DeliveryStream" && loName === "NumberOfRetries" && loValue === "3";
5698
+ const isRdsOptionDefault = isRdsOptionSettingDefault(resourceType, loRec, loName, loValue);
5685
5699
  findings.push({
5686
- tier: isFirehoseRetriesDefault ? "atDefault" : "undeclared",
5700
+ tier: isFirehoseRetriesDefault || isRdsOptionDefault ? "atDefault" : "undeclared",
5687
5701
  logicalId,
5688
5702
  resourceType,
5689
5703
  path: `${d.path}[${loName}]`,
@@ -8686,6 +8700,23 @@ const readGlueConnection = async ({ physicalId, declared, region }) => {
8686
8700
  if (catalogId) out.CatalogId = catalogId;
8687
8701
  return out;
8688
8702
  };
8703
+ const readGlueSecurityConfiguration = async ({ physicalId, declared, region }) => {
8704
+ const name = str$1(physicalId) ?? str$1(declared.Name);
8705
+ if (!name) return void 0;
8706
+ const sc = (await new GlueClient({
8707
+ region,
8708
+ ...READ_RETRY
8709
+ }).send(new GetSecurityConfigurationCommand({ Name: name }))).SecurityConfiguration;
8710
+ if (!sc) throw new ResourceGoneError(`Glue SecurityConfiguration ${name} absent`);
8711
+ const enc = sc.EncryptionConfiguration;
8712
+ const ec = {};
8713
+ if (Array.isArray(enc?.S3Encryption) && enc.S3Encryption.length > 0) ec.S3Encryptions = enc.S3Encryption;
8714
+ if (enc?.CloudWatchEncryption !== void 0) ec.CloudWatchEncryption = enc.CloudWatchEncryption;
8715
+ if (enc?.JobBookmarksEncryption !== void 0) ec.JobBookmarksEncryption = enc.JobBookmarksEncryption;
8716
+ const model = { Name: sc.Name ?? name };
8717
+ if (Object.keys(ec).length > 0) model.EncryptionConfiguration = ec;
8718
+ return model;
8719
+ };
8689
8720
  const readMetricFilter = async ({ physicalId, declared, region }) => {
8690
8721
  const logGroup = str$1(declared.LogGroupName);
8691
8722
  const filterName = str$1(physicalId) ?? str$1(declared.FilterName);
@@ -9143,6 +9174,7 @@ const SDK_OVERRIDES = {
9143
9174
  "AWS::Glue::Classifier": readGlueClassifier,
9144
9175
  "AWS::Glue::Workflow": readGlueWorkflow,
9145
9176
  "AWS::Glue::Connection": readGlueConnection,
9177
+ "AWS::Glue::SecurityConfiguration": readGlueSecurityConfiguration,
9146
9178
  "AWS::Logs::MetricFilter": readMetricFilter,
9147
9179
  "AWS::Scheduler::Schedule": readSchedulerSchedule
9148
9180
  };
@@ -15830,6 +15862,24 @@ function finalCheckExit(code, fail) {
15830
15862
  return fail || code !== 1 ? code : 0;
15831
15863
  }
15832
15864
  /**
15865
+ * Whether `check` should open its interactive after-report resolve menu (Record / Revert /
15866
+ * Ignore / Decide-per-finding). It fires only when there is something to act on (drift,
15867
+ * unrecorded values, or no baseline yet — R141's day-1 establish) AND the run is a TTY human
15868
+ * who can make the decision. It is gated OUT of every machine/automation mode:
15869
+ * - --json / --show-all / --pre-deploy — machine output or baseline-untouched contracts,
15870
+ * - --fail — the CI drift-exit path,
15871
+ * - #1054: --yes — `--yes` has NO documented `check` contract (HELP scopes it to record /
15872
+ * ignore / revert; check's automation flag is --fail / non-TTY). In the menu the USER is
15873
+ * the decision-maker, but `--yes` means "no decision needed" in the record/ignore/revert
15874
+ * sub-actions it threads into — so a `check --yes` in a TTY silently overrode explicit
15875
+ * per-finding choices (recorded / ignored / reverted values the user declined, including
15876
+ * folded values never shown in the report). Under --yes, check just reports.
15877
+ * Pure + exported for tests.
15878
+ */
15879
+ function shouldOfferInteractiveResolve(a, ctx) {
15880
+ return (ctx.code === 1 || ctx.hasUnrecorded || !ctx.hasBaseline) && !a.json && !a.showAll && !a.preDeploy && !a.fail && !a.yes && ctx.interactive;
15881
+ }
15882
+ /**
15833
15883
  * #781: does a committed baseline exist for this stack IN THE REGION being checked?
15834
15884
  * A committed baseline is named `<stackName>.<accountId>.<region>.json` under
15835
15885
  * `.cdkrd/baselines/`. The gone stack's ACCOUNT is unknown without an STS call, so it
@@ -16074,7 +16124,12 @@ async function runCheck(args) {
16074
16124
  expandAtDefault: a.showAll
16075
16125
  });
16076
16126
  const hasUnrecorded = reconciled.some((f) => f.unrecorded === true);
16077
- if ((code === 1 || hasUnrecorded || !baseline) && !a.json && !a.showAll && !a.preDeploy && !a.fail && isInteractive()) code = await resolveInteractively({
16127
+ if (shouldOfferInteractiveResolve(a, {
16128
+ code,
16129
+ hasUnrecorded,
16130
+ hasBaseline: baseline !== void 0,
16131
+ interactive: isInteractive()
16132
+ })) code = await resolveInteractively({
16078
16133
  stackName,
16079
16134
  region,
16080
16135
  desired,