cdk-real-drift 0.10.1 → 0.10.2

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
@@ -3043,7 +3043,6 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
3043
3043
  "AWS::ElasticLoadBalancing::LoadBalancer": new Set(["AvailabilityZones"]),
3044
3044
  "AWS::AutoScaling::AutoScalingGroup": new Set(["AvailabilityZones", "AvailabilityZoneIds"]),
3045
3045
  "AWS::ApiGateway::Authorizer": new Set(["AuthType"]),
3046
- "AWS::GuardDuty::Detector": new Set(["Features"]),
3047
3046
  "AWS::RDS::DBCluster": new Set([
3048
3047
  "KmsKeyId",
3049
3048
  "PerformanceInsightsKmsKeyId",
@@ -4912,8 +4911,26 @@ const MEANINGFUL_WHEN_OFF = {
4912
4911
  "AWS::EC2::NetworkInterface": { SourceDestCheck: () => true },
4913
4912
  "AWS::Cognito::UserPoolClient": { EnableTokenRevocation: () => true },
4914
4913
  "AWS::CloudWatch::CompositeAlarm": { ActionsEnabled: () => true },
4915
- "AWS::ApplicationInsights::Application": { CWEMonitorEnabled: () => true }
4914
+ "AWS::ApplicationInsights::Application": { CWEMonitorEnabled: () => true },
4915
+ "AWS::GuardDuty::Detector": { DataSources: () => true }
4916
4916
  };
4917
+ const GUARDDUTY_DEFAULT_DISABLED_FEATURES = new Set(["AI_ANALYST"]);
4918
+ function guardDutyFeaturesAllAtDefault(features) {
4919
+ const atDefault = (node) => {
4920
+ if (Array.isArray(node)) return node.every(atDefault);
4921
+ if (node !== null && typeof node === "object") {
4922
+ const rec = node;
4923
+ if ("Status" in rec) {
4924
+ const name = typeof rec["Name"] === "string" ? rec["Name"] : "";
4925
+ const defaultStatus = GUARDDUTY_DEFAULT_DISABLED_FEATURES.has(name) ? "DISABLED" : "ENABLED";
4926
+ if (rec["Status"] !== defaultStatus) return false;
4927
+ }
4928
+ return Object.values(rec).every(atDefault);
4929
+ }
4930
+ return true;
4931
+ };
4932
+ return features.every(atDefault);
4933
+ }
4917
4934
  const stripCognitoAttrPrefix = (id) => id.replace(/^(custom|dev):/, "");
4918
4935
  const IDENTITY_KEYED_SUBSET_ARRAYS = {
4919
4936
  "AWS::Cognito::UserPool": { Schema: {
@@ -6092,6 +6109,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6092
6109
  }
6093
6110
  continue;
6094
6111
  }
6112
+ if (resourceType === "AWS::GuardDuty::Detector" && k === "Features" && Array.isArray(v)) {
6113
+ findings.push({
6114
+ tier: guardDutyFeaturesAllAtDefault(v) ? "atDefault" : "undeclared",
6115
+ logicalId,
6116
+ resourceType,
6117
+ path: k,
6118
+ actual: v
6119
+ });
6120
+ continue;
6121
+ }
6095
6122
  if (k in schema.defaults && matchesKnownDefault(v, schema.defaults[k]) || k in knownDef && matchesKnownDefault(v, knownDef[k]) || KNOWN_DEFAULT_ONE_OF[resourceType]?.[k]?.some((d) => matchesKnownDefault(v, d)) || VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS[resourceType]?.has(k) && !isTrivialEmpty(v) && !(k in knownDef) || clbDefaultSslPoliciesAtDefault(resourceType, k, v)) {
6096
6123
  findings.push({
6097
6124
  tier: "atDefault",
@@ -6235,10 +6262,11 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6235
6262
  }
6236
6263
  if (isAllAwsTags(v)) continue;
6237
6264
  if (physicalId !== void 0 && v === physicalId) continue;
6238
- if (!(k in knownDef && !matchesKnownDefault(v, knownDef[k]) && (MEANINGFUL_WHEN_OFF[resourceType]?.[k]?.({
6265
+ const offStateIsMeaningful = k in knownDef && !matchesKnownDefault(v, knownDef[k]) && (MEANINGFUL_WHEN_OFF[resourceType]?.[k]?.({
6239
6266
  declared,
6240
6267
  live
6241
- }) ?? false)) && (isTrivialEmpty(v) || isSelfEchoTrivialEmpty(v, physicalId) || isEmptyPolicyShell(v))) continue;
6268
+ }) ?? false);
6269
+ if (!offStateIsMeaningful && (isTrivialEmpty(v) || isSelfEchoTrivialEmpty(v, physicalId) || isEmptyPolicyShell(v))) continue;
6242
6270
  if (isNestedObject(v) && DESCEND_UNDECLARED_OBJECT_PATHS[resourceType]?.has(k)) {
6243
6271
  collectNestedUndeclared({}, v, k, emitNested, NESTED_ARRAY_IDENTITY[resourceType]);
6244
6272
  continue;
@@ -6272,7 +6300,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6272
6300
  }
6273
6301
  continue;
6274
6302
  }
6275
- if (isNestedObject(v) && Object.keys(v).length > 0 && allLeavesAtSchemaDefault(v, k)) {
6303
+ if (!offStateIsMeaningful && isNestedObject(v) && Object.keys(v).length > 0 && allLeavesAtSchemaDefault(v, k)) {
6276
6304
  findings.push({
6277
6305
  tier: "atDefault",
6278
6306
  logicalId,