@go-to-k/cdkd 0.278.8 → 0.278.9

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.
@@ -9386,6 +9386,149 @@ function toSdkRules(rules) {
9386
9386
  });
9387
9387
  }
9388
9388
  /**
9389
+ * Inverse of {@link toSdkByteMatchStatement}.
9390
+ *
9391
+ * `GetWebACL` returns `SearchString` as the SDK blob type (a `Uint8Array`),
9392
+ * but the template — and therefore cdkd state — carries EITHER a plain
9393
+ * `SearchString` string OR a `SearchStringBase64` string. The bytes are
9394
+ * identical for both spellings, so the AWS value alone cannot say which
9395
+ * one to emit: only the BASELINE can. That is why every function on this
9396
+ * side takes the corresponding state node alongside the AWS node.
9397
+ *
9398
+ * Whenever the baseline string RE-ENCODES to exactly the AWS bytes, it is
9399
+ * emitted VERBATIM rather than re-derived. That is what keeps two otherwise
9400
+ * permanent false positives from appearing:
9401
+ *
9402
+ * - a non-canonical `SearchStringBase64` (whitespace / newlines, missing
9403
+ * padding, base64url) would never equal a canonically re-encoded string,
9404
+ * so the WebACL would drift forever;
9405
+ * - `Buffer.toString('utf8')` is LOSSY for non-UTF-8 bytes (U+FFFD), so a
9406
+ * binary needle under a plain-`SearchString` baseline would both drift
9407
+ * and — via `drift --accept`, which writes the AWS value into
9408
+ * `observedProperties`, then `--revert` — push a mangled needle to AWS.
9409
+ *
9410
+ * When the bytes genuinely differ from the baseline (REAL drift) or no usable
9411
+ * baseline exists, the value is derived: base64 if the baseline used base64,
9412
+ * otherwise plain UTF-8 but ONLY when that round-trips losslessly, falling
9413
+ * back to base64 so binary content is never corrupted.
9414
+ */
9415
+ function toCfnByteMatchStatement(byteMatchStatement, baseline) {
9416
+ const raw = byteMatchStatement["SearchString"];
9417
+ if (raw === void 0) return byteMatchStatement;
9418
+ const bytes = raw instanceof Uint8Array ? Buffer.from(raw) : typeof raw === "string" ? Buffer.from(raw, "utf8") : void 0;
9419
+ if (!bytes) return byteMatchStatement;
9420
+ const base = isPlainObject(baseline) ? baseline : void 0;
9421
+ const baseEncoded = base?.["SearchStringBase64"];
9422
+ const basePlain = base?.["SearchString"];
9423
+ const converted = { ...byteMatchStatement };
9424
+ delete converted["SearchString"];
9425
+ delete converted["SearchStringBase64"];
9426
+ if (typeof baseEncoded === "string" && Buffer.from(baseEncoded, "base64").equals(bytes)) {
9427
+ converted["SearchStringBase64"] = baseEncoded;
9428
+ return converted;
9429
+ }
9430
+ if (typeof basePlain === "string" && Buffer.from(basePlain, "utf8").equals(bytes)) {
9431
+ converted["SearchString"] = basePlain;
9432
+ return converted;
9433
+ }
9434
+ if (typeof baseEncoded === "string") {
9435
+ converted["SearchStringBase64"] = bytes.toString("base64");
9436
+ return converted;
9437
+ }
9438
+ const utf8 = bytes.toString("utf8");
9439
+ if (Buffer.from(utf8, "utf8").equals(bytes)) converted["SearchString"] = utf8;
9440
+ else converted["SearchStringBase64"] = bytes.toString("base64");
9441
+ return converted;
9442
+ }
9443
+ /**
9444
+ * Inverse of {@link toSdkStatement}: re-shape an AWS-returned `Statement`
9445
+ * tree back into the CFn spelling, walking the state baseline in lockstep
9446
+ * so the per-`ByteMatchStatement` spelling choice is baseline-driven.
9447
+ *
9448
+ * Recursion points are IDENTICAL to the forward walk by construction — if
9449
+ * one gains a member, so must the other, or drift silently reappears at
9450
+ * the new nesting depth. When the baseline diverges structurally (a real
9451
+ * drift, or a rule added console-side) the walk simply passes `undefined`
9452
+ * down and the defaults apply; the resulting difference is exactly the
9453
+ * drift the user should see.
9454
+ */
9455
+ function toCfnStatement(statement, baseline) {
9456
+ const converted = { ...statement };
9457
+ const base = isPlainObject(baseline) ? baseline : void 0;
9458
+ const byteMatchStatement = converted["ByteMatchStatement"];
9459
+ if (isPlainObject(byteMatchStatement)) converted["ByteMatchStatement"] = toCfnByteMatchStatement(byteMatchStatement, base?.["ByteMatchStatement"]);
9460
+ for (const key of ARN_REFERENCE_STATEMENT_KEYS) {
9461
+ const reference = converted[key];
9462
+ if (!isPlainObject(reference) || !("ARN" in reference)) continue;
9463
+ const { ARN: arn, ...rest } = reference;
9464
+ converted[key] = {
9465
+ ...rest,
9466
+ Arn: arn
9467
+ };
9468
+ }
9469
+ const notStatement = converted["NotStatement"];
9470
+ if (isPlainObject(notStatement)) {
9471
+ const nested = notStatement["Statement"];
9472
+ if (isPlainObject(nested)) {
9473
+ const baseNot = base?.["NotStatement"];
9474
+ converted["NotStatement"] = {
9475
+ ...notStatement,
9476
+ Statement: toCfnStatement(nested, isPlainObject(baseNot) ? baseNot["Statement"] : void 0)
9477
+ };
9478
+ }
9479
+ }
9480
+ for (const key of ["AndStatement", "OrStatement"]) {
9481
+ const combined = converted[key];
9482
+ if (!isPlainObject(combined)) continue;
9483
+ const nested = combined["Statements"];
9484
+ if (!Array.isArray(nested)) continue;
9485
+ const baseCombined = base?.[key];
9486
+ const baseList = isPlainObject(baseCombined) && Array.isArray(baseCombined["Statements"]) ? baseCombined["Statements"] : void 0;
9487
+ converted[key] = {
9488
+ ...combined,
9489
+ Statements: nested.map((item, i) => isPlainObject(item) ? toCfnStatement(item, baseList?.[i]) : item)
9490
+ };
9491
+ }
9492
+ for (const key of ["RateBasedStatement", "ManagedRuleGroupStatement"]) {
9493
+ const scoping = converted[key];
9494
+ if (!isPlainObject(scoping)) continue;
9495
+ const nested = scoping["ScopeDownStatement"];
9496
+ if (!isPlainObject(nested)) continue;
9497
+ const baseScoping = base?.[key];
9498
+ converted[key] = {
9499
+ ...scoping,
9500
+ ScopeDownStatement: toCfnStatement(nested, isPlainObject(baseScoping) ? baseScoping["ScopeDownStatement"] : void 0)
9501
+ };
9502
+ }
9503
+ return converted;
9504
+ }
9505
+ /**
9506
+ * Inverse of {@link toSdkRules}: re-shape the AWS `Rules` array back into
9507
+ * the CFn spelling so `cdkd drift` compares like with like.
9508
+ *
9509
+ * Without this every WebACL carrying a `ByteMatchStatement` or a reference
9510
+ * statement reported permanent phantom drift, because `drift-calculator`
9511
+ * compares `Rules` wholesale via `deepEqual` (issue #1403).
9512
+ *
9513
+ * Rules are matched to the baseline POSITIONALLY, which is what the
9514
+ * comparator itself does — a reordered or console-added rule therefore
9515
+ * still surfaces as drift, correctly.
9516
+ */
9517
+ function toCfnRules(rules, baselineRules) {
9518
+ if (!Array.isArray(rules)) return [];
9519
+ const baseList = Array.isArray(baselineRules) ? baselineRules : void 0;
9520
+ return rules.map((rule, i) => {
9521
+ if (!isPlainObject(rule)) return rule;
9522
+ const statement = rule["Statement"];
9523
+ if (!isPlainObject(statement)) return rule;
9524
+ const baseRule = baseList?.[i];
9525
+ return {
9526
+ ...rule,
9527
+ Statement: toCfnStatement(statement, isPlainObject(baseRule) ? baseRule["Statement"] : void 0)
9528
+ };
9529
+ });
9530
+ }
9531
+ /**
9389
9532
  * Collect every {@link SDK_UNSUPPORTED_RULE_KEYS} member present anywhere
9390
9533
  * in the CFn `Rules` blob, so the caller can report the silent drop.
9391
9534
  */
