cdk-real-drift 0.12.69 → 0.12.71
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 +81 -14
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3427,7 +3427,6 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
3427
3427
|
"AWS::StepFunctions::StateMachineVersion": new Set(["StateMachineRevisionId"]),
|
|
3428
3428
|
"AWS::StepFunctions::StateMachineAlias": new Set(["StateMachineArn"]),
|
|
3429
3429
|
"AWS::AutoScaling::ScheduledAction": new Set(["StartTime"]),
|
|
3430
|
-
"AWS::RedshiftServerless::Workgroup": new Set(["ConfigParameters"]),
|
|
3431
3430
|
"AWS::CloudFormation::Stack": new Set(["TemplateBody", "Capabilities"])
|
|
3432
3431
|
};
|
|
3433
3432
|
function isPhysicalIdSegment(value, physicalId) {
|
|
@@ -4223,9 +4222,23 @@ const UNORDERED_NESTED_OBJECT_ARRAY_PATHS = {
|
|
|
4223
4222
|
"AWS::AutoScaling::AutoScalingGroup": new Set(["MetricsCollection.Metrics", "NotificationConfigurations.NotificationTypes"]),
|
|
4224
4223
|
"AWS::Lambda::EventSourceMapping": new Set(["SelfManagedEventSource.Endpoints.KafkaBootstrapServers"])
|
|
4225
4224
|
};
|
|
4226
|
-
|
|
4225
|
+
const NESTED_OBJECT_ARRAY_IDENTITY = {
|
|
4226
|
+
"AWS::Bedrock::Guardrail": {
|
|
4227
|
+
"ContentPolicyConfig.FiltersConfig": "Type",
|
|
4228
|
+
"TopicPolicyConfig.TopicsConfig": "Name",
|
|
4229
|
+
"SensitiveInformationPolicyConfig.PiiEntitiesConfig": "Type",
|
|
4230
|
+
"SensitiveInformationPolicyConfig.RegexesConfig": "Name",
|
|
4231
|
+
"WordPolicyConfig.WordsConfig": "Text"
|
|
4232
|
+
},
|
|
4233
|
+
"AWS::ECS::TaskDefinition": {
|
|
4234
|
+
"ContainerDefinitions.PortMappings": "ContainerPort",
|
|
4235
|
+
"ContainerDefinitions.VolumesFrom": "SourceContainer"
|
|
4236
|
+
},
|
|
4237
|
+
"AWS::Backup::BackupSelection": { "BackupSelection.ListOfTags": "ConditionKey" }
|
|
4238
|
+
};
|
|
4239
|
+
function sortNestedObjectArrays(value, subPaths, identityBySubPath) {
|
|
4227
4240
|
if (subPaths.length === 0 || value === null || typeof value !== "object") return value;
|
|
4228
|
-
if (Array.isArray(value)) return value.map((el) => sortNestedObjectArrays(el, subPaths));
|
|
4241
|
+
if (Array.isArray(value)) return value.map((el) => sortNestedObjectArrays(el, subPaths, identityBySubPath));
|
|
4229
4242
|
const clone = structuredClone(value);
|
|
4230
4243
|
for (const sub of subPaths) {
|
|
4231
4244
|
const segs = sub.split(".");
|
|
@@ -4235,7 +4248,7 @@ function sortNestedObjectArrays(value, subPaths) {
|
|
|
4235
4248
|
cur = next !== null && typeof next === "object" ? next : void 0;
|
|
4236
4249
|
}
|
|
4237
4250
|
const last = segs[segs.length - 1];
|
|
4238
|
-
if (cur && Array.isArray(cur[last])) cur[last] = sortUnorderedObjectArray(cur[last]);
|
|
4251
|
+
if (cur && Array.isArray(cur[last])) cur[last] = sortUnorderedObjectArray(cur[last], identityBySubPath?.[sub]);
|
|
4239
4252
|
}
|
|
4240
4253
|
return clone;
|
|
4241
4254
|
}
|
|
@@ -5522,6 +5535,17 @@ function shouldFoldDefaultSubnetList(resourceType, key, liveValue, defaultSubnet
|
|
|
5522
5535
|
return liveValue.every((s) => typeof s === "string" && defaultSubnetIds.has(s));
|
|
5523
5536
|
}
|
|
5524
5537
|
const DEFAULT_SUBNET_LIST_PATHS = { "AWS::RedshiftServerless::Workgroup": "SubnetIds" };
|
|
5538
|
+
const RS_WORKGROUP_CONFIG_PARAM_DEFAULTS = {
|
|
5539
|
+
auto_mv: "true",
|
|
5540
|
+
datestyle: "ISO, MDY",
|
|
5541
|
+
enable_case_sensitive_identifier: "false",
|
|
5542
|
+
enable_user_activity_logging: "true",
|
|
5543
|
+
query_group: "default",
|
|
5544
|
+
require_ssl: "true",
|
|
5545
|
+
search_path: "$user, public",
|
|
5546
|
+
use_fips_ssl: "false",
|
|
5547
|
+
max_query_execution_time: "14400"
|
|
5548
|
+
};
|
|
5525
5549
|
/** #889 fold decision for an UNDECLARED default-SG list (ALB SecurityGroups / ENI GroupSet).
|
|
5526
5550
|
* Returns whether the value-independent fold should still apply for this live value:
|
|
5527
5551
|
* - `true` → FOLD (atDefault): the live list is a single VPC-default SG id, OR the prefetch is
|
|
@@ -5852,7 +5876,6 @@ function cloneDeepWithSymbols(v) {
|
|
|
5852
5876
|
}
|
|
5853
5877
|
const isPolicyStatementArray = (arr) => arr.length > 0 && arr.every((el) => isNestedObject(el) && "Effect" in el);
|
|
5854
5878
|
const isInlinePolicyArray = (arr) => arr.length > 0 && arr.every((el) => isNestedObject(el) && "PolicyDocument" in el);
|
|
5855
|
-
const isIdentitySortedObjectArray = (arr) => arr.length > 0 && identityField(arr) !== void 0;
|
|
5856
5879
|
function isPolicySubsetOf(sub, sup) {
|
|
5857
5880
|
for (const [k, v] of Object.entries(sub)) {
|
|
5858
5881
|
if (!(k in sup)) return false;
|
|
@@ -5970,6 +5993,31 @@ function remapSortedIndexToDeclared(path, arrayKey, sortedDeclared, rawDeclared)
|
|
|
5970
5993
|
const rawIdx = rawDeclared.findIndex((e) => deepEqual(e, el));
|
|
5971
5994
|
return rawIdx < 0 ? path : `${arrayKey}.${rawIdx}${m[2]}`;
|
|
5972
5995
|
}
|
|
5996
|
+
function crossedSortedArrayRevert(v, k, driftPath, resourceType, nestedSubPaths, nestedIdentityBySubPath) {
|
|
5997
|
+
if (!driftPath.startsWith(`${k}.`)) return void 0;
|
|
5998
|
+
const orderSigKeys = ORDER_SIGNIFICANT_ARRAY_KEYS[resourceType];
|
|
5999
|
+
const orderSigPaths = ORDER_SIGNIFICANT_PATHS[resourceType];
|
|
6000
|
+
const rel = driftPath.slice(k.length + 1).split(".");
|
|
6001
|
+
let cur = v;
|
|
6002
|
+
let arrPathRel = "";
|
|
6003
|
+
let parentKey = k;
|
|
6004
|
+
for (const seg of rel) if (Array.isArray(cur)) {
|
|
6005
|
+
const arr = cur;
|
|
6006
|
+
if (!/^\d+$/.test(seg)) return void 0;
|
|
6007
|
+
const fullPath = arrPathRel ? `${k}.${arrPathRel}` : k;
|
|
6008
|
+
const orderSig = (orderSigKeys?.has(parentKey) || orderSigPaths?.has(fullPath)) ?? false;
|
|
6009
|
+
const idField = identityField(arr) ?? nestedIdentityBySubPath[arrPathRel];
|
|
6010
|
+
if (!orderSig && (idField !== void 0 || nestedSubPaths.includes(arrPathRel)) && arr.length >= 2) return {
|
|
6011
|
+
path: fullPath,
|
|
6012
|
+
value: arr
|
|
6013
|
+
};
|
|
6014
|
+
cur = arr[Number(seg)];
|
|
6015
|
+
} else if (cur !== null && typeof cur === "object") {
|
|
6016
|
+
cur = cur[seg];
|
|
6017
|
+
arrPathRel = arrPathRel ? `${arrPathRel}.${seg}` : seg;
|
|
6018
|
+
parentKey = seg;
|
|
6019
|
+
} else return;
|
|
6020
|
+
}
|
|
5973
6021
|
const S3_NOTIF_FILTER_RULE_NAMES = {
|
|
5974
6022
|
prefix: "prefix",
|
|
5975
6023
|
suffix: "suffix",
|
|
@@ -6734,6 +6782,8 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6734
6782
|
const nestedUnordered = UNORDERED_NESTED_OBJECT_ARRAY_PATHS[resourceType];
|
|
6735
6783
|
const orderSigPathsForType = ORDER_SIGNIFICANT_PATHS[resourceType];
|
|
6736
6784
|
const nestedSubPaths = [...new Set([...nestedUnordered ?? [], ...schema.unorderedObjectArrayPaths ?? []].filter((p) => p.startsWith(`${k}.`) && !orderSigPathsForType?.has(p)).map((p) => p.slice(k.length + 1)))];
|
|
6785
|
+
const nestedIdentityBySubPath = {};
|
|
6786
|
+
for (const [fullPath, idf] of Object.entries(NESTED_OBJECT_ARRAY_IDENTITY[resourceType] ?? {})) if (fullPath.startsWith(`${k}.`)) nestedIdentityBySubPath[fullPath.slice(k.length + 1)] = idf;
|
|
6737
6787
|
let declaredVal = v;
|
|
6738
6788
|
let liveVal = live[k];
|
|
6739
6789
|
let declaredRemapSource;
|
|
@@ -6786,14 +6836,14 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6786
6836
|
declaredVal = declaredSorted;
|
|
6787
6837
|
liveVal = liveAligned;
|
|
6788
6838
|
} else if (unorderedObjArray) {
|
|
6789
|
-
const declaredNestedSorted = nestedSubPaths.length > 0 ? sortNestedObjectArrays(v, nestedSubPaths) : v;
|
|
6839
|
+
const declaredNestedSorted = nestedSubPaths.length > 0 ? sortNestedObjectArrays(v, nestedSubPaths, nestedIdentityBySubPath) : v;
|
|
6790
6840
|
const idField = UNORDERED_OBJECT_ARRAY_IDENTITY[resourceType]?.[k];
|
|
6791
6841
|
declaredVal = sortUnorderedObjectArray(declaredNestedSorted, idField);
|
|
6792
|
-
liveVal = sortUnorderedObjectArray(nestedSubPaths.length > 0 ? sortNestedObjectArrays(live[k], nestedSubPaths) : live[k], idField);
|
|
6842
|
+
liveVal = sortUnorderedObjectArray(nestedSubPaths.length > 0 ? sortNestedObjectArrays(live[k], nestedSubPaths, nestedIdentityBySubPath) : live[k], idField);
|
|
6793
6843
|
if (Array.isArray(declaredNestedSorted)) declaredRemapSource = declaredNestedSorted;
|
|
6794
6844
|
} else if (nestedSubPaths.length > 0) {
|
|
6795
|
-
declaredVal = sortNestedObjectArrays(v, nestedSubPaths);
|
|
6796
|
-
liveVal = sortNestedObjectArrays(live[k], nestedSubPaths);
|
|
6845
|
+
declaredVal = sortNestedObjectArrays(v, nestedSubPaths, nestedIdentityBySubPath);
|
|
6846
|
+
liveVal = sortNestedObjectArrays(live[k], nestedSubPaths, nestedIdentityBySubPath);
|
|
6797
6847
|
}
|
|
6798
6848
|
for (const d of calculateResourceDrift({ [k]: declaredVal }, { [k]: liveVal })) {
|
|
6799
6849
|
if (d.stateValue === UNRESOLVED || hasUnresolved(d.stateValue)) continue;
|
|
@@ -6884,17 +6934,14 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6884
6934
|
const transformExpr = schema.propertyTransforms?.[d.path] ?? schema.propertyTransforms?.[d.path.replace(/\.\d+(?=\.|$)/g, ".*")];
|
|
6885
6935
|
if (transformExpr !== void 0 && matchesPropertyTransform(transformExpr, d.stateValue, resolveParentObject(declared, d.path), declared, d.awsValue, d.path.split(".").at(-1) ?? d.path)) continue;
|
|
6886
6936
|
if (schema.propertyTransforms !== void 0 && transformExpr === void 0 && matchesAncestorPropertyTransform(schema.propertyTransforms, d.path, declared, live)) continue;
|
|
6887
|
-
const
|
|
6937
|
+
const crossedSorted = unorderedObjArray ? void 0 : crossedSortedArrayRevert(v, k, d.path, resourceType, nestedSubPaths, nestedIdentityBySubPath);
|
|
6888
6938
|
const unorderedExtra = unorderedObjArray && Array.isArray(declaredVal) && declaredRemapSource ? {
|
|
6889
6939
|
path: remapSortedIndexToDeclared(d.path, k, declaredVal, declaredRemapSource),
|
|
6890
6940
|
wholeArrayRevert: {
|
|
6891
6941
|
path: k,
|
|
6892
6942
|
value: v
|
|
6893
6943
|
}
|
|
6894
|
-
} :
|
|
6895
|
-
path: k,
|
|
6896
|
-
value: v
|
|
6897
|
-
} } : {};
|
|
6944
|
+
} : crossedSorted ? { wholeArrayRevert: crossedSorted } : {};
|
|
6898
6945
|
pushDeclaredFinding(findings, {
|
|
6899
6946
|
logicalId,
|
|
6900
6947
|
resourceType,
|
|
@@ -6973,6 +7020,26 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6973
7020
|
});
|
|
6974
7021
|
continue;
|
|
6975
7022
|
}
|
|
7023
|
+
if (resourceType === "AWS::RedshiftServerless::Workgroup" && k === "ConfigParameters" && Array.isArray(v)) {
|
|
7024
|
+
for (const el of v) {
|
|
7025
|
+
if (!el || typeof el !== "object") continue;
|
|
7026
|
+
const e = el;
|
|
7027
|
+
const pk = e.ParameterKey ?? e.parameterKey;
|
|
7028
|
+
const pv = e.ParameterValue ?? e.parameterValue;
|
|
7029
|
+
if (typeof pk !== "string") continue;
|
|
7030
|
+
const def = RS_WORKGROUP_CONFIG_PARAM_DEFAULTS[pk];
|
|
7031
|
+
const isDefault = def === void 0 || pv === def || isStringlyEqualScalar(pv, def);
|
|
7032
|
+
findings.push({
|
|
7033
|
+
tier: isDefault ? "atDefault" : "undeclared",
|
|
7034
|
+
logicalId,
|
|
7035
|
+
resourceType,
|
|
7036
|
+
path: `${k}[${pk}]`,
|
|
7037
|
+
actual: pv,
|
|
7038
|
+
nested: true
|
|
7039
|
+
});
|
|
7040
|
+
}
|
|
7041
|
+
continue;
|
|
7042
|
+
}
|
|
6976
7043
|
if (k in schema.defaults && matchesKnownDefault(v, schema.defaults[k]) || k in schema.defaultPaths && matchesKnownDefault(v, schema.defaultPaths[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)) {
|
|
6977
7044
|
findings.push({
|
|
6978
7045
|
tier: "atDefault",
|