cdk-real-drift 0.12.0 → 0.12.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
@@ -3618,6 +3618,24 @@ function isCfnTemplateNonAsciiMask(declared, live) {
3618
3618
  } else masked += ch;
3619
3619
  return sawNonAscii && masked === declared;
3620
3620
  }
3621
+ function deepEqualModuloNonAsciiMask(declared, live) {
3622
+ if (declared === live) return true;
3623
+ if (typeof declared === "string" && typeof live === "string") return isCfnTemplateNonAsciiMask(declared, live);
3624
+ if (typeof declared !== "object" || typeof live !== "object" || declared === null || live === null) return false;
3625
+ if (Array.isArray(declared) || Array.isArray(live)) {
3626
+ if (!Array.isArray(declared) || !Array.isArray(live) || declared.length !== live.length) return false;
3627
+ return declared.every((v, i) => deepEqualModuloNonAsciiMask(v, live[i]));
3628
+ }
3629
+ const declaredObj = declared;
3630
+ const liveObj = live;
3631
+ const keys = Object.keys(declaredObj);
3632
+ if (keys.length !== Object.keys(liveObj).length) return false;
3633
+ for (const key of keys) {
3634
+ if (!Object.hasOwn(liveObj, key)) return false;
3635
+ if (!deepEqualModuloNonAsciiMask(declaredObj[key], liveObj[key])) return false;
3636
+ }
3637
+ return true;
3638
+ }
3621
3639
  const ID_RE = /^[a-z][a-z0-9]*-[0-9a-f]{6,}$/;
3622
3640
  const isIdLike = (s) => typeof s === "string" && (s.startsWith("arn:") || ID_RE.test(s));
3623
3641
  const AZ_NAME_RE = /^[a-z]{2}-[a-z]+(-[a-z]+)?-\d{1,2}[a-z]$/;
@@ -6007,6 +6025,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6007
6025
  declaredParsed = void 0;
6008
6026
  }
6009
6027
  if (declaredParsed !== void 0 && deepEqual(declaredParsed, liveParsed)) continue;
6028
+ if (declaredParsed !== void 0 && deepEqualModuloNonAsciiMask(declaredParsed, liveParsed) || isCfnTemplateNonAsciiMask(v, live[k])) {
6029
+ findings.push({
6030
+ tier: "readGap",
6031
+ logicalId,
6032
+ resourceType,
6033
+ path: k,
6034
+ note: "declared value unverifiable — CloudFormation GetTemplate masks non-ASCII characters as \"?\""
6035
+ });
6036
+ continue;
6037
+ }
6010
6038
  findings.push({
6011
6039
  tier: "declared",
6012
6040
  logicalId,
@@ -6584,6 +6612,19 @@ function parentRefMatches(declaredValue, ...candidates) {
6584
6612
  if (declaredValue === UNRESOLVED || hasUnresolved(declaredValue)) return true;
6585
6613
  return candidates.some((c) => c !== void 0 && declaredValue === c);
6586
6614
  }
6615
+ function unqualifiedFunctionRef(ref) {
6616
+ if (typeof ref !== "string") return ref;
6617
+ if (ref.startsWith("arn:")) {
6618
+ const seg = ref.split(":");
6619
+ if (seg.length >= 8 && seg[5] === "function") return seg.slice(0, 7).join(":");
6620
+ return ref;
6621
+ }
6622
+ const i = ref.indexOf(":");
6623
+ return i === -1 ? ref : ref.slice(0, i);
6624
+ }
6625
+ function lambdaFunctionRefMatches(declaredValue, ...candidates) {
6626
+ return parentRefMatches(unqualifiedFunctionRef(declaredValue), ...candidates.map((c) => c === void 0 ? void 0 : unqualifiedFunctionRef(c)));
6627
+ }
6587
6628
  const CHILD_ENUMERATORS = {
6588
6629
  "AWS::ApiGateway::RestApi": enumerateRestApiChildren,
6589
6630
  "AWS::ApiGatewayV2::Api": enumerateHttpApiChildren,
@@ -7292,7 +7333,7 @@ async function enumerateLambdaFunctionChildren(ctx) {
7292
7333
  for (const r of desired.resources) {
7293
7334
  if (r.resourceType !== "AWS::Lambda::EventSourceMapping" || !r.physicalId) continue;
7294
7335
  const fn = r.declared.FunctionName;
7295
- if (parentRefMatches(fn, functionName, fnArn)) declaredMappingIds.push(r.physicalId);
7336
+ if (lambdaFunctionRefMatches(fn, functionName, fnArn)) declaredMappingIds.push(r.physicalId);
7296
7337
  }
7297
7338
  const declaredUrlArns = [];
7298
7339
  for (const r of desired.resources) {
@@ -7311,7 +7352,7 @@ async function enumerateLambdaFunctionChildren(ctx) {
7311
7352
  const declaredVersionArns = [];
7312
7353
  for (const r of desired.resources) {
7313
7354
  if (r.resourceType !== "AWS::Lambda::Version" || !r.physicalId) continue;
7314
- if (parentRefMatches(r.declared.FunctionName, functionName, fnArn)) declaredVersionArns.push(r.physicalId);
7355
+ if (lambdaFunctionRefMatches(r.declared.FunctionName, functionName, fnArn)) declaredVersionArns.push(r.physicalId);
7315
7356
  }
7316
7357
  const client = new LambdaClient({
7317
7358
  region,