cdk-real-drift 0.4.11 → 0.4.13
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 +17 -4
- package/dist/cli.js +174 -31
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -309,6 +309,16 @@ from `--app`: a command (`--app "node bin/app.js"`) or a pre-synthesized assembl
|
|
|
309
309
|
comparison still reads each stack's **deployed** template + live state from AWS;
|
|
310
310
|
synth only tells cdkrd which stacks to look at.
|
|
311
311
|
|
|
312
|
+
**Context lookups.** Resolving a CDK app that uses `fromLookup`
|
|
313
|
+
(`Vpc.fromLookup`, `HostedZone.fromLookup`, …) runs the same live AWS context
|
|
314
|
+
lookups as `cdk synth` and caches the results in `cdk.context.json` in your app
|
|
315
|
+
directory — so an app with uncached lookups will make read-only AWS calls and
|
|
316
|
+
create/update that file (a `git status` change is expected; the cache makes
|
|
317
|
+
subsequent checks reproducible). cdkrd prints a one-liner when it does so. This
|
|
318
|
+
matches `cdk synth` semantics and is the only file `check` writes; it never writes
|
|
319
|
+
to AWS. If every lookup fails (leaving only an empty `{}`), cdkrd removes the file
|
|
320
|
+
it just created rather than leave that noise in your tree.
|
|
321
|
+
|
|
312
322
|
## Commands & options
|
|
313
323
|
|
|
314
324
|
| command | does |
|
|
@@ -333,10 +343,13 @@ CI (with `--yes`).
|
|
|
333
343
|
is always surfaced regardless (as the `skipped=N` footer line or a loud
|
|
334
344
|
`warning:`); `--strict` only decides whether it fails the build.
|
|
335
345
|
- Errors always exit `2`; `revert` exits `1` when drift remains after it.
|
|
336
|
-
- Interrupting a run with **Ctrl-C** (or **ESC**) during the gather/read
|
|
337
|
-
exits `130` (128 + SIGINT) for every verb
|
|
338
|
-
|
|
339
|
-
never
|
|
346
|
+
- Interrupting a run with **Ctrl-C** (or **ESC** / SIGINT) during the gather/read
|
|
347
|
+
phase exits `130` (128 + SIGINT) for every verb, and a **SIGTERM** (CI
|
|
348
|
+
cancellation, `timeout`, a supervisor) exits `143` promptly on the first signal
|
|
349
|
+
— never `0`, so an aborted `check --fail` can never be mistaken for "no drift"
|
|
350
|
+
and an aborted `record` is never a false "written". An unhandled internal error
|
|
351
|
+
(a stray promise rejection / uncaught exception) always exits `2` (the error
|
|
352
|
+
code), never `0` or `1`.
|
|
340
353
|
|
|
341
354
|
```yaml
|
|
342
355
|
- run: npm ci # cdkrd resolves the CDK app, so its deps must be installed
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
3
3
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
5
5
|
import { YAMLSeq, isSeq, parse, parseDocument } from "yaml";
|
|
@@ -87,12 +87,20 @@ function installInterruptGuard() {
|
|
|
87
87
|
installed = true;
|
|
88
88
|
const realExit = process.exit.bind(process);
|
|
89
89
|
process.exit = (code) => realExit(interruptExitCode(code, gatherActive));
|
|
90
|
-
const onSignal = () => {
|
|
90
|
+
const onSignal = (code) => () => {
|
|
91
91
|
process.stderr.write("\x1B[?25h");
|
|
92
|
-
return realExit(
|
|
92
|
+
return realExit(code);
|
|
93
93
|
};
|
|
94
|
-
process.on("SIGINT", onSignal);
|
|
95
|
-
process.on("SIGTERM", onSignal);
|
|
94
|
+
process.on("SIGINT", onSignal(130));
|
|
95
|
+
process.on("SIGTERM", onSignal(143));
|
|
96
|
+
const onFatal = (kind) => (err) => {
|
|
97
|
+
process.stderr.write("\x1B[?25h");
|
|
98
|
+
const detail = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
99
|
+
console.error(`error: ${kind}: ${detail}`);
|
|
100
|
+
realExit(2);
|
|
101
|
+
};
|
|
102
|
+
process.on("unhandledRejection", onFatal("unhandled rejection"));
|
|
103
|
+
process.on("uncaughtException", onFatal("uncaught exception"));
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
//#endregion
|
|
@@ -842,6 +850,8 @@ function resolveApp(explicit) {
|
|
|
842
850
|
const APP_STDOUT = "CDK_ASSEMBLY_I1001";
|
|
843
851
|
const APP_STDERR = "CDK_ASSEMBLY_E1002";
|
|
844
852
|
const VALIDATION_REPORT = "CDK_TOOLKIT_E9600";
|
|
853
|
+
const CONTEXT_FETCHING = "CDK_ASSEMBLY_I0241";
|
|
854
|
+
const CONTEXT_WRITING = "CDK_ASSEMBLY_I0042";
|
|
845
855
|
/**
|
|
846
856
|
* Decide what QuietIoHost does with a message (pure, so it is unit-testable):
|
|
847
857
|
* - the CDK app's own stdout/stderr passthrough -> emit at INFO (default color, like
|
|
@@ -849,6 +859,9 @@ const VALIDATION_REPORT = "CDK_TOOLKIT_E9600";
|
|
|
849
859
|
* - the construct-annotation validation report -> emit at WARN so the whole block is
|
|
850
860
|
* yellow (matching its WARNING label) instead of the misleading ERROR-level red
|
|
851
861
|
* wrap; per-severity labels still survive (see file header);
|
|
862
|
+
* - the context-lookup fetch / write codes -> `note` a fixed one-liner (replacing
|
|
863
|
+
* toolkit-lib's verbose debug text) so the otherwise-silent live lookup + the
|
|
864
|
+
* cdk.context.json write are visible (#906);
|
|
852
865
|
* - a real toolkit warning / error -> emit unchanged (still yellow / red);
|
|
853
866
|
* - everything else (toolkit info/debug/trace chatter) -> drop.
|
|
854
867
|
*/
|
|
@@ -861,6 +874,16 @@ function planIoMessage(msg) {
|
|
|
861
874
|
action: "emit",
|
|
862
875
|
level: "warn"
|
|
863
876
|
};
|
|
877
|
+
if (msg.code === CONTEXT_FETCHING) return {
|
|
878
|
+
action: "note",
|
|
879
|
+
level: "info",
|
|
880
|
+
text: "performing context lookups (Vpc.fromLookup, …)…"
|
|
881
|
+
};
|
|
882
|
+
if (msg.code === CONTEXT_WRITING) return {
|
|
883
|
+
action: "note",
|
|
884
|
+
level: "info",
|
|
885
|
+
text: "wrote cdk.context.json (cached context lookups)"
|
|
886
|
+
};
|
|
864
887
|
if (msg.level === "warn" || msg.level === "error") return {
|
|
865
888
|
action: "emit",
|
|
866
889
|
level: msg.level
|
|
@@ -871,9 +894,19 @@ var QuietIoHost = class extends NonInteractiveIoHost {
|
|
|
871
894
|
constructor() {
|
|
872
895
|
super({ isCI: false });
|
|
873
896
|
}
|
|
897
|
+
seenNotes = /* @__PURE__ */ new Set();
|
|
874
898
|
async notify(msg) {
|
|
875
899
|
const plan = planIoMessage(msg);
|
|
876
900
|
if (plan.action === "drop") return;
|
|
901
|
+
if (plan.action === "note") {
|
|
902
|
+
if (this.seenNotes.has(plan.text)) return;
|
|
903
|
+
this.seenNotes.add(plan.text);
|
|
904
|
+
return super.notify({
|
|
905
|
+
...msg,
|
|
906
|
+
level: plan.level,
|
|
907
|
+
message: `info: ${plan.text}`
|
|
908
|
+
});
|
|
909
|
+
}
|
|
877
910
|
return super.notify(plan.level === msg.level ? msg : {
|
|
878
911
|
...msg,
|
|
879
912
|
level: plan.level
|
|
@@ -933,6 +966,42 @@ function contextIgnoredWarning(isDir, context) {
|
|
|
933
966
|
if (!isDir || keys.length === 0) return null;
|
|
934
967
|
return `ignoring -c/--context (${keys.join(", ")}): --app points at a pre-synthesized cloud-assembly directory, whose context was baked in at synth time — there is no CDK app to re-run with new context. To apply new context, point --app at the CDK app itself (not its cdk.out).`;
|
|
935
968
|
}
|
|
969
|
+
/**
|
|
970
|
+
* Decide whether to remove a `cdk.context.json` that synth may have written (#906).
|
|
971
|
+
*
|
|
972
|
+
* For an app with context lookups but no cached context, toolkit-lib's default
|
|
973
|
+
* `CdkAppMultiContext` persists the resolved lookups into `<cwd>/cdk.context.json` — even
|
|
974
|
+
* when EVERY lookup FAILED, in which case it writes an empty `{}`. That empty file dirties
|
|
975
|
+
* the user's git tree for no benefit (it caches nothing). We remove it, but ONLY when it is
|
|
976
|
+
* safe: the file must NOT have pre-existed (so we never touch a user's committed context),
|
|
977
|
+
* AND it must be empty (`{}` / whitespace-only) now (so we never delete a file that captured
|
|
978
|
+
* real lookup results). Returns true iff the file at `file` should be deleted.
|
|
979
|
+
*/
|
|
980
|
+
function shouldRemoveEmptyContextFile(existedBefore, existsNow) {
|
|
981
|
+
return !existedBefore && existsNow;
|
|
982
|
+
}
|
|
983
|
+
/** An object with no own enumerable keys — a persisted `{}` context (an all-failed lookup). */
|
|
984
|
+
function isEmptyContextJson(raw) {
|
|
985
|
+
const trimmed = raw.trim();
|
|
986
|
+
if (trimmed === "" || trimmed === "{}") return true;
|
|
987
|
+
try {
|
|
988
|
+
const parsed = JSON.parse(trimmed);
|
|
989
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) && Object.keys(parsed).length === 0;
|
|
990
|
+
} catch {
|
|
991
|
+
return false;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Remove a `cdk.context.json` at `file` iff synth JUST created it AND it is empty (an
|
|
996
|
+
* all-failed lookup that persisted `{}`). Guarded so a pre-existing or non-empty user file
|
|
997
|
+
* is NEVER touched (#906). No-op on any read/remove error — cleanup is best-effort.
|
|
998
|
+
*/
|
|
999
|
+
function cleanupEmptyContextFile(file, existedBefore) {
|
|
1000
|
+
if (!shouldRemoveEmptyContextFile(existedBefore, existsSync(file))) return;
|
|
1001
|
+
try {
|
|
1002
|
+
if (isEmptyContextJson(readFileSync(file, "utf-8"))) rmSync(file);
|
|
1003
|
+
} catch {}
|
|
1004
|
+
}
|
|
936
1005
|
async function synthApp(app, opts = {}) {
|
|
937
1006
|
const { region, profile, context = {} } = opts;
|
|
938
1007
|
const toolkit = new Toolkit({
|
|
@@ -944,6 +1013,8 @@ async function synthApp(app, opts = {}) {
|
|
|
944
1013
|
});
|
|
945
1014
|
const p = resolve(app);
|
|
946
1015
|
const isDir = existsSync(p) && statSync(p).isDirectory();
|
|
1016
|
+
const contextFile = resolve(process.cwd(), "cdk.context.json");
|
|
1017
|
+
const contextFileExistedBefore = !isDir && existsSync(contextFile);
|
|
947
1018
|
let source;
|
|
948
1019
|
if (isDir) {
|
|
949
1020
|
const ignored = contextIgnoredWarning(isDir, context);
|
|
@@ -963,6 +1034,7 @@ async function synthApp(app, opts = {}) {
|
|
|
963
1034
|
});
|
|
964
1035
|
}
|
|
965
1036
|
const cached = await toolkit.synth(source);
|
|
1037
|
+
if (!isDir) cleanupEmptyContextFile(contextFile, contextFileExistedBefore);
|
|
966
1038
|
try {
|
|
967
1039
|
const missingKeys = missingContextKeys(collectMissingRecursively(cached.cloudAssembly));
|
|
968
1040
|
if (missingKeys.length > 0) {
|
|
@@ -1112,8 +1184,8 @@ function isScalarInterpolant(v) {
|
|
|
1112
1184
|
const t = typeof v;
|
|
1113
1185
|
return t === "string" || t === "number" || t === "boolean";
|
|
1114
1186
|
}
|
|
1115
|
-
function resolve$1(node, ctx) {
|
|
1116
|
-
if (Array.isArray(node)) return node.map((n) => resolve$1(n, ctx));
|
|
1187
|
+
function resolve$1(node, ctx, inCondition = false) {
|
|
1188
|
+
if (Array.isArray(node)) return node.map((n) => resolve$1(n, ctx, inCondition));
|
|
1117
1189
|
if (typeof node === "string" && isDynamicReference(node)) return UNRESOLVED;
|
|
1118
1190
|
if (node === null || typeof node !== "object") return node;
|
|
1119
1191
|
const obj = node;
|
|
@@ -1214,14 +1286,16 @@ function resolve$1(node, ctx) {
|
|
|
1214
1286
|
const r = condVal(v[0], ctx);
|
|
1215
1287
|
return r === UNRESOLVED ? UNRESOLVED : !r;
|
|
1216
1288
|
}
|
|
1217
|
-
case "Condition":
|
|
1289
|
+
case "Condition":
|
|
1290
|
+
if (inCondition) return evalCondition(String(v), ctx);
|
|
1291
|
+
break;
|
|
1218
1292
|
default:
|
|
1219
1293
|
if (k.startsWith("Fn::")) return UNRESOLVED;
|
|
1220
1294
|
break;
|
|
1221
1295
|
}
|
|
1222
1296
|
}
|
|
1223
1297
|
const out = {};
|
|
1224
|
-
for (const [kk, vv] of Object.entries(obj)) out[kk] = resolve$1(vv, ctx);
|
|
1298
|
+
for (const [kk, vv] of Object.entries(obj)) out[kk] = resolve$1(vv, ctx, inCondition);
|
|
1225
1299
|
return out;
|
|
1226
1300
|
}
|
|
1227
1301
|
function scalarEqual(a, b) {
|
|
@@ -1236,7 +1310,7 @@ function condVal(node, ctx) {
|
|
|
1236
1310
|
const r = evalCondition(String(node["Condition"]), ctx);
|
|
1237
1311
|
return r === UNRESOLVED ? UNRESOLVED : r === true;
|
|
1238
1312
|
}
|
|
1239
|
-
const r = resolve$1(node, ctx);
|
|
1313
|
+
const r = resolve$1(node, ctx, true);
|
|
1240
1314
|
if (r === true) return true;
|
|
1241
1315
|
if (r === false) return false;
|
|
1242
1316
|
return UNRESOLVED;
|
|
@@ -1244,7 +1318,7 @@ function condVal(node, ctx) {
|
|
|
1244
1318
|
function evalCondition(name, ctx) {
|
|
1245
1319
|
if (ctx.condCache.has(name)) return ctx.condCache.get(name);
|
|
1246
1320
|
ctx.condCache.set(name, UNRESOLVED);
|
|
1247
|
-
const r = resolve$1(ctx.conditions[name], ctx);
|
|
1321
|
+
const r = resolve$1(ctx.conditions[name], ctx, true);
|
|
1248
1322
|
const val = r === true ? true : r === false ? false : UNRESOLVED;
|
|
1249
1323
|
ctx.condCache.set(name, val);
|
|
1250
1324
|
return val;
|
|
@@ -1498,6 +1572,7 @@ const KNOWN_DEFAULTS = {
|
|
|
1498
1572
|
Description: ""
|
|
1499
1573
|
},
|
|
1500
1574
|
"AWS::IAM::ServerCertificate": { Path: "/" },
|
|
1575
|
+
"AWS::CertificateManager::Certificate": { KeyAlgorithm: "RSA_2048" },
|
|
1501
1576
|
"AWS::AppRunner::Service": {
|
|
1502
1577
|
HealthCheckConfiguration: {
|
|
1503
1578
|
Protocol: "TCP",
|
|
@@ -3398,7 +3473,8 @@ const READGAP_COLLECTION_PATHS = {
|
|
|
3398
3473
|
"AWS::Batch::JobDefinition": new Set(["Timeout"]),
|
|
3399
3474
|
"AWS::Budgets::Budget": new Set(["NotificationsWithSubscribers"]),
|
|
3400
3475
|
"AWS::DynamoDB::GlobalTable": new Set(["SSESpecification"]),
|
|
3401
|
-
"AWS::DynamoDB::Table": new Set(["SSESpecification"])
|
|
3476
|
+
"AWS::DynamoDB::Table": new Set(["SSESpecification"]),
|
|
3477
|
+
"AWS::CertificateManager::Certificate": new Set(["DomainValidationOptions"])
|
|
3402
3478
|
};
|
|
3403
3479
|
const SCALAR_RETURNED_WHEN_SET = {
|
|
3404
3480
|
"AWS::NetworkFirewall::RuleGroup": new Set(["Description"]),
|
|
@@ -3719,6 +3795,14 @@ function parseCfnTemplate(text) {
|
|
|
3719
3795
|
function parseTemplateBody(body) {
|
|
3720
3796
|
return parseCfnTemplate(body);
|
|
3721
3797
|
}
|
|
3798
|
+
function deletedResourceInfo(physIds, template, stackName) {
|
|
3799
|
+
const templateIds = new Set(Object.keys(template.Resources ?? {}));
|
|
3800
|
+
const deleted = Object.keys(physIds).filter((id) => !templateIds.has(id)).sort();
|
|
3801
|
+
if (deleted.length === 0) return null;
|
|
3802
|
+
const shown = deleted.slice(0, 10);
|
|
3803
|
+
const more = deleted.length > shown.length ? `, …(+${deleted.length - shown.length} more)` : "";
|
|
3804
|
+
return `info: ${stackName}: ${deleted.length} deployed resource(s) absent from the local template — the next deploy will DELETE them: ${shown.join(", ")}${more}`;
|
|
3805
|
+
}
|
|
3722
3806
|
function partitionForRegion(region) {
|
|
3723
3807
|
if (region.startsWith("us-gov-")) return {
|
|
3724
3808
|
partition: "aws-us-gov",
|
|
@@ -3850,6 +3934,10 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
|
|
|
3850
3934
|
if (value === "****") continue;
|
|
3851
3935
|
stackParams[p.ParameterKey] = value;
|
|
3852
3936
|
}
|
|
3937
|
+
if (templateOverride) {
|
|
3938
|
+
const deletedInfo = deletedResourceInfo(physIds, template, stackName);
|
|
3939
|
+
if (deletedInfo) console.error(deletedInfo);
|
|
3940
|
+
}
|
|
3853
3941
|
const ctx = buildResolverContext(template, stackParams, physIds, region, accountId, stackName, stackId);
|
|
3854
3942
|
const notificationArns = stack?.NotificationARNs ?? [];
|
|
3855
3943
|
if (notificationArns.length > 0) ctx.params["AWS::NotificationARNs"] = notificationArns;
|
|
@@ -4793,9 +4881,10 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
4793
4881
|
}
|
|
4794
4882
|
if (resourceType === "AWS::CodeBuild::Project") {
|
|
4795
4883
|
const name = declared["Name"];
|
|
4796
|
-
|
|
4884
|
+
const artifactName = typeof name === "string" ? name : physicalId;
|
|
4885
|
+
if (typeof artifactName === "string") knownDefPaths = {
|
|
4797
4886
|
...knownDefPaths,
|
|
4798
|
-
"Artifacts.Name":
|
|
4887
|
+
"Artifacts.Name": artifactName
|
|
4799
4888
|
};
|
|
4800
4889
|
}
|
|
4801
4890
|
if (resourceType === "AWS::SecretsManager::RotationSchedule") {
|
|
@@ -4808,9 +4897,13 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
|
|
|
4808
4897
|
}
|
|
4809
4898
|
if (resourceType === "AWS::AmazonMQ::Broker") {
|
|
4810
4899
|
const engineType = declared["EngineType"];
|
|
4811
|
-
|
|
4900
|
+
const storageDefault = typeof engineType === "string" ? {
|
|
4901
|
+
ACTIVEMQ: "EFS",
|
|
4902
|
+
RABBITMQ: "EBS"
|
|
4903
|
+
}[engineType.toUpperCase()] : void 0;
|
|
4904
|
+
if (storageDefault !== void 0) knownDef = {
|
|
4812
4905
|
...knownDef,
|
|
4813
|
-
StorageType:
|
|
4906
|
+
StorageType: storageDefault
|
|
4814
4907
|
};
|
|
4815
4908
|
}
|
|
4816
4909
|
if (resourceType === "AWS::Lambda::EventSourceMapping") {
|
|
@@ -7182,6 +7275,10 @@ function diffRdsClusterChildren(input) {
|
|
|
7182
7275
|
}
|
|
7183
7276
|
return added;
|
|
7184
7277
|
}
|
|
7278
|
+
const AAS_MANAGED_READER_PREFIX = "application-autoscaling-";
|
|
7279
|
+
function isAasManagedReader(dbInstanceIdentifier) {
|
|
7280
|
+
return dbInstanceIdentifier.startsWith(AAS_MANAGED_READER_PREFIX);
|
|
7281
|
+
}
|
|
7185
7282
|
async function pageDbInstances(client, clusterId) {
|
|
7186
7283
|
const out = [];
|
|
7187
7284
|
let marker;
|
|
@@ -7214,7 +7311,7 @@ async function enumerateRdsClusterChildren(ctx) {
|
|
|
7214
7311
|
const [instances, clusterMemberIds] = await Promise.all([pageDbInstances(client, clusterId), describeClusterMemberIds(client, clusterId)]);
|
|
7215
7312
|
return diffRdsClusterChildren({
|
|
7216
7313
|
declaredInstanceIds,
|
|
7217
|
-
liveInstances: instances.filter((i) => typeof i.DBInstanceIdentifier === "string").map((i) => ({
|
|
7314
|
+
liveInstances: instances.filter((i) => typeof i.DBInstanceIdentifier === "string" && !isAasManagedReader(i.DBInstanceIdentifier)).map((i) => ({
|
|
7218
7315
|
id: i.DBInstanceIdentifier,
|
|
7219
7316
|
label: i.DBInstanceIdentifier
|
|
7220
7317
|
})),
|
|
@@ -8457,8 +8554,20 @@ const readAcmCertificate = async ({ physicalId, declared, region }) => {
|
|
|
8457
8554
|
const model = {};
|
|
8458
8555
|
if (str$1(cert.DomainName)) model.DomainName = cert.DomainName;
|
|
8459
8556
|
if (str$1(cert.KeyAlgorithm)) model.KeyAlgorithm = cert.KeyAlgorithm;
|
|
8460
|
-
const
|
|
8461
|
-
const
|
|
8557
|
+
const declaredSans = Array.isArray(declared.SubjectAlternativeNames) ? declared.SubjectAlternativeNames.filter((s) => str$1(s) !== void 0) : [];
|
|
8558
|
+
const declaresSans = declaredSans.length > 0;
|
|
8559
|
+
let sans = (cert.SubjectAlternativeNames ?? []).filter((s) => str$1(s) !== void 0);
|
|
8560
|
+
const apex = str$1(cert.DomainName);
|
|
8561
|
+
if (declaresSans && apex !== void 0 && !declaredSans.includes(apex)) {
|
|
8562
|
+
let dropped = false;
|
|
8563
|
+
sans = sans.filter((s) => {
|
|
8564
|
+
if (!dropped && s === apex) {
|
|
8565
|
+
dropped = true;
|
|
8566
|
+
return false;
|
|
8567
|
+
}
|
|
8568
|
+
return true;
|
|
8569
|
+
});
|
|
8570
|
+
}
|
|
8462
8571
|
if (declaresSans && sans.length > 0) model.SubjectAlternativeNames = sans;
|
|
8463
8572
|
const pref = str$1(cert.Options?.CertificateTransparencyLoggingPreference);
|
|
8464
8573
|
const declaresOptions = declared.Options !== void 0 && declared.Options !== null && typeof declared.Options === "object";
|
|
@@ -9992,13 +10101,25 @@ function carryForwardUnreadable(recorded, existing, findings) {
|
|
|
9992
10101
|
/**
|
|
9993
10102
|
* The single source of truth for "is this baseline value equal to the current
|
|
9994
10103
|
* value?". `applyBaseline` (suppress vs surface) and `splitRecordedByBaseline`
|
|
9995
|
-
* (unchanged vs changed) MUST share this exact predicate.
|
|
10104
|
+
* (unchanged vs changed) MUST share this exact predicate. BOTH sides are
|
|
9996
10105
|
* re-canonicalized through the CURRENT pipeline so a baseline written under older
|
|
9997
|
-
* normalization rules still matches today's canonical live value (R6)
|
|
9998
|
-
*
|
|
10106
|
+
* normalization rules still matches today's canonical live value (R6).
|
|
10107
|
+
*
|
|
10108
|
+
* #807: canonicalize the CURRENT side too, not just the baseline side. The caller's
|
|
10109
|
+
* `currentCanonicalValue` is only canonical at the OUTER value — a free-form-map
|
|
10110
|
+
* ENTRY (a Lambda env var, a Glue `Parameters` value, a Docker label) whose value is
|
|
10111
|
+
* a JSON- or policy-shaped STRING keeps its ancestry-lost RAW string. Canonicalizing
|
|
10112
|
+
* just the baseline side then policy-parses / JSON-minifies / key-sorts that bare
|
|
10113
|
+
* string on the recorded side while the live side stays raw, so `deepEqual` is false
|
|
10114
|
+
* forever — the predicate is not reflexive (`baselineValueMatches(v, v)` is false)
|
|
10115
|
+
* and a re-record never converges. Running the SAME `canonicalizeForCompare` on both
|
|
10116
|
+
* sides restores reflexivity for the whole free-form-string class (and composes
|
|
10117
|
+
* cleanly with #767's identity-sort case). Idempotency of the pipeline means an
|
|
10118
|
+
* already-canonical live value is unchanged, so this never weakens real change
|
|
10119
|
+
* detection: two values that differ after canonicalization still compare unequal.
|
|
9999
10120
|
*/
|
|
10000
10121
|
function baselineValueMatches(baselineValue, currentCanonicalValue) {
|
|
10001
|
-
return deepEqual(canonicalizeForCompare(baselineValue), currentCanonicalValue);
|
|
10122
|
+
return deepEqual(canonicalizeForCompare(baselineValue), canonicalizeForCompare(currentCanonicalValue));
|
|
10002
10123
|
}
|
|
10003
10124
|
const DELTA_IDENTITY_FIELDS = [
|
|
10004
10125
|
"Key",
|
|
@@ -13664,6 +13785,9 @@ const INFO_TIERS = [
|
|
|
13664
13785
|
"unresolved",
|
|
13665
13786
|
"skipped"
|
|
13666
13787
|
];
|
|
13788
|
+
function isPendingCreationSkip$1(f) {
|
|
13789
|
+
return f.tier === "skipped" && f.note === "no physical id";
|
|
13790
|
+
}
|
|
13667
13791
|
function formatFinding(f, stackName = "") {
|
|
13668
13792
|
const id = f.constructPath ? withinStackPath(f.constructPath, stackName) : f.logicalId;
|
|
13669
13793
|
const pathDisplay = f.attributeKey ? `${f.path}[${sanitizeForTerminal(f.attributeKey)}]` : f.path;
|
|
@@ -13826,9 +13950,20 @@ function report(rawFindings, header, opts = {}) {
|
|
|
13826
13950
|
if (t === "skipped") return `skipped=${items.length} — NOT checked (coverage incomplete: ${groupReasons(items)})`;
|
|
13827
13951
|
return `${t}=${items.length} (${groupReasons(items)})`;
|
|
13828
13952
|
};
|
|
13829
|
-
const
|
|
13953
|
+
const skippedSummaryFor = (items) => {
|
|
13954
|
+
if (!opts.preDeploy) return [summaryFor("skipped", items)];
|
|
13955
|
+
const pending = items.filter(isPendingCreationSkip$1);
|
|
13956
|
+
const gaps = items.filter((f) => !isPendingCreationSkip$1(f));
|
|
13957
|
+
const lines = [];
|
|
13958
|
+
if (gaps.length > 0) lines.push(summaryFor("skipped", gaps));
|
|
13959
|
+
if (pending.length > 0) lines.push(`pending creation=${pending.length} (not yet deployed — the next deploy will create them, not a coverage gap)`);
|
|
13960
|
+
return lines;
|
|
13961
|
+
};
|
|
13962
|
+
const summaries = INFO_TIERS.filter((t) => !isExpanded(t)).flatMap((t) => {
|
|
13830
13963
|
const items = byTier(t);
|
|
13831
|
-
|
|
13964
|
+
if (items.length === 0) return [];
|
|
13965
|
+
if (t === "skipped") return skippedSummaryFor(items);
|
|
13966
|
+
return [summaryFor(t, items)];
|
|
13832
13967
|
}).filter((s) => s !== null);
|
|
13833
13968
|
if (nestedFolded.length > 0) summaries.push(`undeclared-subkey=${nestedFolded.length} (undeclared live-only values inside a declared object — record to record; --show-all to list)`);
|
|
13834
13969
|
if (summaries.length === 1) log(style.note(`info: ${summaries[0]} — run with --verbose for the list`));
|
|
@@ -14116,10 +14251,16 @@ function buildScopeOptions(shownCount, foldedCount) {
|
|
|
14116
14251
|
* to be prompted, so it gets the full set, matching the pre-gate `--yes` behaviour). The
|
|
14117
14252
|
* `--yes` case never reaches the AWS-mutating revert through here (revert has no gate).
|
|
14118
14253
|
*/
|
|
14119
|
-
|
|
14254
|
+
function scopeMessage(stackName, region, foldedCount) {
|
|
14255
|
+
return `${stackLabel$1(stackName, region)}: the report folded ${foldedCount} undeclared value(s) — which to decide on?`;
|
|
14256
|
+
}
|
|
14257
|
+
function perFindingActionMessage(stackName, region) {
|
|
14258
|
+
return `${stackLabel$1(stackName, region)}: assign an action to each finding`;
|
|
14259
|
+
}
|
|
14260
|
+
async function chooseScope(stackName, region, shownCount, foldedCount, yes) {
|
|
14120
14261
|
if (yes || foldedCount === 0 || shownCount === 0) return "all";
|
|
14121
14262
|
const choice = await select({
|
|
14122
|
-
message:
|
|
14263
|
+
message: scopeMessage(stackName, region, foldedCount),
|
|
14123
14264
|
options: buildScopeOptions(shownCount, foldedCount),
|
|
14124
14265
|
initialValue: "shown"
|
|
14125
14266
|
});
|
|
@@ -14275,7 +14416,7 @@ async function recordAll(p) {
|
|
|
14275
14416
|
async function ignoreAll(p) {
|
|
14276
14417
|
const ignorable = p.reconciled.filter((f) => f.tier === "declared" || f.tier === "undeclared" || f.tier === "added");
|
|
14277
14418
|
const foldedCount = ignorable.filter((f) => isFoldedFinding(f, p.verbose)).length;
|
|
14278
|
-
const scope = await chooseScope(p.stackName, ignorable.length - foldedCount, foldedCount, p.yes);
|
|
14419
|
+
const scope = await chooseScope(p.stackName, p.region, ignorable.length - foldedCount, foldedCount, p.yes);
|
|
14279
14420
|
if (scope === null) return null;
|
|
14280
14421
|
const findings = scope === "all" ? ignorable : ignorable.filter((f) => !isFoldedFinding(f, p.verbose));
|
|
14281
14422
|
return (await ignoreStack({
|
|
@@ -14315,14 +14456,14 @@ async function revertAll(p) {
|
|
|
14315
14456
|
}
|
|
14316
14457
|
async function perFinding(p, decidable) {
|
|
14317
14458
|
const foldedCount = decidable.filter((f) => isFoldedFinding(f, p.verbose)).length;
|
|
14318
|
-
const scope = await chooseScope(p.stackName, decidable.length - foldedCount, foldedCount, p.yes);
|
|
14459
|
+
const scope = await chooseScope(p.stackName, p.region, decidable.length - foldedCount, foldedCount, p.yes);
|
|
14319
14460
|
if (scope === null) return null;
|
|
14320
14461
|
const scoped = scope === "all" ? decidable : decidable.filter((f) => !isFoldedFinding(f, p.verbose));
|
|
14321
14462
|
const rows = scoped.map((f) => ({
|
|
14322
14463
|
label: pickerLabel(f, p.stackName),
|
|
14323
14464
|
applicable: applicableActions(f)
|
|
14324
14465
|
}));
|
|
14325
|
-
const chosen = await actionPicker(
|
|
14466
|
+
const chosen = await actionPicker(perFindingActionMessage(p.stackName, p.region), rows);
|
|
14326
14467
|
if (chosen === void 0) return null;
|
|
14327
14468
|
const groups = groupByAction(scoped, chosen);
|
|
14328
14469
|
if (groups.record.length + groups.ignore.length + groups.revert.length === 0) return {
|
|
@@ -14558,6 +14699,7 @@ async function runCheck(args) {
|
|
|
14558
14699
|
if (synthTemplates && !synthTemplates.has(sKey)) {
|
|
14559
14700
|
console.error(`note: ${stackName}: not in the synth output — skipped (--pre-deploy)`);
|
|
14560
14701
|
jsonError(stackName, region, "not in the synth output — skipped (--pre-deploy)");
|
|
14702
|
+
worst = Math.max(worst, a.strict ? 1 : 0);
|
|
14561
14703
|
continue;
|
|
14562
14704
|
}
|
|
14563
14705
|
const gathered = await gatherWithProgress(showProgress, progressLabel(idx, stacks.length, stackName, region), () => gatherFindings(stackName, region, synthTemplates?.get(sKey), template));
|
|
@@ -14672,6 +14814,7 @@ async function runCheck(args) {
|
|
|
14672
14814
|
if (e instanceof StackNotCheckableError) {
|
|
14673
14815
|
console.error(`note: ${stackName}: ${e.message} — skipped`);
|
|
14674
14816
|
jsonError(stackName, region, `${e.message} — skipped`);
|
|
14817
|
+
worst = Math.max(worst, a.strict ? 1 : 0);
|
|
14675
14818
|
continue;
|
|
14676
14819
|
}
|
|
14677
14820
|
console.error(`error: ${stackName}: ${e.message}`);
|
|
@@ -14874,7 +15017,7 @@ EXIT CODES
|
|
|
14874
15017
|
record: 0 = written 2 = error/refused
|
|
14875
15018
|
ignore: 0 = rule(s) written / nothing to ignore 2 = error/refused
|
|
14876
15019
|
revert: 0 = converged/aborted 1 = drift remains 2 = error/apply failure
|
|
14877
|
-
all: 130 = interrupted (Ctrl-C / ESC)
|
|
15020
|
+
all: 130 = interrupted (Ctrl-C / ESC / SIGINT) 143 = terminated (SIGTERM) — never mistaken for clean; an unhandled error always exits 2
|
|
14878
15021
|
|
|
14879
15022
|
The baseline lives at .cdkrd/baselines/<stack>.<accountId>.<region>.json — commit it; review
|
|
14880
15023
|
its diff in PRs. Ignore rules live in .cdkrd/ignore.yaml — also git-committed.`;
|