cdk-real-drift 0.2.61 → 0.2.63
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 +68 -16
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -510,9 +510,20 @@ function validateIgnoreEntry(entry, index) {
|
|
|
510
510
|
* key) so a rule is writable even on a non-CDK / metadata-stripped stack. Pure + exported;
|
|
511
511
|
* `applyIgnores` matches the within-stack path, the full construct path (older rules), AND
|
|
512
512
|
* the logicalId, so every form works.
|
|
513
|
+
*
|
|
514
|
+
* EXCEPTION — an `added`-tier finding always keys on `logicalId`, NEVER constructPath
|
|
515
|
+
* (issue #802). For an added child the constructPath is a display LABEL
|
|
516
|
+
* (`<parent> ▸ <label>`, gather.ts) built from a NON-unique, human name — a Cognito
|
|
517
|
+
* UserPoolClient's ClientName, an SNS subscription's `protocol endpoint` — so a rule
|
|
518
|
+
* written against it silently ignores EVERY same-labelled added child under the parent,
|
|
519
|
+
* present and future. The label can also carry glob metacharacters (an https endpoint's
|
|
520
|
+
* `?query` turns the `?` into a wildcard). The logicalId form `<parent>/<CC-identifier>`
|
|
521
|
+
* is the UNIQUE identity (and `applyIgnores` matches logicalId targets), so it is the only
|
|
522
|
+
* safe thing to write. This is scoped to `added` only; declared/undeclared keep the
|
|
523
|
+
* human-friendly constructPath, whose path IS unique.
|
|
513
524
|
*/
|
|
514
525
|
function ignoreRuleFor(finding, stackName = "", accountId = "", region = "") {
|
|
515
|
-
const id = finding.constructPath ? withinStackPath(finding.constructPath, stackName) : finding.logicalId;
|
|
526
|
+
const id = finding.constructPath && finding.tier !== "added" ? withinStackPath(finding.constructPath, stackName) : finding.logicalId;
|
|
516
527
|
const rule = { path: finding.path ? `${id}.${finding.path}` : id };
|
|
517
528
|
if (stackName) rule.stack = stackName;
|
|
518
529
|
if (accountId) rule.account = accountId;
|
|
@@ -987,7 +998,19 @@ function resolveGetAtt(v, ctx) {
|
|
|
987
998
|
}
|
|
988
999
|
const model = ctx.liveAttrs[logicalId];
|
|
989
1000
|
if (!model) return UNRESOLVED;
|
|
990
|
-
const
|
|
1001
|
+
const segs = attr.split(".");
|
|
1002
|
+
if (ctx.typeOf?.[logicalId] === "AWS::CloudFormation::Stack" && segs.length >= 2 && segs[0] === "Outputs") {
|
|
1003
|
+
const outputs = model["Outputs"];
|
|
1004
|
+
if (Array.isArray(outputs)) {
|
|
1005
|
+
const key = segs[1];
|
|
1006
|
+
const entry = outputs.find((o) => o !== null && typeof o === "object" && o["OutputKey"] === key);
|
|
1007
|
+
if (entry === void 0) return UNRESOLVED;
|
|
1008
|
+
const rest = segs.slice(2);
|
|
1009
|
+
const got = rest.length === 0 ? entry["OutputValue"] : getPath(entry, ["OutputValue", ...rest]);
|
|
1010
|
+
return got === void 0 ? UNRESOLVED : got;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
const got = getPath(model, segs);
|
|
991
1014
|
return got === void 0 ? UNRESOLVED : got;
|
|
992
1015
|
}
|
|
993
1016
|
function getPath(obj, segs) {
|
|
@@ -3878,9 +3901,9 @@ function deepEqual(a, b) {
|
|
|
3878
3901
|
function isPlainObject(value) {
|
|
3879
3902
|
return typeof value === "object" && value !== null;
|
|
3880
3903
|
}
|
|
3881
|
-
const PATH_UNSAFE_KEY = /[.[\]]/;
|
|
3904
|
+
const PATH_UNSAFE_KEY$1 = /[.[\]]/;
|
|
3882
3905
|
function hasPathUnsafeKey(o) {
|
|
3883
|
-
return Object.keys(o).some((k) => PATH_UNSAFE_KEY.test(k));
|
|
3906
|
+
return Object.keys(o).some((k) => PATH_UNSAFE_KEY$1.test(k));
|
|
3884
3907
|
}
|
|
3885
3908
|
|
|
3886
3909
|
//#endregion
|
|
@@ -4173,12 +4196,17 @@ function collectNestedUndeclared(declaredVal, liveVal, path, emit, nestedArrayId
|
|
|
4173
4196
|
return;
|
|
4174
4197
|
}
|
|
4175
4198
|
if (!isNestedObject(declaredVal) || !isNestedObject(liveVal)) return;
|
|
4199
|
+
if (Object.keys(liveVal).some((k) => PATH_UNSAFE_KEY.test(k))) {
|
|
4200
|
+
emit(path, liveVal);
|
|
4201
|
+
return;
|
|
4202
|
+
}
|
|
4176
4203
|
for (const [k, val] of Object.entries(liveVal)) {
|
|
4177
4204
|
const childPath = `${path}.${k}`;
|
|
4178
4205
|
if (k in declaredVal) collectNestedUndeclared(declaredVal[k], val, childPath, emit, nestedArrayIdentity);
|
|
4179
4206
|
else emit(childPath, val);
|
|
4180
4207
|
}
|
|
4181
4208
|
}
|
|
4209
|
+
const PATH_UNSAFE_KEY = /[.[\]]/;
|
|
4182
4210
|
function sortUnorderedSetProps(model, resourceType, schemaObjectArrayKeys = []) {
|
|
4183
4211
|
const objKeys = new Set([...UNORDERED_OBJECT_ARRAY_PROPS[resourceType] ?? [], ...schemaObjectArrayKeys]);
|
|
4184
4212
|
const orderSig = ORDER_SIGNIFICANT_ARRAY_KEYS[resourceType];
|
|
@@ -5052,8 +5080,12 @@ const CHILD_ENUMERATORS = {
|
|
|
5052
5080
|
"AWS::EFS::FileSystem": enumerateEfsFileSystemChildren,
|
|
5053
5081
|
"AWS::RDS::DBCluster": enumerateRdsClusterChildren
|
|
5054
5082
|
};
|
|
5083
|
+
function isBodyDefinedRestApi(declared) {
|
|
5084
|
+
return declared.Body != null || declared.BodyS3Location != null;
|
|
5085
|
+
}
|
|
5055
5086
|
function diffApiGatewayChildren(input) {
|
|
5056
|
-
const { apiId, rootResourceId, declaredResourceIds, declaredMethodKeys, liveResources, liveMethodsByResource } = input;
|
|
5087
|
+
const { apiId, rootResourceId, declaredResourceIds, declaredMethodKeys, liveResources, liveMethodsByResource, bodyDefined } = input;
|
|
5088
|
+
if (bodyDefined) return [];
|
|
5057
5089
|
const liveRootId = liveResources.find((r) => r.path === "/")?.id;
|
|
5058
5090
|
const declaredResources = new Set(declaredResourceIds);
|
|
5059
5091
|
if (rootResourceId) declaredResources.add(rootResourceId);
|
|
@@ -5110,6 +5142,7 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
5110
5142
|
if (!apiId) return [];
|
|
5111
5143
|
const restApiLive = desired.ctx.liveAttrs[parent.logicalId] ?? {};
|
|
5112
5144
|
const rootResourceId = typeof restApiLive.RootResourceId === "string" ? restApiLive.RootResourceId : void 0;
|
|
5145
|
+
const bodyDefined = isBodyDefinedRestApi(parent.declared);
|
|
5113
5146
|
const declaredResourceIds = [];
|
|
5114
5147
|
const declaredMethodKeys = [];
|
|
5115
5148
|
for (const r of desired.resources) {
|
|
@@ -5135,7 +5168,7 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
5135
5168
|
region,
|
|
5136
5169
|
...READ_RETRY
|
|
5137
5170
|
});
|
|
5138
|
-
const items = await getAllResources(client, apiId);
|
|
5171
|
+
const items = bodyDefined ? [] : await getAllResources(client, apiId);
|
|
5139
5172
|
const liveResources = items.filter((i) => typeof i.id === "string").map((i) => ({
|
|
5140
5173
|
id: i.id,
|
|
5141
5174
|
path: i.path,
|
|
@@ -5162,7 +5195,8 @@ async function enumerateRestApiChildren(ctx) {
|
|
|
5162
5195
|
declaredResourceIds,
|
|
5163
5196
|
declaredMethodKeys,
|
|
5164
5197
|
liveResources,
|
|
5165
|
-
liveMethodsByResource
|
|
5198
|
+
liveMethodsByResource,
|
|
5199
|
+
bodyDefined
|
|
5166
5200
|
});
|
|
5167
5201
|
const authorizerAdded = diffApiGatewayAuthorizers({
|
|
5168
5202
|
apiId,
|
|
@@ -8367,13 +8401,25 @@ const EMPTY = {
|
|
|
8367
8401
|
unorderedObjectArrayPaths: [],
|
|
8368
8402
|
freeFormMapPaths: []
|
|
8369
8403
|
};
|
|
8404
|
+
const failureWarned = /* @__PURE__ */ new Set();
|
|
8405
|
+
function describeTypeFailedWarning(resourceType, region) {
|
|
8406
|
+
return `warning: ${region}: cloudformation:DescribeType failed for ${resourceType} — schema-based drift suppression is degraded for this type. Undeclared read-only attributes may surface as [Potential Drift] and declared write-only properties may report false drift. Grant cloudformation:DescribeType (and retry if throttled) for full coverage.`;
|
|
8407
|
+
}
|
|
8370
8408
|
async function getSchemaInfo(client, resourceType) {
|
|
8371
|
-
const
|
|
8409
|
+
const region = await client.config.region();
|
|
8410
|
+
const cacheKey = `${region}\0${resourceType}`;
|
|
8372
8411
|
const cached = cache.get(cacheKey);
|
|
8373
8412
|
if (cached) return cached;
|
|
8374
|
-
const
|
|
8375
|
-
|
|
8376
|
-
|
|
8413
|
+
const result = await fetch$1(client, resourceType);
|
|
8414
|
+
if (result.ok) {
|
|
8415
|
+
cache.set(cacheKey, result.info);
|
|
8416
|
+
return result.info;
|
|
8417
|
+
}
|
|
8418
|
+
if (!failureWarned.has(cacheKey)) {
|
|
8419
|
+
failureWarned.add(cacheKey);
|
|
8420
|
+
console.error(describeTypeFailedWarning(resourceType, region));
|
|
8421
|
+
}
|
|
8422
|
+
return result.info;
|
|
8377
8423
|
}
|
|
8378
8424
|
const OVERRIDE_READABLE_WRITEONLY = {
|
|
8379
8425
|
"AWS::EC2::LaunchTemplate": ["LaunchTemplateData"],
|
|
@@ -8434,12 +8480,18 @@ function exemptOverrideReadable(info, resourceType) {
|
|
|
8434
8480
|
}
|
|
8435
8481
|
async function fetch$1(client, resourceType) {
|
|
8436
8482
|
try {
|
|
8437
|
-
return
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8483
|
+
return {
|
|
8484
|
+
ok: true,
|
|
8485
|
+
info: injectReaderGaps(exemptOverrideReadable(supplementReadOnly(parseSchema((await client.send(new DescribeTypeCommand({
|
|
8486
|
+
Type: "RESOURCE",
|
|
8487
|
+
TypeName: resourceType
|
|
8488
|
+
}))).Schema ?? "{}"), resourceType), resourceType), resourceType)
|
|
8489
|
+
};
|
|
8441
8490
|
} catch {
|
|
8442
|
-
return
|
|
8491
|
+
return {
|
|
8492
|
+
ok: false,
|
|
8493
|
+
info: EMPTY
|
|
8494
|
+
};
|
|
8443
8495
|
}
|
|
8444
8496
|
}
|
|
8445
8497
|
function pointerToDotted$1(p) {
|