cdk-real-drift 0.10.1 → 0.10.3
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 +118 -6
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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",
|
|
@@ -3638,6 +3637,90 @@ function canonicalizeIdArraysDeep(v) {
|
|
|
3638
3637
|
}
|
|
3639
3638
|
return v;
|
|
3640
3639
|
}
|
|
3640
|
+
function parseIpv6Groups(addr) {
|
|
3641
|
+
if (addr.includes(".")) return void 0;
|
|
3642
|
+
const dc = addr.indexOf("::");
|
|
3643
|
+
if (dc !== addr.lastIndexOf("::")) return void 0;
|
|
3644
|
+
const hextet = (part) => {
|
|
3645
|
+
if (!/^[0-9a-fA-F]{1,4}$/.test(part)) return void 0;
|
|
3646
|
+
return Number.parseInt(part, 16);
|
|
3647
|
+
};
|
|
3648
|
+
if (dc === -1) {
|
|
3649
|
+
const parts = addr.split(":");
|
|
3650
|
+
if (parts.length !== 8) return void 0;
|
|
3651
|
+
const groups = [];
|
|
3652
|
+
for (const p of parts) {
|
|
3653
|
+
const g = hextet(p);
|
|
3654
|
+
if (g === void 0) return void 0;
|
|
3655
|
+
groups.push(g);
|
|
3656
|
+
}
|
|
3657
|
+
return groups;
|
|
3658
|
+
}
|
|
3659
|
+
const head = addr.slice(0, dc);
|
|
3660
|
+
const tail = addr.slice(dc + 2);
|
|
3661
|
+
const headParts = head === "" ? [] : head.split(":");
|
|
3662
|
+
const tailParts = tail === "" ? [] : tail.split(":");
|
|
3663
|
+
const headGroups = [];
|
|
3664
|
+
for (const p of headParts) {
|
|
3665
|
+
const g = hextet(p);
|
|
3666
|
+
if (g === void 0) return void 0;
|
|
3667
|
+
headGroups.push(g);
|
|
3668
|
+
}
|
|
3669
|
+
const tailGroups = [];
|
|
3670
|
+
for (const p of tailParts) {
|
|
3671
|
+
const g = hextet(p);
|
|
3672
|
+
if (g === void 0) return void 0;
|
|
3673
|
+
tailGroups.push(g);
|
|
3674
|
+
}
|
|
3675
|
+
const missing = 8 - headGroups.length - tailGroups.length;
|
|
3676
|
+
if (missing < 1) return void 0;
|
|
3677
|
+
return [
|
|
3678
|
+
...headGroups,
|
|
3679
|
+
...new Array(missing).fill(0),
|
|
3680
|
+
...tailGroups
|
|
3681
|
+
];
|
|
3682
|
+
}
|
|
3683
|
+
function canonicalIpv6Cidr(s) {
|
|
3684
|
+
const slash = s.indexOf("/");
|
|
3685
|
+
if (slash === -1) return void 0;
|
|
3686
|
+
const addr = s.slice(0, slash);
|
|
3687
|
+
const prefixStr = s.slice(slash + 1);
|
|
3688
|
+
if (!/^\d{1,3}$/.test(prefixStr)) return void 0;
|
|
3689
|
+
const prefix = Number.parseInt(prefixStr, 10);
|
|
3690
|
+
if (prefix < 0 || prefix > 128) return void 0;
|
|
3691
|
+
const groups = parseIpv6Groups(addr);
|
|
3692
|
+
if (!groups) return void 0;
|
|
3693
|
+
let bestStart = -1;
|
|
3694
|
+
let bestLen = 0;
|
|
3695
|
+
let curStart = -1;
|
|
3696
|
+
let curLen = 0;
|
|
3697
|
+
for (let i = 0; i < 8; i++) if (groups[i] === 0) {
|
|
3698
|
+
if (curStart === -1) curStart = i;
|
|
3699
|
+
curLen++;
|
|
3700
|
+
if (curLen > bestLen) {
|
|
3701
|
+
bestLen = curLen;
|
|
3702
|
+
bestStart = curStart;
|
|
3703
|
+
}
|
|
3704
|
+
} else {
|
|
3705
|
+
curStart = -1;
|
|
3706
|
+
curLen = 0;
|
|
3707
|
+
}
|
|
3708
|
+
const hex = groups.map((g) => g.toString(16));
|
|
3709
|
+
let addrOut;
|
|
3710
|
+
if (bestLen >= 2) addrOut = `${hex.slice(0, bestStart).join(":")}::${hex.slice(bestStart + bestLen).join(":")}`;
|
|
3711
|
+
else addrOut = hex.join(":");
|
|
3712
|
+
return `${addrOut}/${prefix}`;
|
|
3713
|
+
}
|
|
3714
|
+
function canonicalizeIpv6CidrsDeep(v) {
|
|
3715
|
+
if (typeof v === "string") return canonicalIpv6Cidr(v) ?? v;
|
|
3716
|
+
if (Array.isArray(v)) return v.map(canonicalizeIpv6CidrsDeep);
|
|
3717
|
+
if (v && typeof v === "object") {
|
|
3718
|
+
const out = {};
|
|
3719
|
+
for (const [k, val] of Object.entries(v)) out[k] = canonicalizeIpv6CidrsDeep(val);
|
|
3720
|
+
return out;
|
|
3721
|
+
}
|
|
3722
|
+
return v;
|
|
3723
|
+
}
|
|
3641
3724
|
const NAME_VALUE_SUBSET_PATHS = {
|
|
3642
3725
|
"AWS::KinesisFirehose::DeliveryStream": {
|
|
3643
3726
|
re: /(^|\.)Processors\.\d+\.Parameters$/,
|
|
@@ -4801,7 +4884,7 @@ function normWalk(v, freeForm) {
|
|
|
4801
4884
|
//#region src/normalize/pipeline.ts
|
|
4802
4885
|
function canonicalizeForCompare(v, resourceType) {
|
|
4803
4886
|
const orderSig = resourceType ? ORDER_SIGNIFICANT_ARRAY_KEYS[resourceType] : void 0;
|
|
4804
|
-
const base = canonicalizeIdArraysDeep(canonicalizeTagListsDeep(normalizePoliciesDeep(v), orderSig));
|
|
4887
|
+
const base = canonicalizeIpv6CidrsDeep(canonicalizeIdArraysDeep(canonicalizeTagListsDeep(normalizePoliciesDeep(v), orderSig)));
|
|
4805
4888
|
return resourceType === "AWS::WAFv2::WebACL" || resourceType === "AWS::WAFv2::RuleGroup" ? normalizeWafByteMatchDeep(base) : base;
|
|
4806
4889
|
}
|
|
4807
4890
|
function sortObjectArraysDeep(v) {
|
|
@@ -4912,8 +4995,26 @@ const MEANINGFUL_WHEN_OFF = {
|
|
|
4912
4995
|
"AWS::EC2::NetworkInterface": { SourceDestCheck: () => true },
|
|
4913
4996
|
"AWS::Cognito::UserPoolClient": { EnableTokenRevocation: () => true },
|
|
4914
4997
|
"AWS::CloudWatch::CompositeAlarm": { ActionsEnabled: () => true },
|
|
4915
|
-
"AWS::ApplicationInsights::Application": { CWEMonitorEnabled: () => true }
|
|
4998
|
+
"AWS::ApplicationInsights::Application": { CWEMonitorEnabled: () => true },
|
|
4999
|
+
"AWS::GuardDuty::Detector": { DataSources: () => true }
|
|
4916
5000
|
};
|
|
5001
|
+
const GUARDDUTY_DEFAULT_DISABLED_FEATURES = new Set(["AI_ANALYST"]);
|
|
5002
|
+
function guardDutyFeaturesAllAtDefault(features) {
|
|
5003
|
+
const atDefault = (node) => {
|
|
5004
|
+
if (Array.isArray(node)) return node.every(atDefault);
|
|
5005
|
+
if (node !== null && typeof node === "object") {
|
|
5006
|
+
const rec = node;
|
|
5007
|
+
if ("Status" in rec) {
|
|
5008
|
+
const name = typeof rec["Name"] === "string" ? rec["Name"] : "";
|
|
5009
|
+
const defaultStatus = GUARDDUTY_DEFAULT_DISABLED_FEATURES.has(name) ? "DISABLED" : "ENABLED";
|
|
5010
|
+
if (rec["Status"] !== defaultStatus) return false;
|
|
5011
|
+
}
|
|
5012
|
+
return Object.values(rec).every(atDefault);
|
|
5013
|
+
}
|
|
5014
|
+
return true;
|
|
5015
|
+
};
|
|
5016
|
+
return features.every(atDefault);
|
|
5017
|
+
}
|
|
4917
5018
|
const stripCognitoAttrPrefix = (id) => id.replace(/^(custom|dev):/, "");
|
|
4918
5019
|
const IDENTITY_KEYED_SUBSET_ARRAYS = {
|
|
4919
5020
|
"AWS::Cognito::UserPool": { Schema: {
|
|
@@ -6092,6 +6193,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6092
6193
|
}
|
|
6093
6194
|
continue;
|
|
6094
6195
|
}
|
|
6196
|
+
if (resourceType === "AWS::GuardDuty::Detector" && k === "Features" && Array.isArray(v)) {
|
|
6197
|
+
findings.push({
|
|
6198
|
+
tier: guardDutyFeaturesAllAtDefault(v) ? "atDefault" : "undeclared",
|
|
6199
|
+
logicalId,
|
|
6200
|
+
resourceType,
|
|
6201
|
+
path: k,
|
|
6202
|
+
actual: v
|
|
6203
|
+
});
|
|
6204
|
+
continue;
|
|
6205
|
+
}
|
|
6095
6206
|
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
6207
|
findings.push({
|
|
6097
6208
|
tier: "atDefault",
|
|
@@ -6235,10 +6346,11 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6235
6346
|
}
|
|
6236
6347
|
if (isAllAwsTags(v)) continue;
|
|
6237
6348
|
if (physicalId !== void 0 && v === physicalId) continue;
|
|
6238
|
-
|
|
6349
|
+
const offStateIsMeaningful = k in knownDef && !matchesKnownDefault(v, knownDef[k]) && (MEANINGFUL_WHEN_OFF[resourceType]?.[k]?.({
|
|
6239
6350
|
declared,
|
|
6240
6351
|
live
|
|
6241
|
-
}) ?? false)
|
|
6352
|
+
}) ?? false);
|
|
6353
|
+
if (!offStateIsMeaningful && (isTrivialEmpty(v) || isSelfEchoTrivialEmpty(v, physicalId) || isEmptyPolicyShell(v))) continue;
|
|
6242
6354
|
if (isNestedObject(v) && DESCEND_UNDECLARED_OBJECT_PATHS[resourceType]?.has(k)) {
|
|
6243
6355
|
collectNestedUndeclared({}, v, k, emitNested, NESTED_ARRAY_IDENTITY[resourceType]);
|
|
6244
6356
|
continue;
|
|
@@ -6272,7 +6384,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
6272
6384
|
}
|
|
6273
6385
|
continue;
|
|
6274
6386
|
}
|
|
6275
|
-
if (isNestedObject(v) && Object.keys(v).length > 0 && allLeavesAtSchemaDefault(v, k)) {
|
|
6387
|
+
if (!offStateIsMeaningful && isNestedObject(v) && Object.keys(v).length > 0 && allLeavesAtSchemaDefault(v, k)) {
|
|
6276
6388
|
findings.push({
|
|
6277
6389
|
tier: "atDefault",
|
|
6278
6390
|
logicalId,
|