@@ -9647,7 +9790,7 @@ var WAFv2WebACLProvider = class {
9647
9790
  * when the ARN can't be parsed or the WebACL is gone
9648
9791
  * (`WAFNonexistentItemException`).
9649
9792
  */
9650
- async readCurrentState(physicalId, _logicalId, _resourceType) {
9793
+ async readCurrentState(physicalId, _logicalId, _resourceType, properties) {
9651
9794
  const { id, name, scope } = parseWebACLArn(physicalId);
9652
9795
  if (!id || !name) return void 0;
9653
9796
  let webACL;
@@ -9667,7 +9810,7 @@ var WAFv2WebACLProvider = class {
9667
9810
  result["Scope"] = scope;
9668
9811
  result["Description"] = webACL.Description ?? "";
9669
9812
  if (webACL.DefaultAction) result["DefaultAction"] = webACL.DefaultAction;
9670
- result["Rules"] = (webACL.Rules ?? []).map((r) => r);
9813
+ result["Rules"] = toCfnRules(webACL.Rules ?? [], properties?.["Rules"]);
9671
9814
  if (webACL.VisibilityConfig) result["VisibilityConfig"] = webACL.VisibilityConfig;
9672
9815
  result["CustomResponseBodies"] = webACL.CustomResponseBodies ?? {};
9673
9816
  if (webACL.CaptchaConfig) result["CaptchaConfig"] = webACL.CaptchaConfig;
@@ -12286,7 +12429,7 @@ var CloudControlProvider = class {
12286
12429
  if (context?.finalSnapshotIdentifier !== void 0) throw new ProvisioningError(`${logicalId} (${resourceType}) requires a final snapshot (DeletionPolicy: Snapshot), but the Cloud Control API delete route has no final-snapshot parameter. Re-run with --skip-final-snapshot after snapshotting manually, or retain the resource.`, resourceType, logicalId, physicalId);
12287
12430
  if (context?.removeProtection === true && resourceType === "AWS::AutoScaling::AutoScalingGroup") {
12288
12431
  this.logger.debug(`Delegating protected AutoScalingGroup ${logicalId} delete to the SDK ASGProvider (Cloud Control cannot force-delete a protected ASG)`);
12289
- const { ASGProvider } = await import("./asg-provider-De5hpQWP.js").then((n) => n.n);
12432
+ const { ASGProvider } = await import("./asg-provider-D9iaehAe.js").then((n) => n.n);
12290
12433
  await new ASGProvider().delete(logicalId, physicalId, resourceType, _properties, context);
12291
12434
  return;
12292
12435
  }
@@ -18709,7 +18852,7 @@ const FLUSH_INTERVAL_MS = 2e3;
18709
18852
  const FLUSH_EVENT_THRESHOLD = 50;
18710
18853
  /** Build-time cdkd version, with a dev fallback for non-built contexts. */
18711
18854
  function getCdkdVersion() {
18712
- return "0.278.8";
18855
+ return "0.278.9";
18713
18856
  }
18714
18857
  /**
18715
18858
  * Generate a time-sortable unique run id, e.g.
@@ -20821,4 +20964,4 @@ var DeployEngine = class {
20821
20964
 
20822
20965
  //#endregion
20823
20966
  export { DagBuilder as $, AssetError as $t, red as A, resolveApp as At, isTerminationProtectionPropagationError as B, CFN_TEMPLATE_URL_LIMIT as Bt, isStatefulRecreateTargetSync as C, runDockerStreaming as Ct, cyan as D, synthesisStatusMessage as Dt, bold as E, Synthesizer as Et, ProviderRegistry as F, resolveStateBucketWithDefaultAndSource as Ft, normalizeAwsTagsToCfn as G, AssemblyReader as Gt, cfnRefValueFromPhysicalId as H, findLargeInlineResources as Ht, findActionableSilentDrops as I, resolveUseCdkBootstrapAssets as It, applyRoleArnIfSet as J, resolveBucketRegion as Jt, resolveExplicitPhysicalId as K, processStackMessages as Kt, CloudControlProvider as L, stateBucketExistenceConfirmed as Lt, IAMRoleProvider as M, resolveCaptureObservedState as Mt, collectInlinePolicyNamesManagedBySiblings as N, resolveSkipPrefix as Nt, gray as O, getDefaultStateBucketName as Ot, clearOnUpdateRemoval as P, resolveStateBucketWithDefault as Pt, isRetryableTransientError as Q, setAwsClients as Qt, slowCcOperationTimeoutMs as R, warnDeprecatedNoPrefixCliFlag as Rt, MULTI_REGION_RECREATE_BLOCKED_TYPES as S, __exportAll as Sn, runDockerForeground as St, formatResourceLine as T, getDockerImageBySourceHash as Tt, refStateLookupFromResource as U, uploadCfnTemplate as Ut, IntrinsicFunctionResolver as V, MIGRATE_TMP_PREFIX as Vt, WAFv2WebACLProvider as W, expectedOwnerParam as Wt, describeTypeWithThrottleRetry as X, getAwsClients as Xt, DiffCalculator as Y, AwsClients as Yt, withRetry as Z, resetAwsClients as Zt, createPreDeleteFinalSnapshot as _, SynthesisError as _n, validateAssetBucketName as _t, DeploymentEventsStore as a, LocalMigrateError as an, AssetPublisher as at, unsupportedFinalSnapshotError as b, normalizeAwsError as bn, formatDockerLoginError as bt, replayFailedOperations as c, MissingCdkCliError as cn, buildAssetRedirectMap as ct, IMPLICIT_DELETE_DEPENDENCIES as d, ProvisioningError as dn, rewriteTemplateAssetReferences as dt, CdkdError as en, TemplateParser as et, computeImplicitDeleteEdges as f, ResourceTimeoutError as fn, AssetModeResolver as ft, ccRoutedFinalSnapshotError as g, StateError as gn, parseBootstrapMarker as gt, buildFinalSnapshotIdentifier as h, StackTerminationProtectionError as hn, getBootstrapMarkerKey as ht, DeploymentEventsReader as i, LocalInvokeBuildError as in, shouldRetainResource as it, yellow as j, resolveAutoAssetStorage as jt, green as k, getLegacyStateBucketName as kt, replayRollback as l, NestedStackChildDirectDestroyError as ln, createAssetRedirectResolver as lt, PRE_DELETE_SNAPSHOT_TYPES as m, StackHasActiveImportsError as mn, ensureAssetStorage as mt, DEFAULT_RESOURCE_WARN_AFTER_MS as n, DependencyError as nn, S3StateBackend as nt, planFailedOps as o, LocalStartServiceError as on, stringifyValue as ot, ATOMIC_FINAL_SNAPSHOT_TYPES as p, ResourceUpdateNotSupportedError as pn, BOOTSTRAP_MARKER_PREFIX as pt, assertRegionMatch as q, clearBucketRegionCache as qt, DeployEngine as r, DeployCancelledError as rn, rebuildClientForBucketRegion as rt, planRollback as s, LockError as sn, WorkGraph as st, DEFAULT_RESOURCE_TIMEOUT_MS as t, ConfigError as tn, LockManager as tt, withResourceDeadline as u, PartialFailureError as un, loadPublishableAssetManifest as ut, isFinalSnapshotError as v, formatError as vn, validateContainerRepoName as vt, renderStatefulReason as w, AssetManifestLoader as wt, extractDeploymentEventError as x, withErrorHandling as xn, getDockerCmd as xt, refusesFinalSnapshot as y, isCdkdError as yn, buildDockerImage as yt, disableInstanceApiTermination as z, CFN_TEMPLATE_BODY_LIMIT as zt };
20824
- //# sourceMappingURL=deploy-engine-HAlYSktR.js.map
20967
+ //# sourceMappingURL=deploy-engine-D304rUnl.js.map