cdk-real-drift 0.28.0 → 0.28.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/README.md +4 -4
- package/dist/cli.js +174 -160
- package/dist/cli.js.map +1 -1
- package/package.json +68 -68
package/dist/cli.js
CHANGED
|
@@ -76,7 +76,7 @@ import { CloudFrontClient, GetDistributionConfigCommand, UpdateDistributionComma
|
|
|
76
76
|
import { DescribeSignalingChannelCommand, DescribeStreamCommand, KinesisVideoClient, UpdateDataRetentionCommand, UpdateSignalingChannelCommand, UpdateStreamStorageConfigurationCommand } from "@aws-sdk/client-kinesis-video";
|
|
77
77
|
import { GetWebACLCommand, UpdateWebACLCommand, WAFV2Client } from "@aws-sdk/client-wafv2";
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
// src/exit.ts
|
|
80
80
|
function drain(stream) {
|
|
81
81
|
return new Promise((resolve) => {
|
|
82
82
|
if (stream.writableLength === 0 || stream.writableEnded) {
|
|
@@ -91,8 +91,7 @@ async function flushAndExit(code) {
|
|
|
91
91
|
process.exit(code);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
//#region src/interrupt.ts
|
|
94
|
+
// src/interrupt.ts
|
|
96
95
|
let gatherActive = false;
|
|
97
96
|
function setGatherActive(active) {
|
|
98
97
|
gatherActive = active;
|
|
@@ -122,8 +121,7 @@ function installInterruptGuard() {
|
|
|
122
121
|
process.on("uncaughtException", onFatal("uncaught exception"));
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
|
|
126
|
-
//#region src/aws-errors.ts
|
|
124
|
+
// src/aws-errors.ts
|
|
127
125
|
function isStackNotDeployed(e) {
|
|
128
126
|
const msg = e?.message ?? String(e);
|
|
129
127
|
return /does not exist/i.test(msg) || /ValidationError/i.test(msg) && /stack/i.test(msg);
|
|
@@ -203,8 +201,7 @@ function isResourceNotFoundError(e) {
|
|
|
203
201
|
return NOT_FOUND_ERROR_NAMES.has(code);
|
|
204
202
|
}
|
|
205
203
|
|
|
206
|
-
|
|
207
|
-
//#region src/revert/transient.ts
|
|
204
|
+
// src/revert/transient.ts
|
|
208
205
|
const RETRY_HINT = "the resource is still applying a previous update — retry in a few minutes";
|
|
209
206
|
const TRANSIENT_PATTERNS = [
|
|
210
207
|
{
|
|
@@ -286,8 +283,7 @@ async function retryTransient(op, opts = {}) {
|
|
|
286
283
|
return result;
|
|
287
284
|
}
|
|
288
285
|
|
|
289
|
-
|
|
290
|
-
//#region src/cli-args.ts
|
|
286
|
+
// src/cli-args.ts
|
|
291
287
|
const VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
292
288
|
"--region",
|
|
293
289
|
"--profile",
|
|
@@ -454,8 +450,7 @@ function parseCommonArgs(args, verb) {
|
|
|
454
450
|
return parsed;
|
|
455
451
|
}
|
|
456
452
|
|
|
457
|
-
|
|
458
|
-
//#region src/commands/glob-match.ts
|
|
453
|
+
// src/commands/glob-match.ts
|
|
459
454
|
/** True when `s` contains an UNESCAPED glob metachar (`*` or `?`). A `\*` / `\?` is a
|
|
460
455
|
* literal, not a wildcard, so a pattern made only of escaped metachars is NOT a glob. */
|
|
461
456
|
function isGlob(s) {
|
|
@@ -561,16 +556,14 @@ function matchesPathGlob(pattern, target) {
|
|
|
561
556
|
return new RegExp(out).test(target);
|
|
562
557
|
}
|
|
563
558
|
|
|
564
|
-
|
|
565
|
-
//#region src/construct-path.ts
|
|
559
|
+
// src/construct-path.ts
|
|
566
560
|
function withinStackPath(constructPath, stackName) {
|
|
567
561
|
const segs = constructPath.split("/");
|
|
568
562
|
for (let k = segs.length - 1; k >= 1; k--) if (segs.slice(0, k).join("-") === stackName) return segs.slice(k).join("/");
|
|
569
563
|
return constructPath;
|
|
570
564
|
}
|
|
571
565
|
|
|
572
|
-
|
|
573
|
-
//#region src/config/config-file.ts
|
|
566
|
+
// src/config/config-file.ts
|
|
574
567
|
const CONFIG_PATH = ".cdkrd/ignore.yaml";
|
|
575
568
|
const KNOWN_KEYS = /* @__PURE__ */ new Set(["ignore"]);
|
|
576
569
|
const RULE_OBJECT_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -949,8 +942,7 @@ function applyIgnores(findings, scope, config) {
|
|
|
949
942
|
});
|
|
950
943
|
}
|
|
951
944
|
|
|
952
|
-
|
|
953
|
-
//#region src/read/proxy-routing-agent.ts
|
|
945
|
+
// src/read/proxy-routing-agent.ts
|
|
954
946
|
/**
|
|
955
947
|
* An `http.Agent` that routes each request through the environment's proxy, or
|
|
956
948
|
* direct, according to `HTTPS_PROXY` / `HTTP_PROXY` / `NO_PROXY` (#1841).
|
|
@@ -1065,8 +1057,7 @@ function createInnerAgent(secure, proxyUrl) {
|
|
|
1065
1057
|
return secure ? new HttpsProxyAgent(proxyUrl, INNER_AGENT_OPTIONS) : new HttpProxyAgent(proxyUrl, INNER_AGENT_OPTIONS);
|
|
1066
1058
|
}
|
|
1067
1059
|
|
|
1068
|
-
|
|
1069
|
-
//#region src/read/client-config.ts
|
|
1060
|
+
// src/read/client-config.ts
|
|
1070
1061
|
/** Port of toolkit-lib awscli-compatible `shouldPrioritizeEnv()` (env creds win over profile). */
|
|
1071
1062
|
function shouldPrioritizeEnv() {
|
|
1072
1063
|
if (process.env.CDKRD_EXPLICIT_PROFILE) return false;
|
|
@@ -1132,8 +1123,7 @@ const READ_RETRY = {
|
|
|
1132
1123
|
}
|
|
1133
1124
|
};
|
|
1134
1125
|
|
|
1135
|
-
|
|
1136
|
-
//#region src/commands/account-gate.ts
|
|
1126
|
+
// src/commands/account-gate.ts
|
|
1137
1127
|
function mismatchTail(declaredAccount, verb) {
|
|
1138
1128
|
return verb === "revert" ? `refusing to revert (run with account-${declaredAccount} credentials to revert it)` : `skipped (run with account-${declaredAccount} credentials to ${verb} it)`;
|
|
1139
1129
|
}
|
|
@@ -1236,8 +1226,7 @@ function createAccountGate(verb) {
|
|
|
1236
1226
|
};
|
|
1237
1227
|
}
|
|
1238
1228
|
|
|
1239
|
-
|
|
1240
|
-
//#region src/synth/resolve-app.ts
|
|
1229
|
+
// src/synth/resolve-app.ts
|
|
1241
1230
|
function decodeCdkJson(buf) {
|
|
1242
1231
|
const encoding = buf[0] === 255 && buf[1] === 254 ? "utf-16le" : buf[0] === 254 && buf[1] === 255 ? "utf-16be" : "utf-8";
|
|
1243
1232
|
return new TextDecoder(encoding).decode(buf);
|
|
@@ -1260,8 +1249,7 @@ function resolveApp(explicit) {
|
|
|
1260
1249
|
return typeof json.app === "string" && json.app.length > 0 ? json.app : void 0;
|
|
1261
1250
|
}
|
|
1262
1251
|
|
|
1263
|
-
|
|
1264
|
-
//#region src/synth/io-host.ts
|
|
1252
|
+
// src/synth/io-host.ts
|
|
1265
1253
|
const APP_STDOUT = "CDK_ASSEMBLY_I1001";
|
|
1266
1254
|
const APP_STDERR = "CDK_ASSEMBLY_E1002";
|
|
1267
1255
|
const VALIDATION_REPORT = "CDK_TOOLKIT_E9600";
|
|
@@ -1329,8 +1317,7 @@ var QuietIoHost = class extends NonInteractiveIoHost {
|
|
|
1329
1317
|
}
|
|
1330
1318
|
};
|
|
1331
1319
|
|
|
1332
|
-
|
|
1333
|
-
//#region src/synth/missing-context.ts
|
|
1320
|
+
// src/synth/missing-context.ts
|
|
1334
1321
|
/**
|
|
1335
1322
|
* Collect `missing` context entries across the top-level assembly AND every nested assembly
|
|
1336
1323
|
* (recursively — a Stage-in-Stage app nests arbitrarily deep). Mirrors how `stacksRecursively`
|
|
@@ -1364,8 +1351,7 @@ function missingContextWarning(keys, opts = {}) {
|
|
|
1364
1351
|
return `${lead}\n${why}`;
|
|
1365
1352
|
}
|
|
1366
1353
|
|
|
1367
|
-
|
|
1368
|
-
//#region src/synth/synth.ts
|
|
1354
|
+
// src/synth/synth.ts
|
|
1369
1355
|
function proxyHttpOptions() {
|
|
1370
1356
|
return isProxyConfigured() ? { httpOptions: { agent: new ProxyRoutingAgent() } } : {};
|
|
1371
1357
|
}
|
|
@@ -1572,8 +1558,7 @@ async function discoverStacks(app, opts = {}) {
|
|
|
1572
1558
|
}));
|
|
1573
1559
|
}
|
|
1574
1560
|
|
|
1575
|
-
|
|
1576
|
-
//#region src/commands/resolve-stacks.ts
|
|
1561
|
+
// src/commands/resolve-stacks.ts
|
|
1577
1562
|
function regionFromIniFile(path, section) {
|
|
1578
1563
|
let text;
|
|
1579
1564
|
try {
|
|
@@ -1726,8 +1711,7 @@ async function resolveStacks(a) {
|
|
|
1726
1711
|
return out;
|
|
1727
1712
|
}
|
|
1728
1713
|
|
|
1729
|
-
|
|
1730
|
-
//#region src/normalize/intrinsic-resolver.ts
|
|
1714
|
+
// src/normalize/intrinsic-resolver.ts
|
|
1731
1715
|
const UNRESOLVED = Symbol("unresolved");
|
|
1732
1716
|
const NOVALUE = Symbol("novalue");
|
|
1733
1717
|
const CONTAINS_DYNAMIC_REFERENCE_RE = /\{\{resolve:(ssm|ssm-secure|secretsmanager):[\s\S]*?\}\}/;
|
|
@@ -2055,8 +2039,7 @@ function resolveProperties(props, ctx) {
|
|
|
2055
2039
|
return pruneNoValue(resolve$1(props, ctx));
|
|
2056
2040
|
}
|
|
2057
2041
|
|
|
2058
|
-
|
|
2059
|
-
//#region src/corpus/record.ts
|
|
2042
|
+
// src/corpus/record.ts
|
|
2060
2043
|
const CORPUS_DIR_ENV = "CDKRD_CORPUS_DIR";
|
|
2061
2044
|
const UNRESOLVED_SENTINEL = "__cdkrd_corpus_unresolved__";
|
|
2062
2045
|
function swapUnresolved(v, from, to) {
|
|
@@ -2168,8 +2151,7 @@ async function recordCorpusCase(dir, c) {
|
|
|
2168
2151
|
return p;
|
|
2169
2152
|
}
|
|
2170
2153
|
|
|
2171
|
-
|
|
2172
|
-
//#region src/normalize/cc-api-strip.ts
|
|
2154
|
+
// src/normalize/cc-api-strip.ts
|
|
2173
2155
|
const ALWAYS_STRIPPED = /* @__PURE__ */ new Set([
|
|
2174
2156
|
"CreationDate",
|
|
2175
2157
|
"CreationTime",
|
|
@@ -2253,8 +2235,7 @@ function stripWalk(value, freeForm) {
|
|
|
2253
2235
|
return value;
|
|
2254
2236
|
}
|
|
2255
2237
|
|
|
2256
|
-
|
|
2257
|
-
//#region src/normalize/noise.ts
|
|
2238
|
+
// src/normalize/noise.ts
|
|
2258
2239
|
const KNOWN_DEFAULTS = {
|
|
2259
2240
|
"AWS::IAM::Role": {
|
|
2260
2241
|
MaxSessionDuration: 3600,
|
|
@@ -4084,11 +4065,23 @@ function stripAsymmetricIdentityFields(declared, live) {
|
|
|
4084
4065
|
const ORDER_SIGNIFICANT_ARRAY_KEYS = {
|
|
4085
4066
|
"AWS::CodePipeline::Pipeline": /* @__PURE__ */ new Set(["Stages", "Actions"]),
|
|
4086
4067
|
"AWS::Logs::Transformer": /* @__PURE__ */ new Set(["TransformerConfig"]),
|
|
4087
|
-
"AWS::SSMContacts::Plan": /* @__PURE__ */ new Set(["Stages"])
|
|
4068
|
+
"AWS::SSMContacts::Plan": /* @__PURE__ */ new Set(["Stages"]),
|
|
4069
|
+
"AWS::Glue::Table": /* @__PURE__ */ new Set([
|
|
4070
|
+
"Columns",
|
|
4071
|
+
"PartitionKeys",
|
|
4072
|
+
"SortColumns"
|
|
4073
|
+
]),
|
|
4074
|
+
"AWS::Glue::Partition": /* @__PURE__ */ new Set(["Columns", "SortColumns"])
|
|
4088
4075
|
};
|
|
4089
4076
|
const ORDER_SIGNIFICANT_PATHS = {
|
|
4090
4077
|
"AWS::Scheduler::Schedule": /* @__PURE__ */ new Set(["Target.EcsParameters.PlacementStrategy"]),
|
|
4091
|
-
"AWS::AppSync::Resolver": /* @__PURE__ */ new Set(["PipelineConfig.Functions"])
|
|
4078
|
+
"AWS::AppSync::Resolver": /* @__PURE__ */ new Set(["PipelineConfig.Functions"]),
|
|
4079
|
+
"AWS::Glue::Table": /* @__PURE__ */ new Set([
|
|
4080
|
+
"TableInput.StorageDescriptor.Columns",
|
|
4081
|
+
"TableInput.PartitionKeys",
|
|
4082
|
+
"TableInput.StorageDescriptor.SortColumns",
|
|
4083
|
+
"TableInput.StorageDescriptor.BucketColumns"
|
|
4084
|
+
])
|
|
4092
4085
|
};
|
|
4093
4086
|
function canonicalizeTagListsDeep(v, orderSig) {
|
|
4094
4087
|
return canonicalizeTagLists(v, orderSig, void 0);
|
|
@@ -5072,8 +5065,7 @@ function isAllAwsTags(v) {
|
|
|
5072
5065
|
return false;
|
|
5073
5066
|
}
|
|
5074
5067
|
|
|
5075
|
-
|
|
5076
|
-
//#region src/desired/recover-nonascii.ts
|
|
5068
|
+
// src/desired/recover-nonascii.ts
|
|
5077
5069
|
function isObject(v) {
|
|
5078
5070
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
5079
5071
|
}
|
|
@@ -5090,8 +5082,7 @@ function recoverNonAsciiMasks(deployed, recovery) {
|
|
|
5090
5082
|
return deployed;
|
|
5091
5083
|
}
|
|
5092
5084
|
|
|
5093
|
-
|
|
5094
|
-
//#region src/desired/yaml-cfn.ts
|
|
5085
|
+
// src/desired/yaml-cfn.ts
|
|
5095
5086
|
const FN_TAGS = [
|
|
5096
5087
|
"GetAtt",
|
|
5097
5088
|
"Sub",
|
|
@@ -5256,8 +5247,7 @@ function parseCfnTemplate(text) {
|
|
|
5256
5247
|
return parsed;
|
|
5257
5248
|
}
|
|
5258
5249
|
|
|
5259
|
-
|
|
5260
|
-
//#region src/desired/template-adapter.ts
|
|
5250
|
+
// src/desired/template-adapter.ts
|
|
5261
5251
|
/** Parse a deployed template body (JSON or CFn-flavored YAML). */
|
|
5262
5252
|
function parseTemplateBody(body) {
|
|
5263
5253
|
return parseCfnTemplate(body);
|
|
@@ -5700,8 +5690,7 @@ function resolvePolicyName(raw, ctx) {
|
|
|
5700
5690
|
return typeof resolved === "string" ? resolved : void 0;
|
|
5701
5691
|
}
|
|
5702
5692
|
|
|
5703
|
-
|
|
5704
|
-
//#region src/normalize/arn-identity.ts
|
|
5693
|
+
// src/normalize/arn-identity.ts
|
|
5705
5694
|
function isArnNameMatch(desired, actual, opts) {
|
|
5706
5695
|
if (typeof desired !== "string" || typeof actual !== "string") return false;
|
|
5707
5696
|
const dArn = desired.startsWith("arn:");
|
|
@@ -5714,7 +5703,9 @@ function arnMatchesName(arn, name, opts) {
|
|
|
5714
5703
|
const afterSlash = afterColon.includes("/") ? afterColon.slice(afterColon.lastIndexOf("/") + 1) : afterColon;
|
|
5715
5704
|
const seg = arn.split(":");
|
|
5716
5705
|
const colonId = seg.length >= 7 ? seg.slice(6).join(":") : afterColon;
|
|
5717
|
-
if (
|
|
5706
|
+
if (seg.length >= 8) {
|
|
5707
|
+
if (name !== colonId) return false;
|
|
5708
|
+
} else if (name !== afterColon && name !== afterSlash && name !== colonId) return false;
|
|
5718
5709
|
const arnRegion = seg[3] ?? "";
|
|
5719
5710
|
const arnAccount = seg[4] ?? "";
|
|
5720
5711
|
if (opts?.region && arnRegion && arnRegion !== opts.region) return false;
|
|
@@ -5723,11 +5714,11 @@ function arnMatchesName(arn, name, opts) {
|
|
|
5723
5714
|
}
|
|
5724
5715
|
const KMS_KEY_ARN_RE = /^arn:aws[a-z-]*:kms:[^:]*:\d*:key\//;
|
|
5725
5716
|
const keyIdOf$1 = (s) => s.slice(s.lastIndexOf("/") + 1);
|
|
5726
|
-
function
|
|
5727
|
-
if (typeof desired !== "string" || typeof actual !== "string" || !desired.startsWith("alias/aws/") || !KMS_KEY_ARN_RE.test(actual)) return
|
|
5717
|
+
function managedKmsAliasVerdict(desired, actual, aliasTargets) {
|
|
5718
|
+
if (typeof desired !== "string" || typeof actual !== "string" || !desired.startsWith("alias/aws/") || !KMS_KEY_ARN_RE.test(actual)) return void 0;
|
|
5728
5719
|
const target = aliasTargets?.[desired];
|
|
5729
|
-
if (target) return
|
|
5730
|
-
return
|
|
5720
|
+
if (!target) return "unresolved";
|
|
5721
|
+
return keyIdOf$1(actual) === keyIdOf$1(target) ? "match" : "mismatch";
|
|
5731
5722
|
}
|
|
5732
5723
|
const LOG_GROUP_ARN_RE = /^arn:aws[a-z-]*:logs:[^:]*:\d*:log-group:/;
|
|
5733
5724
|
const stripLogGroupWildcard = (s) => s.endsWith(":*") ? s.slice(0, -2) : s;
|
|
@@ -5736,8 +5727,7 @@ function isLogGroupArnWildcardMatch(desired, actual) {
|
|
|
5736
5727
|
return stripLogGroupWildcard(desired) === stripLogGroupWildcard(actual);
|
|
5737
5728
|
}
|
|
5738
5729
|
|
|
5739
|
-
|
|
5740
|
-
//#region src/normalize/derived-defaults.ts
|
|
5730
|
+
// src/normalize/derived-defaults.ts
|
|
5741
5731
|
function route53HealthCheckDerivedPort(hcType) {
|
|
5742
5732
|
return hcType === "HTTP" || hcType === "HTTP_STR_MATCH" ? 80 : hcType === "HTTPS" || hcType === "HTTPS_STR_MATCH" ? 443 : void 0;
|
|
5743
5733
|
}
|
|
@@ -5780,8 +5770,7 @@ function ecsDaemonDerivedDeploymentConfiguration(schedulingStrategy) {
|
|
|
5780
5770
|
};
|
|
5781
5771
|
}
|
|
5782
5772
|
|
|
5783
|
-
|
|
5784
|
-
//#region src/read/kms-aliases.ts
|
|
5773
|
+
// src/read/kms-aliases.ts
|
|
5785
5774
|
const cache$1 = /* @__PURE__ */ new Map();
|
|
5786
5775
|
/** True when the error is a DEFINITIVE access-denial (cacheable), NOT a transient blip.
|
|
5787
5776
|
* Matches an AccessDenied(Exception) / UnauthorizedOperation by name or code, or the AWS
|
|
@@ -5836,11 +5825,11 @@ async function fetchManagedAliasTargets(region) {
|
|
|
5836
5825
|
}
|
|
5837
5826
|
}
|
|
5838
5827
|
/** The one-line warning emitted when ListAliases is denied but the stack declares an
|
|
5839
|
-
* AWS-managed alias: the managed-vs-customer key check
|
|
5840
|
-
*
|
|
5828
|
+
* AWS-managed alias: the managed-vs-customer key check cannot run, so every
|
|
5829
|
+
* `alias/aws/*` vs live-key pair is reported unverified instead of compared. Pure +
|
|
5841
5830
|
* exported so the wording is unit-tested. */
|
|
5842
5831
|
function kmsListAliasesDeniedWarning(region) {
|
|
5843
|
-
return `warning: ${region}: kms:ListAliases denied — managed-KMS-alias drift detection is degraded.
|
|
5832
|
+
return `warning: ${region}: kms:ListAliases denied — managed-KMS-alias drift detection is degraded. Whether a live key is still the AWS-managed default (alias/aws/*) cannot be verified, so those values are reported as unreadable / not compared. Grant kms:ListAliases for full coverage.`;
|
|
5844
5833
|
}
|
|
5845
5834
|
/** The one-line warning emitted when ListAliases fails TRANSIENTLY (throttle / network
|
|
5846
5835
|
* blip / 5xx) for a stack that declares an AWS-managed alias: the managed-vs-customer
|
|
@@ -5884,16 +5873,16 @@ const keyIdOf = (s) => s.slice(s.lastIndexOf("/") + 1);
|
|
|
5884
5873
|
/** #704 fold decision for an UNDECLARED managed-service-key nested path (DynamoDB SSE,
|
|
5885
5874
|
* OpenSearch EncryptionAtRest). Returns whether the value-independent fold should still
|
|
5886
5875
|
* apply for this live value:
|
|
5887
|
-
* - `true` → FOLD (atDefault): the live key IS the account/region AWS-managed key
|
|
5888
|
-
* alias could not be resolved (fail OPEN — no ListAliases / denied / transient).
|
|
5876
|
+
* - `true` → FOLD (atDefault): the live key IS the account/region AWS-managed key.
|
|
5889
5877
|
* - `false` → SURFACE (undeclared): the live key is some OTHER key (a customer-managed key
|
|
5890
|
-
* swapped in out of band — a real, security-relevant drift)
|
|
5878
|
+
* swapped in out of band — a real, security-relevant drift), OR the alias could
|
|
5879
|
+
* not be resolved (no ListAliases / denied / transient; #1952).
|
|
5891
5880
|
* Pure; `aliasTargets` is the resolved alias-name -> target-key-id map (empty when unresolved).*/
|
|
5892
5881
|
function shouldFoldManagedServiceKey(resourceType, schemaPath, liveValue, aliasTargets) {
|
|
5893
5882
|
const alias = MANAGED_KEY_ALIAS_PATHS[resourceType]?.[schemaPath];
|
|
5894
5883
|
if (!alias) return false;
|
|
5895
5884
|
const target = aliasTargets?.[alias];
|
|
5896
|
-
if (!target) return
|
|
5885
|
+
if (!target) return false;
|
|
5897
5886
|
if (typeof liveValue !== "string") return true;
|
|
5898
5887
|
return keyIdOf(liveValue) === keyIdOf(target);
|
|
5899
5888
|
}
|
|
@@ -5915,8 +5904,7 @@ function usesManagedKmsAlias(v) {
|
|
|
5915
5904
|
return false;
|
|
5916
5905
|
}
|
|
5917
5906
|
|
|
5918
|
-
|
|
5919
|
-
//#region src/normalize/path-strip.ts
|
|
5907
|
+
// src/normalize/path-strip.ts
|
|
5920
5908
|
function deepStripPaths(obj, paths) {
|
|
5921
5909
|
for (const p of paths) stripPath(obj, p.split("."));
|
|
5922
5910
|
}
|
|
@@ -5931,8 +5919,7 @@ function stripPath(node, segs) {
|
|
|
5931
5919
|
} else stripPath(container[k], rest);
|
|
5932
5920
|
}
|
|
5933
5921
|
|
|
5934
|
-
|
|
5935
|
-
//#region src/normalize/policy-canonical.ts
|
|
5922
|
+
// src/normalize/policy-canonical.ts
|
|
5936
5923
|
function isObj(v) {
|
|
5937
5924
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
5938
5925
|
}
|
|
@@ -5996,7 +5983,6 @@ function canonicalizeStatement(s) {
|
|
|
5996
5983
|
const out = {};
|
|
5997
5984
|
for (const k of Object.keys(s).sort()) {
|
|
5998
5985
|
const v = s[k];
|
|
5999
|
-
if (k === "Sid" && typeof v === "string" && /^\d+$/.test(v)) continue;
|
|
6000
5986
|
if (ARRAYISH_KEYS.has(k)) out[k] = toSortedArray(v);
|
|
6001
5987
|
else if (k === "Principal" || k === "NotPrincipal") out[k] = canonicalizePrincipal(v);
|
|
6002
5988
|
else if (k === "Condition") out[k] = canonicalizeCondition(v);
|
|
@@ -6015,7 +6001,7 @@ const AWS_LOG_DELIVERY_ALLOWED_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
6015
6001
|
function isAwsManagedLogDeliveryStatement(s) {
|
|
6016
6002
|
if (!isObj(s)) return false;
|
|
6017
6003
|
const sid = s.Sid;
|
|
6018
|
-
if (typeof sid !== "string" ||
|
|
6004
|
+
if (typeof sid !== "string" || !LOG_DELIVERY_SID_RE.test(sid)) return false;
|
|
6019
6005
|
const principal = s.Principal;
|
|
6020
6006
|
if (!isObj(principal)) return false;
|
|
6021
6007
|
const svc = principal.Service;
|
|
@@ -6024,7 +6010,28 @@ function isAwsManagedLogDeliveryStatement(s) {
|
|
|
6024
6010
|
const actionRaw = s.Action;
|
|
6025
6011
|
const actions = Array.isArray(actionRaw) ? actionRaw : [actionRaw];
|
|
6026
6012
|
if (actions.length === 0) return false;
|
|
6027
|
-
|
|
6013
|
+
if (!actions.every((a) => typeof a === "string" && AWS_LOG_DELIVERY_ALLOWED_ACTIONS.has(a))) return false;
|
|
6014
|
+
return hasSourceCondition(s.Condition);
|
|
6015
|
+
}
|
|
6016
|
+
const SOURCE_CONDITION_KEYS = /* @__PURE__ */ new Set(["aws:sourceaccount", "aws:sourcearn"]);
|
|
6017
|
+
function hasSourceCondition(cond) {
|
|
6018
|
+
if (!isObj(cond)) return false;
|
|
6019
|
+
return Object.values(cond).some((body) => isObj(body) && Object.keys(body).some((k) => SOURCE_CONDITION_KEYS.has(k.toLowerCase())));
|
|
6020
|
+
}
|
|
6021
|
+
const LOG_DELIVERY_SID_RE = /^AWSLogDelivery/;
|
|
6022
|
+
/** #1952: the Sids of every `AWSLogDelivery*` statement a (declared) value carries, at any
|
|
6023
|
+
* depth and inside JSON-string policies too. Passed back as `keepLogDeliverySids` so a
|
|
6024
|
+
* DECLARED log-delivery statement is compared instead of subtracted on both sides. */
|
|
6025
|
+
function collectLogDeliverySids(v, out = /* @__PURE__ */ new Set()) {
|
|
6026
|
+
if (typeof v === "string") {
|
|
6027
|
+
const p = parsePolicyString(v);
|
|
6028
|
+
if (p) collectLogDeliverySids(p, out);
|
|
6029
|
+
} else if (Array.isArray(v)) for (const el of v) collectLogDeliverySids(el, out);
|
|
6030
|
+
else if (isObj(v)) {
|
|
6031
|
+
if ("Effect" in v && typeof v.Sid === "string" && LOG_DELIVERY_SID_RE.test(v.Sid)) out.add(v.Sid);
|
|
6032
|
+
for (const val of Object.values(v)) collectLogDeliverySids(val, out);
|
|
6033
|
+
}
|
|
6034
|
+
return out;
|
|
6028
6035
|
}
|
|
6029
6036
|
function canonicalizePrincipal(v) {
|
|
6030
6037
|
if (isObj(v)) {
|
|
@@ -6041,13 +6048,22 @@ function normalizeAccountPrincipal(v) {
|
|
|
6041
6048
|
}
|
|
6042
6049
|
return v;
|
|
6043
6050
|
}
|
|
6044
|
-
|
|
6045
|
-
|
|
6051
|
+
const POLICY_GRAMMAR_KEYS = /* @__PURE__ */ new Set([
|
|
6052
|
+
"Version",
|
|
6053
|
+
"Id",
|
|
6054
|
+
"Statement"
|
|
6055
|
+
]);
|
|
6056
|
+
const IAM_DEFAULT_POLICY_VERSION = "2008-10-17";
|
|
6057
|
+
function canonicalizePolicy(doc, keepLogDeliverySids) {
|
|
6058
|
+
const statements = (Array.isArray(doc.Statement) ? doc.Statement : [doc.Statement]).filter((s) => !isAwsManagedLogDeliveryStatement(s) || keepLogDeliverySids?.has(s.Sid) === true);
|
|
6046
6059
|
const out = {
|
|
6047
6060
|
...doc,
|
|
6048
6061
|
Statement: statements.map(canonicalizeStatement).sort(byJson)
|
|
6049
6062
|
};
|
|
6050
|
-
if (doc.Version === void 0)
|
|
6063
|
+
if (doc.Version === void 0) {
|
|
6064
|
+
if (Object.keys(doc).every((k) => POLICY_GRAMMAR_KEYS.has(k))) out.Version = IAM_DEFAULT_POLICY_VERSION;
|
|
6065
|
+
else delete out.Version;
|
|
6066
|
+
}
|
|
6051
6067
|
return out;
|
|
6052
6068
|
}
|
|
6053
6069
|
const OAI_USER_ARN_RE = /^arn:aws[a-z-]*:iam::cloudfront:user\/CloudFront Origin Access Identity (.+)$/;
|
|
@@ -6105,31 +6121,30 @@ function sortDeep(v) {
|
|
|
6105
6121
|
* Walk a value, replacing policy-document subtrees with their canonical form and
|
|
6106
6122
|
* embedded JSON-text strings with a canonical (sorted, minified) form.
|
|
6107
6123
|
*/
|
|
6108
|
-
function normalizePoliciesDeep(v) {
|
|
6109
|
-
return normWalk(v, false);
|
|
6124
|
+
function normalizePoliciesDeep(v, keepLogDeliverySids) {
|
|
6125
|
+
return normWalk(v, false, keepLogDeliverySids);
|
|
6110
6126
|
}
|
|
6111
|
-
function normWalk(v, freeForm) {
|
|
6127
|
+
function normWalk(v, freeForm, keep) {
|
|
6112
6128
|
if (typeof v === "string") {
|
|
6113
6129
|
if (freeForm) return v;
|
|
6114
6130
|
const p = parsePolicyString(v);
|
|
6115
|
-
if (p) return canonicalizePolicy(p);
|
|
6131
|
+
if (p) return canonicalizePolicy(p, keep);
|
|
6116
6132
|
return canonicalizeJsonText(v);
|
|
6117
6133
|
}
|
|
6118
|
-
if (Array.isArray(v)) return v.map((el) => normWalk(el, freeForm));
|
|
6119
|
-
if (!freeForm && isPolicyDoc(v)) return canonicalizePolicy(v);
|
|
6134
|
+
if (Array.isArray(v)) return v.map((el) => normWalk(el, freeForm, keep));
|
|
6135
|
+
if (!freeForm && isPolicyDoc(v)) return canonicalizePolicy(v, keep);
|
|
6120
6136
|
if (isObj(v)) {
|
|
6121
6137
|
const out = {};
|
|
6122
|
-
for (const [k, val] of Object.entries(v)) out[k] = normWalk(val, freeForm || FREE_FORM_MAP_PARENTS.has(k));
|
|
6138
|
+
for (const [k, val] of Object.entries(v)) out[k] = normWalk(val, freeForm || FREE_FORM_MAP_PARENTS.has(k), keep);
|
|
6123
6139
|
return out;
|
|
6124
6140
|
}
|
|
6125
6141
|
return v;
|
|
6126
6142
|
}
|
|
6127
6143
|
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
function canonicalizeForCompare(v, resourceType) {
|
|
6144
|
+
// src/normalize/pipeline.ts
|
|
6145
|
+
function canonicalizeForCompare(v, resourceType, keepLogDeliverySids) {
|
|
6131
6146
|
const orderSig = resourceType ? ORDER_SIGNIFICANT_ARRAY_KEYS[resourceType] : void 0;
|
|
6132
|
-
const base = canonicalizeIpv6CidrsDeep(canonicalizeIdArraysDeep(canonicalizeTagListsDeep(normalizePoliciesDeep(v), orderSig)));
|
|
6147
|
+
const base = canonicalizeIpv6CidrsDeep(canonicalizeIdArraysDeep(canonicalizeTagListsDeep(normalizePoliciesDeep(v, keepLogDeliverySids), orderSig)));
|
|
6133
6148
|
return resourceType === "AWS::WAFv2::WebACL" || resourceType === "AWS::WAFv2::RuleGroup" ? normalizeWafByteMatchDeep(base) : base;
|
|
6134
6149
|
}
|
|
6135
6150
|
function sortObjectArraysDeep(v) {
|
|
@@ -6150,8 +6165,7 @@ function canonicalizeBaselineForCompare(v, resourceType, path) {
|
|
|
6150
6165
|
return sortObjectArraysDeep(canonicalizeForCompare(stripAwsTagsDeep(stripCcApiAwsManagedFields(v, freeFormSeed)), resourceType));
|
|
6151
6166
|
}
|
|
6152
6167
|
|
|
6153
|
-
|
|
6154
|
-
//#region src/normalize/stack-tags.ts
|
|
6168
|
+
// src/normalize/stack-tags.ts
|
|
6155
6169
|
const declaredTagKeys = (declared) => {
|
|
6156
6170
|
const out = /* @__PURE__ */ new Set();
|
|
6157
6171
|
const collect = (tags) => {
|
|
@@ -6212,8 +6226,7 @@ const subtractPropagatedStackTags = (live, stackTags, declaredKeys) => {
|
|
|
6212
6226
|
return out;
|
|
6213
6227
|
};
|
|
6214
6228
|
|
|
6215
|
-
|
|
6216
|
-
//#region src/diff/drift-calculator.ts
|
|
6229
|
+
// src/diff/drift-calculator.ts
|
|
6217
6230
|
function calculateResourceDrift(stateProperties, awsProperties, options) {
|
|
6218
6231
|
const drifts = [];
|
|
6219
6232
|
const ignore = options?.ignorePaths ?? [];
|
|
@@ -6292,8 +6305,7 @@ function hasPathUnsafeKey(o) {
|
|
|
6292
6305
|
return Object.keys(o).some((k) => PATH_UNSAFE_KEY$1.test(k));
|
|
6293
6306
|
}
|
|
6294
6307
|
|
|
6295
|
-
|
|
6296
|
-
//#region src/diff/classify.ts
|
|
6308
|
+
// src/diff/classify.ts
|
|
6297
6309
|
function elbAttributeDefaultsFor(resourceType, declared, live) {
|
|
6298
6310
|
const shared = ELB_ATTRIBUTE_DEFAULTS[resourceType] ?? {};
|
|
6299
6311
|
if (resourceType === "AWS::ElasticLoadBalancingV2::LoadBalancer") {
|
|
@@ -7025,7 +7037,7 @@ function sortUnorderedSetProps(model, resourceType, schemaObjectArrayKeys = [],
|
|
|
7025
7037
|
}
|
|
7026
7038
|
function normalizeLiveModel(liveRaw, schema, opts = {}) {
|
|
7027
7039
|
const oaiMap = opts.oaiCanonicalIds ?? {};
|
|
7028
|
-
const live = canonicalizeForCompare(rewriteOaiPrincipalsDeep(stripAwsTagsDeep(stripCcApiAwsManagedFields(liveRaw)), oaiMap), opts.resourceType);
|
|
7040
|
+
const live = canonicalizeForCompare(rewriteOaiPrincipalsDeep(stripAwsTagsDeep(stripCcApiAwsManagedFields(liveRaw)), oaiMap), opts.resourceType, opts.keepLogDeliverySids);
|
|
7029
7041
|
deepStripPaths(live, schema.readOnlyPaths);
|
|
7030
7042
|
deepStripPaths(live, schema.writeOnlyPaths);
|
|
7031
7043
|
if (opts.resourceType) sortUnorderedSetProps(live, opts.resourceType, (schema.unorderedObjectArrayPaths ?? []).filter((p) => !p.includes(".")), schema.unorderedScalarPaths ?? []);
|
|
@@ -7270,6 +7282,7 @@ function resolveParentObject(root, dottedPath) {
|
|
|
7270
7282
|
return node;
|
|
7271
7283
|
}
|
|
7272
7284
|
const GETTEMPLATE_MASK_NOTE = "declared value unverifiable — CloudFormation GetTemplate masks non-ASCII characters as \"?\"";
|
|
7285
|
+
const KMS_ALIAS_UNRESOLVED_NOTE = "AWS-managed KMS alias unresolved (kms:ListAliases unavailable) — cannot confirm the live key is the managed key";
|
|
7273
7286
|
function pushDeclaredFinding(findings, finding) {
|
|
7274
7287
|
if (!deepEqual(finding.desired, finding.actual) && deepEqualModuloNonAsciiMask(finding.desired, finding.actual)) {
|
|
7275
7288
|
findings.push({
|
|
@@ -7388,11 +7401,13 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
7388
7401
|
const liveForCompare = structuredClone(liveRaw);
|
|
7389
7402
|
const declaredForCompare = cloneDeepWithSymbols(declaredIn);
|
|
7390
7403
|
stripAsymmetricIdentityFields(declaredForCompare, liveForCompare);
|
|
7404
|
+
const keepLogDeliverySids = collectLogDeliverySids(declaredForCompare);
|
|
7391
7405
|
const live = subtractPropagatedStackTags(normalizeLiveModel(liveForCompare, schema, {
|
|
7392
7406
|
oaiCanonicalIds: oaiMap,
|
|
7393
|
-
resourceType
|
|
7407
|
+
resourceType,
|
|
7408
|
+
keepLogDeliverySids
|
|
7394
7409
|
}), opts.stackTags ?? {}, declaredTagKeys(declaredForCompare));
|
|
7395
|
-
let declared = canonicalizeForCompare(rewriteOaiPrincipalsDeep(declaredForCompare, oaiMap), resourceType);
|
|
7410
|
+
let declared = canonicalizeForCompare(rewriteOaiPrincipalsDeep(declaredForCompare, oaiMap), resourceType, keepLogDeliverySids);
|
|
7396
7411
|
if (resourceType === "AWS::GuardDuty::Filter") declared = canonicalizeGuardDutyCriterionKeys(declared);
|
|
7397
7412
|
const reflected = REFLECTED_CHILD_PROPS[resourceType];
|
|
7398
7413
|
if (reflected && !(reflected in declared)) delete live[reflected];
|
|
@@ -7751,7 +7766,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
7751
7766
|
}
|
|
7752
7767
|
if (physicalId && opts.accountId !== void 0 && declared["Policy"] && declared["Policy"] !== UNRESOLVED && !hasUnresolved(declared["Policy"])) {
|
|
7753
7768
|
const arnPrefix = `arn:${opts.region !== void 0 ? partitionForRegion(opts.region).partition : "aws"}:execute-api:${opts.region ?? ""}:${opts.accountId}:${physicalId}`;
|
|
7754
|
-
declared["Policy"] = canonicalizePolicy(expandExecuteApiResources(declared["Policy"], arnPrefix));
|
|
7769
|
+
declared["Policy"] = canonicalizePolicy(expandExecuteApiResources(declared["Policy"], arnPrefix), keepLogDeliverySids);
|
|
7755
7770
|
}
|
|
7756
7771
|
}
|
|
7757
7772
|
if (resourceType === "AWS::Cognito::UserPool") {
|
|
@@ -8187,7 +8202,19 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
8187
8202
|
}
|
|
8188
8203
|
}
|
|
8189
8204
|
if (isArnNameMatch(d.stateValue, d.awsValue, opts)) continue;
|
|
8190
|
-
|
|
8205
|
+
const kmsVerdict = managedKmsAliasVerdict(d.stateValue, d.awsValue, opts.kmsAliasTargets);
|
|
8206
|
+
if (kmsVerdict === "match") continue;
|
|
8207
|
+
if (kmsVerdict === "unresolved") {
|
|
8208
|
+
findings.push({
|
|
8209
|
+
tier: "readGap",
|
|
8210
|
+
logicalId,
|
|
8211
|
+
resourceType,
|
|
8212
|
+
path: d.path,
|
|
8213
|
+
note: KMS_ALIAS_UNRESOLVED_NOTE,
|
|
8214
|
+
compareOnly: true
|
|
8215
|
+
});
|
|
8216
|
+
continue;
|
|
8217
|
+
}
|
|
8191
8218
|
if (isLogGroupArnWildcardMatch(d.stateValue, d.awsValue)) continue;
|
|
8192
8219
|
if (isStringlyEqualScalar(d.stateValue, d.awsValue)) continue;
|
|
8193
8220
|
if (isStringlyEqualScalarArray(d.stateValue, d.awsValue)) continue;
|
|
@@ -8730,8 +8757,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
8730
8757
|
}));
|
|
8731
8758
|
}
|
|
8732
8759
|
|
|
8733
|
-
|
|
8734
|
-
//#region src/read/child-enumerators.ts
|
|
8760
|
+
// src/read/child-enumerators.ts
|
|
8735
8761
|
function parentRefMatches(declaredValue, ...candidates) {
|
|
8736
8762
|
if (declaredValue === UNRESOLVED || hasUnresolved(declaredValue)) return true;
|
|
8737
8763
|
return candidates.some((c) => c !== void 0 && declaredValue === c);
|
|
@@ -12415,8 +12441,7 @@ async function enumerateElasticBeanstalkApplicationChildren(ctx) {
|
|
|
12415
12441
|
});
|
|
12416
12442
|
}
|
|
12417
12443
|
|
|
12418
|
-
|
|
12419
|
-
//#region src/read/pem.ts
|
|
12444
|
+
// src/read/pem.ts
|
|
12420
12445
|
function hashCaBundle(pem) {
|
|
12421
12446
|
if (typeof pem !== "string") return void 0;
|
|
12422
12447
|
const bodies = [];
|
|
@@ -12434,8 +12459,7 @@ function sha256Hex(bytes) {
|
|
|
12434
12459
|
return createHash("sha256").update(bytes).digest("hex");
|
|
12435
12460
|
}
|
|
12436
12461
|
|
|
12437
|
-
|
|
12438
|
-
//#region src/read/overrides.ts
|
|
12462
|
+
// src/read/overrides.ts
|
|
12439
12463
|
const OVERRIDE_READ_GAP = Symbol.for("cdkrd.overrideReadGap");
|
|
12440
12464
|
function overrideReadGap(model, readGapPaths) {
|
|
12441
12465
|
return {
|
|
@@ -14894,8 +14918,7 @@ const SDK_SUPPLEMENTS = {
|
|
|
14894
14918
|
"AWS::RedshiftServerless::Workgroup": supplementRedshiftServerlessWorkgroup
|
|
14895
14919
|
};
|
|
14896
14920
|
|
|
14897
|
-
|
|
14898
|
-
//#region src/schema/schema-strip.ts
|
|
14921
|
+
// src/schema/schema-strip.ts
|
|
14899
14922
|
const cache = /* @__PURE__ */ new Map();
|
|
14900
14923
|
const EMPTY = {
|
|
14901
14924
|
readOnly: /* @__PURE__ */ new Set(),
|
|
@@ -15185,8 +15208,7 @@ function parseSchema(schemaJson) {
|
|
|
15185
15208
|
};
|
|
15186
15209
|
}
|
|
15187
15210
|
|
|
15188
|
-
|
|
15189
|
-
//#region src/read/router.ts
|
|
15211
|
+
// src/read/router.ts
|
|
15190
15212
|
const CC_IDENTIFIER_ADAPTERS = {
|
|
15191
15213
|
"AWS::AppSync::GraphQLApi": (pid) => pid.startsWith("arn:") ? pid.split("/").pop() : pid,
|
|
15192
15214
|
"AWS::Batch::JobDefinition": (pid) => {
|
|
@@ -15394,8 +15416,7 @@ async function readLive(cc, resource, region, accountId) {
|
|
|
15394
15416
|
}
|
|
15395
15417
|
}
|
|
15396
15418
|
|
|
15397
|
-
|
|
15398
|
-
//#region src/commands/gather.ts
|
|
15419
|
+
// src/commands/gather.ts
|
|
15399
15420
|
function liveModelMap(reads) {
|
|
15400
15421
|
const out = /* @__PURE__ */ new Map();
|
|
15401
15422
|
for (const [logicalId, read] of reads) if (read.live) out.set(logicalId, read.live);
|
|
@@ -16715,8 +16736,7 @@ async function regatherTouched(gathered, touched, region) {
|
|
|
16715
16736
|
return [...gathered.findings.filter((f) => !touched.has(f.logicalId)), ...fresh];
|
|
16716
16737
|
}
|
|
16717
16738
|
|
|
16718
|
-
|
|
16719
|
-
//#region src/commands/progress.ts
|
|
16739
|
+
// src/commands/progress.ts
|
|
16720
16740
|
async function gatherWithProgress(show, label, run) {
|
|
16721
16741
|
if (!show) return run();
|
|
16722
16742
|
const s = spinner();
|
|
@@ -16744,8 +16764,7 @@ function stackCountAnnouncement(stackNames) {
|
|
|
16744
16764
|
return `note: checking ${stackNames.length} stack(s): ${stackNames.join(", ")}`;
|
|
16745
16765
|
}
|
|
16746
16766
|
|
|
16747
|
-
|
|
16748
|
-
//#region src/report/redact.ts
|
|
16767
|
+
// src/report/redact.ts
|
|
16749
16768
|
function maskPlaceholder(value) {
|
|
16750
16769
|
if (typeof value === "string") {
|
|
16751
16770
|
const sig = createHash("sha256").update(value).digest("hex").slice(0, 8);
|
|
@@ -16885,8 +16904,7 @@ function redactedHashOf(sentinelOrCanonical) {
|
|
|
16885
16904
|
return isRedactedHashSentinel(sentinelOrCanonical) ? sentinelOrCanonical[REDACTION_HASH_KEY] ?? hashOfCanonical(sentinelOrCanonical) : hashOfCanonical(sentinelOrCanonical);
|
|
16886
16905
|
}
|
|
16887
16906
|
|
|
16888
|
-
|
|
16889
|
-
//#region src/baseline/baseline-file.ts
|
|
16907
|
+
// src/baseline/baseline-file.ts
|
|
16890
16908
|
const OBSERVED_DEFAULT_TRACKED_PATHS = { "AWS::S3::Bucket": ["PublicAccessBlockConfiguration"] };
|
|
16891
16909
|
const KNOWN_BASELINE_KEYS = /* @__PURE__ */ new Set([
|
|
16892
16910
|
"schemaVersion",
|
|
@@ -17173,7 +17191,7 @@ function computeCompleteResources(allLogicalIds, findings, recorded, previousCom
|
|
|
17173
17191
|
const blocked = /* @__PURE__ */ new Set();
|
|
17174
17192
|
const blockedByIgnore = /* @__PURE__ */ new Set();
|
|
17175
17193
|
for (const f of findings) {
|
|
17176
|
-
if (f.tier === "skipped" || f.tier === "deleted" || f.tier === "readGap" && !f.writeOnly) blocked.add(f.logicalId);
|
|
17194
|
+
if (f.tier === "skipped" || f.tier === "deleted" || f.tier === "readGap" && !f.writeOnly && !f.compareOnly) blocked.add(f.logicalId);
|
|
17177
17195
|
if (f.tier === "undeclared" && !recordedKeys.has(recordedKey(f))) blocked.add(f.logicalId);
|
|
17178
17196
|
if (f.tier === "ignored" && f.ignoredFrom === "undeclared" && !recordedKeys.has(recordedKey(f))) blockedByIgnore.add(f.logicalId);
|
|
17179
17197
|
}
|
|
@@ -18039,8 +18057,7 @@ function warnTemplateHashDrift(baseline, rawTemplate, stackName, warn = console.
|
|
|
18039
18057
|
if (baseline.templateHash !== hashTemplate(rawTemplate)) warn(`note: ${stackName}: baseline was captured against a different template version — consider re-running \`cdkrd record\`.`);
|
|
18040
18058
|
}
|
|
18041
18059
|
|
|
18042
|
-
|
|
18043
|
-
//#region src/diff/hints.ts
|
|
18060
|
+
// src/diff/hints.ts
|
|
18044
18061
|
const APP_SIGNALS_HINT = "looks like CloudWatch Application Signals / Lambda Insights auto-instrumentation — typically enabled at the account/region level (a CloudWatch setting), not a per-resource edit; declare it in CDK to make it intent, or record/ignore to accept it";
|
|
18045
18062
|
const INSIGHTS_LAYER = /:layer:LambdaInsightsExtension(-Arm64)?:/;
|
|
18046
18063
|
const INSIGHTS_POLICY = /(AWSLambdaTracerAccessExecutionRole|CloudWatchLambdaInsightsExecutionRolePolicy)/;
|
|
@@ -18083,8 +18100,7 @@ function annotateHints(findings) {
|
|
|
18083
18100
|
});
|
|
18084
18101
|
}
|
|
18085
18102
|
|
|
18086
|
-
|
|
18087
|
-
//#region src/report/style.ts
|
|
18103
|
+
// src/report/style.ts
|
|
18088
18104
|
/** Build the palette on top of a picocolors instance (identity when disabled). */
|
|
18089
18105
|
function makeStyle(c) {
|
|
18090
18106
|
return {
|
|
@@ -18106,8 +18122,7 @@ function makeStyle(c) {
|
|
|
18106
18122
|
const colorEnabled = process.stdout.isTTY === true && process.env["NO_COLOR"] === void 0;
|
|
18107
18123
|
const style = makeStyle(pc.createColors(colorEnabled));
|
|
18108
18124
|
|
|
18109
|
-
|
|
18110
|
-
//#region src/report/report.ts
|
|
18125
|
+
// src/report/report.ts
|
|
18111
18126
|
function stackNameFromHeader(header) {
|
|
18112
18127
|
return header.replace(/\s*\([^)]*\)\s*$/, "");
|
|
18113
18128
|
}
|
|
@@ -18439,8 +18454,7 @@ function jPair(a, b) {
|
|
|
18439
18454
|
};
|
|
18440
18455
|
}
|
|
18441
18456
|
|
|
18442
|
-
|
|
18443
|
-
//#region src/commands/bulk-multiselect.ts
|
|
18457
|
+
// src/commands/bulk-multiselect.ts
|
|
18444
18458
|
/** The selected-value array after a bulk action — `all` selects every option, `none`
|
|
18445
18459
|
* clears it. Pure (no prompt state) so the →/← wiring is unit-testable without a TTY. */
|
|
18446
18460
|
function bulkSelectValues(options, action) {
|
|
@@ -18501,8 +18515,7 @@ async function bulkMultiselect(message, options) {
|
|
|
18501
18515
|
return picked ?? [];
|
|
18502
18516
|
}
|
|
18503
18517
|
|
|
18504
|
-
|
|
18505
|
-
//#region src/revert/apply-ops.ts
|
|
18518
|
+
// src/revert/apply-ops.ts
|
|
18506
18519
|
function unescape(seg) {
|
|
18507
18520
|
return seg.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
18508
18521
|
}
|
|
@@ -18534,8 +18547,7 @@ function removeAt(root, segs) {
|
|
|
18534
18547
|
delete node[segs[segs.length - 1]];
|
|
18535
18548
|
}
|
|
18536
18549
|
|
|
18537
|
-
|
|
18538
|
-
//#region src/revert/writers.ts
|
|
18550
|
+
// src/revert/writers.ts
|
|
18539
18551
|
const str = (v) => typeof v === "string" && v.length > 0 ? v : void 0;
|
|
18540
18552
|
const strList = (v) => (Array.isArray(v) ? v : [v]).map(str).filter((s) => s !== void 0);
|
|
18541
18553
|
const opTopSeg = (path) => path.replace(/^\//, "").split("/")[0] ?? "";
|
|
@@ -18556,7 +18568,7 @@ async function desiredModel(type, ctx, ops) {
|
|
|
18556
18568
|
const current = (reader && await reader(ctx)) ?? {};
|
|
18557
18569
|
const aligned = current.PolicyDocument === void 0 ? current : {
|
|
18558
18570
|
...current,
|
|
18559
|
-
PolicyDocument: canonicalizeForCompare(current.PolicyDocument)
|
|
18571
|
+
PolicyDocument: canonicalizeForCompare(current.PolicyDocument, void 0, collectLogDeliverySids(ctx.declared))
|
|
18560
18572
|
};
|
|
18561
18573
|
assertIndexedPriorsFresh(type, aligned, ops);
|
|
18562
18574
|
return applyOps(aligned, ops);
|
|
@@ -20848,8 +20860,7 @@ const SDK_DELETERS = {
|
|
|
20848
20860
|
"AWS::Glue::Table": deleteGlueTable
|
|
20849
20861
|
};
|
|
20850
20862
|
|
|
20851
|
-
|
|
20852
|
-
//#region src/revert/plan.ts
|
|
20863
|
+
// src/revert/plan.ts
|
|
20853
20864
|
const WRITEONLY_NESTED_NO_CC_REVERT = {};
|
|
20854
20865
|
const SYNTHETIC_READ_SIGNAL_PATHS = {
|
|
20855
20866
|
"AWS::ElasticLoadBalancingV2::TrustStore": ["CaCertificatesBundleSha256"],
|
|
@@ -20857,6 +20868,15 @@ const SYNTHETIC_READ_SIGNAL_PATHS = {
|
|
|
20857
20868
|
"AWS::Glue::Job": ["ScriptSha256"]
|
|
20858
20869
|
};
|
|
20859
20870
|
const WRITEONLY_REINCLUDE_SKIP = { "AWS::Lambda::Function": ["Code"] };
|
|
20871
|
+
const WRITEONLY_REINCLUDE_OVERRIDE_READABLE = { "AWS::ECS::Service": ["VolumeConfigurations"] };
|
|
20872
|
+
function sdkRevertedOverrideReadablePaths(items, logicalId, resourceType) {
|
|
20873
|
+
const out = /* @__PURE__ */ new Set();
|
|
20874
|
+
for (const path of WRITEONLY_REINCLUDE_OVERRIDE_READABLE[resourceType] ?? []) {
|
|
20875
|
+
const ptr = toPointer(path);
|
|
20876
|
+
if (items.some((i) => i.kind === "sdk" && i.logicalId === logicalId && i.ops.some((o) => o.path === ptr || o.path.startsWith(`${ptr}/`)))) out.add(path);
|
|
20877
|
+
}
|
|
20878
|
+
return out;
|
|
20879
|
+
}
|
|
20860
20880
|
const CC_REVERTABLE_DESPITE_READ_OVERRIDE = /* @__PURE__ */ new Set([
|
|
20861
20881
|
"AWS::Scheduler::Schedule",
|
|
20862
20882
|
"AWS::Cognito::IdentityPool",
|
|
@@ -21595,17 +21615,22 @@ function valueAtDottedPath(model, path) {
|
|
|
21595
21615
|
}
|
|
21596
21616
|
return node;
|
|
21597
21617
|
}
|
|
21598
|
-
function writeOnlyReincludeOps(declared, schema, existingOps, resourceType) {
|
|
21599
|
-
if (!declared || !schema
|
|
21618
|
+
function writeOnlyReincludeOps(declared, schema, existingOps, resourceType, live, declaredSourced) {
|
|
21619
|
+
if (!declared || !schema) return [];
|
|
21620
|
+
const overrideReadable = resourceType ? WRITEONLY_REINCLUDE_OVERRIDE_READABLE[resourceType] ?? [] : [];
|
|
21621
|
+
const writeOnlyPaths = [...schema.writeOnlyPaths, ...overrideReadable.filter((p) => !schema.writeOnlyPaths.includes(p))];
|
|
21622
|
+
if (writeOnlyPaths.length === 0) return [];
|
|
21600
21623
|
const touched = new Set(existingOps.map((o) => o.path));
|
|
21601
21624
|
const skipPrefixes = resourceType ? WRITEONLY_REINCLUDE_SKIP[resourceType] ?? [] : [];
|
|
21602
21625
|
const ops = [];
|
|
21603
|
-
for (const path of
|
|
21626
|
+
for (const path of writeOnlyPaths) {
|
|
21604
21627
|
if (path.includes("*")) continue;
|
|
21605
21628
|
if (skipPrefixes.some((p) => path === p || path.startsWith(`${p}.`))) continue;
|
|
21606
21629
|
if (isUnderCreateOnly(path, schema.createOnlyPaths)) continue;
|
|
21607
21630
|
if (isUnderCreateOnly(path, schema.conditionalCreateOnlyPaths ?? [])) continue;
|
|
21608
|
-
const
|
|
21631
|
+
const fromLive = overrideReadable.includes(path) && !declaredSourced?.has(path);
|
|
21632
|
+
if (overrideReadable.includes(path) && valueAtDottedPath(declared, path) === void 0) continue;
|
|
21633
|
+
const value = fromLive ? live ? valueAtDottedPath(live, path) : void 0 : valueAtDottedPath(declared, path);
|
|
21609
21634
|
if (value === void 0 || value === UNRESOLVED || hasUnresolved(value)) continue;
|
|
21610
21635
|
const pointer = toPointer(path);
|
|
21611
21636
|
if (touched.has(pointer)) continue;
|
|
@@ -21782,8 +21807,7 @@ function toPatchDocument(item, liveRaw = item.liveRaw) {
|
|
|
21782
21807
|
return JSON.stringify(doc);
|
|
21783
21808
|
}
|
|
21784
21809
|
|
|
21785
|
-
|
|
21786
|
-
//#region src/revert/apply.ts
|
|
21810
|
+
// src/revert/apply.ts
|
|
21787
21811
|
const POLL_INTERVAL_MS = 2e3;
|
|
21788
21812
|
const TIMEOUT_MS = 9e5;
|
|
21789
21813
|
const MAX_POLL_READ_FAILURES = 10;
|
|
@@ -21939,8 +21963,7 @@ async function applyRevertDeleteSdk(doDelete, retry = {}) {
|
|
|
21939
21963
|
return retryDeleteDeferringDependencies(oneDelete, retry);
|
|
21940
21964
|
}
|
|
21941
21965
|
|
|
21942
|
-
|
|
21943
|
-
//#region src/commands/stack-actions.ts
|
|
21966
|
+
// src/commands/stack-actions.ts
|
|
21944
21967
|
const isDrift = (f) => (f.tier === "deleted" || f.tier === "added" || f.tier === "declared" || f.tier === "undeclared") && !f.unrecorded;
|
|
21945
21968
|
const driftCount = (findings) => findings.filter(isDrift).length;
|
|
21946
21969
|
const unrecordedCount = (findings) => findings.filter((f) => f.unrecorded === true).length;
|
|
@@ -22544,11 +22567,11 @@ const CONVERGE_RETRY_DELAY_MS = 3e3;
|
|
|
22544
22567
|
function includeUnrecordedRemovals(removeUnrecorded, interactive, yes) {
|
|
22545
22568
|
return removeUnrecorded || interactive && !yes;
|
|
22546
22569
|
}
|
|
22547
|
-
function augmentCcItemOps(item, schemas, liveByLogical, declaredByLogical) {
|
|
22570
|
+
function augmentCcItemOps(item, schemas, liveByLogical, declaredByLogical, planItems = []) {
|
|
22548
22571
|
if (item.kind !== "cc") return item;
|
|
22549
22572
|
const liveRaw = liveByLogical.get(item.logicalId);
|
|
22550
22573
|
const tagged = tagPreservingOps(item.ops, liveRaw);
|
|
22551
|
-
const extra = writeOnlyReincludeOps(declaredByLogical(item.logicalId), schemas.get(item.resourceType), tagged, item.resourceType);
|
|
22574
|
+
const extra = writeOnlyReincludeOps(declaredByLogical(item.logicalId), schemas.get(item.resourceType), tagged, item.resourceType, liveRaw, sdkRevertedOverrideReadablePaths(planItems, item.logicalId, item.resourceType));
|
|
22552
22575
|
const strip = rejectedEmptyStripOps(item.resourceType, [...tagged, ...extra], liveRaw);
|
|
22553
22576
|
const combined = [
|
|
22554
22577
|
...tagged,
|
|
@@ -22571,7 +22594,7 @@ function attributeOpFailure(item, error) {
|
|
|
22571
22594
|
function augmentRevertPlan(plan, schemas, liveByLogical, declaredByLogical) {
|
|
22572
22595
|
return {
|
|
22573
22596
|
...plan,
|
|
22574
|
-
items: plan.items.map((item) => augmentCcItemOps(item, schemas, liveByLogical, declaredByLogical))
|
|
22597
|
+
items: plan.items.map((item) => augmentCcItemOps(item, schemas, liveByLogical, declaredByLogical, plan.items))
|
|
22575
22598
|
};
|
|
22576
22599
|
}
|
|
22577
22600
|
async function revertStack(p) {
|
|
@@ -22646,7 +22669,7 @@ async function revertStack(p) {
|
|
|
22646
22669
|
if (!yes) {
|
|
22647
22670
|
if (!interactive) {
|
|
22648
22671
|
const reason = "refusing to write to AWS non-interactively — pass --yes to apply (or --dry-run to preview).";
|
|
22649
|
-
console.error("\
|
|
22672
|
+
console.error("\n" + reason);
|
|
22650
22673
|
return {
|
|
22651
22674
|
exit: 2,
|
|
22652
22675
|
aborted: false,
|
|
@@ -22890,8 +22913,7 @@ function availableActions(findings, baseline, schemas, removeUnrecorded) {
|
|
|
22890
22913
|
};
|
|
22891
22914
|
}
|
|
22892
22915
|
|
|
22893
|
-
|
|
22894
|
-
//#region src/commands/verb-json.ts
|
|
22916
|
+
// src/commands/verb-json.ts
|
|
22895
22917
|
function stackLabel(stackName, region) {
|
|
22896
22918
|
return region ? `${stackName} (${region})` : stackName;
|
|
22897
22919
|
}
|
|
@@ -22899,8 +22921,7 @@ function emitJsonArray(reports) {
|
|
|
22899
22921
|
console.log(JSON.stringify(reports, null, 2));
|
|
22900
22922
|
}
|
|
22901
22923
|
|
|
22902
|
-
|
|
22903
|
-
//#region src/commands/record.ts
|
|
22924
|
+
// src/commands/record.ts
|
|
22904
22925
|
async function runRecord(args) {
|
|
22905
22926
|
const a = parseCommonArgs(args, "record");
|
|
22906
22927
|
if (a.profile) process.env.AWS_PROFILE = a.profile;
|
|
@@ -23031,8 +23052,7 @@ async function runRecord(args) {
|
|
|
23031
23052
|
return worst;
|
|
23032
23053
|
}
|
|
23033
23054
|
|
|
23034
|
-
|
|
23035
|
-
//#region src/commands/ignore.ts
|
|
23055
|
+
// src/commands/ignore.ts
|
|
23036
23056
|
function ignoreApplyBaselineOpts(desired) {
|
|
23037
23057
|
return {
|
|
23038
23058
|
declaredByLogical: declaredKeysByLogical(desired.resources),
|
|
@@ -23174,8 +23194,7 @@ async function runIgnore(args) {
|
|
|
23174
23194
|
return worst;
|
|
23175
23195
|
}
|
|
23176
23196
|
|
|
23177
|
-
|
|
23178
|
-
//#region src/commands/action-picker.ts
|
|
23197
|
+
// src/commands/action-picker.ts
|
|
23179
23198
|
/**
|
|
23180
23199
|
* The actions that apply to a finding, in cycle order (EXCLUDING the always-present
|
|
23181
23200
|
* `skip`). Mirrors the verbs' scope:
|
|
@@ -23357,8 +23376,7 @@ async function actionPicker(message, rows) {
|
|
|
23357
23376
|
return [...actions];
|
|
23358
23377
|
}
|
|
23359
23378
|
|
|
23360
|
-
|
|
23361
|
-
//#region src/commands/interactive-resolve.ts
|
|
23379
|
+
// src/commands/interactive-resolve.ts
|
|
23362
23380
|
/**
|
|
23363
23381
|
* Closing note after an interactive record inside `check` (R52). A PARTIAL record used
|
|
23364
23382
|
* to end with `baseline written: ...` and a silent failure-looking exit. State plainly
|
|
@@ -23677,8 +23695,7 @@ async function perFinding(p, decidable) {
|
|
|
23677
23695
|
};
|
|
23678
23696
|
}
|
|
23679
23697
|
|
|
23680
|
-
|
|
23681
|
-
//#region src/commands/check.ts
|
|
23698
|
+
// src/commands/check.ts
|
|
23682
23699
|
function synthKey(stackName, region, account) {
|
|
23683
23700
|
return `${stackName}\0${region ?? ""}\0${account ?? ""}`;
|
|
23684
23701
|
}
|
|
@@ -24075,8 +24092,7 @@ async function runCheck(args) {
|
|
|
24075
24092
|
return worst;
|
|
24076
24093
|
}
|
|
24077
24094
|
|
|
24078
|
-
|
|
24079
|
-
//#region src/commands/revert.ts
|
|
24095
|
+
// src/commands/revert.ts
|
|
24080
24096
|
async function runRevert(args) {
|
|
24081
24097
|
const a = parseCommonArgs(args, "revert");
|
|
24082
24098
|
if (a.profile) process.env.AWS_PROFILE = a.profile;
|
|
@@ -24222,8 +24238,7 @@ async function runRevert(args) {
|
|
|
24222
24238
|
return worst;
|
|
24223
24239
|
}
|
|
24224
24240
|
|
|
24225
|
-
|
|
24226
|
-
//#region src/cli.ts
|
|
24241
|
+
// src/cli.ts
|
|
24227
24242
|
const HELP = `cdkrd — drift detection + revert for AWS CDK, including UNDECLARED
|
|
24228
24243
|
properties that 'cdk drift' / CloudFormation drift detection never see.
|
|
24229
24244
|
|
|
@@ -24366,6 +24381,5 @@ main(argv).then((code) => flushAndExit(code)).catch((e) => {
|
|
|
24366
24381
|
return flushAndExit(2);
|
|
24367
24382
|
});
|
|
24368
24383
|
|
|
24369
|
-
//#endregion
|
|
24370
24384
|
export { };
|
|
24371
24385
|
//# sourceMappingURL=cli.js.map
|