cdk-real-drift 0.12.15 → 0.12.17

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
@@ -9783,7 +9783,9 @@ const readMetricFilter = async ({ physicalId, declared, region }) => {
9783
9783
  ...t.unit !== void 0 && { Unit: t.unit },
9784
9784
  ...t.dimensions !== void 0 && { Dimensions: t.dimensions }
9785
9785
  })),
9786
- ...mf.applyOnTransformedLogs !== void 0 && { ApplyOnTransformedLogs: mf.applyOnTransformedLogs }
9786
+ ...mf.applyOnTransformedLogs !== void 0 && { ApplyOnTransformedLogs: mf.applyOnTransformedLogs },
9787
+ ...mf.fieldSelectionCriteria !== void 0 && { FieldSelectionCriteria: mf.fieldSelectionCriteria },
9788
+ ...mf.emitSystemFieldDimensions !== void 0 && { EmitSystemFieldDimensions: mf.emitSystemFieldDimensions }
9787
9789
  };
9788
9790
  };
9789
9791
  const readSchedulerSchedule = async ({ physicalId, declared, region }) => {
@@ -14812,6 +14814,34 @@ function isNestedSdkWritable(f) {
14812
14814
  function isContractOp(op) {
14813
14815
  return op.contract === true;
14814
14816
  }
14817
+ function maskReadGapKeysOf(findings) {
14818
+ const keys = /* @__PURE__ */ new Set();
14819
+ for (const f of findings) if (f.tier === "readGap" && f.note === "declared value unverifiable — CloudFormation GetTemplate masks non-ASCII characters as \"?\"") keys.add(`${f.logicalId}\0${f.path}`);
14820
+ return keys;
14821
+ }
14822
+ function hasGetTemplateMaskedLeaf(desired, live) {
14823
+ if (typeof desired === "string" && typeof live === "string") {
14824
+ if (isCfnTemplateNonAsciiMask(desired, live)) return true;
14825
+ try {
14826
+ return hasGetTemplateMaskedLeaf(JSON.parse(desired), JSON.parse(live));
14827
+ } catch {
14828
+ return false;
14829
+ }
14830
+ }
14831
+ if (Array.isArray(desired) && Array.isArray(live)) {
14832
+ const n = Math.min(desired.length, live.length);
14833
+ for (let i = 0; i < n; i++) if (hasGetTemplateMaskedLeaf(desired[i], live[i])) return true;
14834
+ return false;
14835
+ }
14836
+ if (typeof desired === "object" && desired !== null && typeof live === "object" && live !== null && !Array.isArray(desired) && !Array.isArray(live)) {
14837
+ for (const key of Object.keys(desired)) {
14838
+ if (!Object.hasOwn(live, key)) continue;
14839
+ if (hasGetTemplateMaskedLeaf(desired[key], live[key])) return true;
14840
+ }
14841
+ return false;
14842
+ }
14843
+ return false;
14844
+ }
14815
14845
  function nullHuskRemovalOps(model) {
14816
14846
  const ops = [];
14817
14847
  const walk = (value, pointer) => {
@@ -14889,6 +14919,8 @@ function buildRevertPlan(findings, baseline, opts = {}) {
14889
14919
  const itemsByLogical = /* @__PURE__ */ new Map();
14890
14920
  const notRevertable = [];
14891
14921
  const recorded = baseline?.recorded ?? [];
14922
+ const maskGapKeys = maskReadGapKeysOf(findings);
14923
+ for (const k of opts.maskReadGapKeys ?? []) maskGapKeys.add(k);
14892
14924
  const wholeArrayEmitted = /* @__PURE__ */ new Set();
14893
14925
  for (let f of findings) {
14894
14926
  const displayId = f.constructPath ? withinStackPath(f.constructPath, opts.stackName ?? "") : f.logicalId;
@@ -14963,6 +14995,25 @@ function buildRevertPlan(findings, baseline, opts = {}) {
14963
14995
  continue;
14964
14996
  }
14965
14997
  if (!DRIFT_TIERS$1.has(f.tier)) continue;
14998
+ const maskedSiblingUnderPath = () => {
14999
+ if (maskGapKeys.size === 0) return false;
15000
+ for (const key of maskGapKeys) {
15001
+ const sep = key.indexOf("\0");
15002
+ if (key.slice(0, sep) !== f.logicalId) continue;
15003
+ const p = key.slice(sep + 1);
15004
+ if (p === f.path || p.startsWith(`${f.path}.`)) return true;
15005
+ }
15006
+ return false;
15007
+ };
15008
+ if (f.tier === "declared" && (hasGetTemplateMaskedLeaf(f.desired, f.actual) || f.wholeArrayRevert !== void 0 && maskedSiblingUnderPath())) {
15009
+ notRevertable.push({
15010
+ displayId,
15011
+ resourceType: f.resourceType,
15012
+ path: f.path,
15013
+ reason: "declared value is non-ASCII-masked by GetTemplate (\"?\") — writing it back would corrupt the live text; redeploy from your CDK app instead"
15014
+ });
15015
+ continue;
15016
+ }
14966
15017
  if (SYNTHETIC_READ_SIGNAL_PATHS[f.resourceType]?.includes(f.path)) {
14967
15018
  notRevertable.push({
14968
15019
  displayId,
@@ -16103,7 +16154,8 @@ async function revertStack(p) {
16103
16154
  schemas: gathered.schemas,
16104
16155
  siblingSgRules: buildSiblingSgRules(gathered.desired),
16105
16156
  stackName,
16106
- liveByLogical: gathered.liveByLogical
16157
+ liveByLogical: gathered.liveByLogical,
16158
+ maskReadGapKeys: maskReadGapKeysOf(reconciled)
16107
16159
  });
16108
16160
  if (plan.items.length === 0 && plan.notRevertable.length === 0) {
16109
16161
  out(style.clean(`${stackName} (${region}): no drift to revert.`));