cdk-real-drift 0.3.11 → 0.3.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/dist/cli.js +46 -20
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1426,6 +1426,14 @@ const KNOWN_DEFAULTS = {
|
|
|
1426
1426
|
IngressConfiguration: { IsPubliclyAccessible: true }
|
|
1427
1427
|
}
|
|
1428
1428
|
},
|
|
1429
|
+
"AWS::GuardDuty::Detector": {
|
|
1430
|
+
FindingPublishingFrequency: "SIX_HOURS",
|
|
1431
|
+
DataSources: {
|
|
1432
|
+
MalwareProtection: { ScanEc2InstanceWithFindings: { EbsVolumes: true } },
|
|
1433
|
+
S3Logs: { Enable: true },
|
|
1434
|
+
Kubernetes: { AuditLogs: { Enable: true } }
|
|
1435
|
+
}
|
|
1436
|
+
},
|
|
1429
1437
|
"AWS::KinesisAnalyticsV2::Application": { ApplicationMode: "STREAMING" },
|
|
1430
1438
|
"AWS::Events::ApiDestination": { InvocationRateLimitPerSecond: 300 },
|
|
1431
1439
|
"AWS::ElasticBeanstalk::Application": { ResourceLifecycleConfig: { VersionLifecycleConfig: {
|
|
@@ -2633,6 +2641,7 @@ const VALUE_INDEPENDENT_DEFAULT_TOPLEVEL_PATHS = {
|
|
|
2633
2641
|
"AWS::ElasticLoadBalancing::LoadBalancer": new Set(["AvailabilityZones"]),
|
|
2634
2642
|
"AWS::AutoScaling::AutoScalingGroup": new Set(["AvailabilityZones", "AvailabilityZoneIds"]),
|
|
2635
2643
|
"AWS::ApiGateway::Authorizer": new Set(["AuthType"]),
|
|
2644
|
+
"AWS::GuardDuty::Detector": new Set(["Features"]),
|
|
2636
2645
|
"AWS::RDS::DBCluster": new Set([
|
|
2637
2646
|
"KmsKeyId",
|
|
2638
2647
|
"PerformanceInsightsKmsKeyId",
|
|
@@ -3223,7 +3232,10 @@ const UNORDERED_ARRAY_PROPS = {
|
|
|
3223
3232
|
"AllowedOAuthScopes",
|
|
3224
3233
|
"ExplicitAuthFlows",
|
|
3225
3234
|
"CallbackURLs",
|
|
3226
|
-
"LogoutURLs"
|
|
3235
|
+
"LogoutURLs",
|
|
3236
|
+
"ReadAttributes",
|
|
3237
|
+
"WriteAttributes",
|
|
3238
|
+
"SupportedIdentityProviders"
|
|
3227
3239
|
]),
|
|
3228
3240
|
"AWS::WAFv2::IPSet": new Set(["Addresses"]),
|
|
3229
3241
|
"AWS::Route53::RecordSet": new Set(["ResourceRecords"]),
|
|
@@ -12417,14 +12429,26 @@ const driftCount = (findings) => findings.filter(isDrift).length;
|
|
|
12417
12429
|
const unrecordedCount = (findings) => findings.filter((f) => f.unrecorded === true).length;
|
|
12418
12430
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
12419
12431
|
/**
|
|
12432
|
+
* The per-stack label shown in a DECISION prompt — the SAME `Name (region)` form the
|
|
12433
|
+
* report header uses (`check.ts` `${stackName} (${region})`). After #899 exact-name
|
|
12434
|
+
* selection targets EVERY same-named region instance, so a bare `stackName` in a
|
|
12435
|
+
* record/ignore/revert prompt is indistinguishable across regions (a wrong-region
|
|
12436
|
+
* record/ignore/revert hazard, #947). Naming the region disambiguates them. Pure +
|
|
12437
|
+
* exported so the wording is unit-tested.
|
|
12438
|
+
*/
|
|
12439
|
+
function stackLabel$1(stackName, region) {
|
|
12440
|
+
return `${stackName} (${region})`;
|
|
12441
|
+
}
|
|
12442
|
+
/**
|
|
12420
12443
|
* The revert confirm message (R52). When NOT-revertable findings exist (e.g. a
|
|
12421
12444
|
* no-baseline first check with one declared drift and 100+ undeclared values),
|
|
12422
12445
|
* users read "This WRITES to AWS" as "everything I just saw gets written" —
|
|
12423
12446
|
* state explicitly that ONLY the listed op(s) are written and the rest is
|
|
12424
12447
|
* untouched. Pure + exported so the wording is unit-tested.
|
|
12425
12448
|
*/
|
|
12426
|
-
function revertConfirmMessage(stackName, opCount, notRevertableCount) {
|
|
12427
|
-
|
|
12449
|
+
function revertConfirmMessage(stackName, region, opCount, notRevertableCount) {
|
|
12450
|
+
const scope = notRevertableCount > 0 ? ` Only the ${opCount} selected op(s) are written — the ${notRevertableCount} NOT-revertable finding(s) are untouched.` : "";
|
|
12451
|
+
return `Apply ${opCount} revert op(s) to ${stackLabel$1(stackName, region)}? This WRITES to AWS.${scope}`;
|
|
12428
12452
|
}
|
|
12429
12453
|
/**
|
|
12430
12454
|
* The post-revert surviving-drift pointer list (R46), capped (R52): after a
|
|
@@ -12448,8 +12472,9 @@ function formatSurvivingDrift(remaining, stackName = "", cap = 10) {
|
|
|
12448
12472
|
* (the folded would just nag forever), whereas deselecting a standout to "record the rest"
|
|
12449
12473
|
* IS useful — so standouts toggle, the folded always record. Pure + exported.
|
|
12450
12474
|
*/
|
|
12451
|
-
function recordSelectMessage(stackName, foldedCount = 0) {
|
|
12452
|
-
|
|
12475
|
+
function recordSelectMessage(stackName, region, foldedCount = 0) {
|
|
12476
|
+
const fold = foldedCount > 0 ? `; +${foldedCount} folded sub-key(s) ALWAYS recorded too (--verbose to itemize)` : "";
|
|
12477
|
+
return `${stackLabel$1(stackName, region)}: select undeclared value(s) to record (unselected stay reported)${fold}`;
|
|
12453
12478
|
}
|
|
12454
12479
|
/**
|
|
12455
12480
|
* Split the to-record delta into STANDOUT (itemized in the record multiselect) and FOLDED
|
|
@@ -12540,8 +12565,8 @@ function filterRevertPlan(plan, picked) {
|
|
|
12540
12565
|
notRevertable: plan.notRevertable
|
|
12541
12566
|
};
|
|
12542
12567
|
}
|
|
12543
|
-
function revertSelectMessage(stackName) {
|
|
12544
|
-
return `${stackName}: select the op(s) to revert (unselected are not written)`;
|
|
12568
|
+
function revertSelectMessage(stackName, region) {
|
|
12569
|
+
return `${stackLabel$1(stackName, region)}: select the op(s) to revert (unselected are not written)`;
|
|
12545
12570
|
}
|
|
12546
12571
|
/**
|
|
12547
12572
|
* Record the current undeclared state into the baseline file. In an interactive run
|
|
@@ -12559,7 +12584,7 @@ async function recordStack(p) {
|
|
|
12559
12584
|
const { stackName, region, desired, findings, yes, interactive, preselectedKeys, expandNested } = p;
|
|
12560
12585
|
const existing = await loadBaseline(stackName, desired.accountId, region);
|
|
12561
12586
|
if (existing) checkBaselineAccount(existing, desired.accountId, stackName);
|
|
12562
|
-
if (!yes && existing) console.error(`note: ${stackName}: will overwrite the existing baseline file on confirm (nothing written yet; it is git-tracked — review the diff afterwards). Pass --yes to silence.`);
|
|
12587
|
+
if (!yes && existing) console.error(`note: ${stackLabel$1(stackName, region)}: will overwrite the existing baseline file on confirm (nothing written yet; it is git-tracked — review the diff afterwards). Pass --yes to silence.`);
|
|
12563
12588
|
let recorded = carryForwardUnreadable(buildRecorded(findings), existing, findings);
|
|
12564
12589
|
let refreshedOnly = false;
|
|
12565
12590
|
if (!yes && recorded.length > 0) {
|
|
@@ -12582,7 +12607,7 @@ async function recordStack(p) {
|
|
|
12582
12607
|
const { standout, folded } = splitFoldedNested(changed, findings, expandNested);
|
|
12583
12608
|
if (standout.length === 0) {
|
|
12584
12609
|
const proceed = await confirm({
|
|
12585
|
-
message: `${stackName}: record ${folded.length} undeclared sub-key value(s)? (--verbose to itemize each)`,
|
|
12610
|
+
message: `${stackLabel$1(stackName, region)}: record ${folded.length} undeclared sub-key value(s)? (--verbose to itemize each)`,
|
|
12586
12611
|
initialValue: true
|
|
12587
12612
|
});
|
|
12588
12613
|
if (isCancel(proceed) || !proceed) {
|
|
@@ -12594,7 +12619,7 @@ async function recordStack(p) {
|
|
|
12594
12619
|
}
|
|
12595
12620
|
picked = changed.map((e) => recordedKey(e));
|
|
12596
12621
|
} else {
|
|
12597
|
-
const fromPrompt = await bulkMultiselect(recordSelectMessage(stackName, folded.length), standout.map((e) => ({
|
|
12622
|
+
const fromPrompt = await bulkMultiselect(recordSelectMessage(stackName, region, folded.length), standout.map((e) => ({
|
|
12598
12623
|
value: recordedKey(e),
|
|
12599
12624
|
label: e.path ? `${e.logicalId}.${e.path}` : `${e.logicalId} (added resource)`,
|
|
12600
12625
|
selected: true
|
|
@@ -12613,7 +12638,7 @@ async function recordStack(p) {
|
|
|
12613
12638
|
recorded = [...unchanged, ...selectedChanged];
|
|
12614
12639
|
if (recorded.length === 0 && !preselectedKeys) {
|
|
12615
12640
|
const proceed = await confirm({
|
|
12616
|
-
message: `${stackName}: record nothing? This writes an EMPTY baseline — every undeclared value stays reported as unrecorded.`,
|
|
12641
|
+
message: `${stackLabel$1(stackName, region)}: record nothing? This writes an EMPTY baseline — every undeclared value stays reported as unrecorded.`,
|
|
12617
12642
|
initialValue: false
|
|
12618
12643
|
});
|
|
12619
12644
|
if (isCancel(proceed) || !proceed) {
|
|
@@ -12643,8 +12668,8 @@ async function recordStack(p) {
|
|
|
12643
12668
|
}
|
|
12644
12669
|
/** Header for ignore's multiselect. The key hints are rendered by `bulkMultiselect`
|
|
12645
12670
|
* itself, so this is just the one-line prompt. Pure + exported for unit tests. */
|
|
12646
|
-
function ignoreSelectMessage(stackName) {
|
|
12647
|
-
return `${stackName}: select drift to ignore — stops reporting it (writes .cdkrd/ignore.yaml)`;
|
|
12671
|
+
function ignoreSelectMessage(stackName, region) {
|
|
12672
|
+
return `${stackLabel$1(stackName, region)}: select drift to ignore — stops reporting it (writes .cdkrd/ignore.yaml)`;
|
|
12648
12673
|
}
|
|
12649
12674
|
const ignoreFindingKey = (f) => `${f.logicalId}::${f.path}`;
|
|
12650
12675
|
/**
|
|
@@ -12695,7 +12720,7 @@ async function ignoreStack(p) {
|
|
|
12695
12720
|
added: 0
|
|
12696
12721
|
};
|
|
12697
12722
|
}
|
|
12698
|
-
const picked = await bulkMultiselect(ignoreSelectMessage(stackName), ignoreSelectOptions(ignorable, stackName));
|
|
12723
|
+
const picked = await bulkMultiselect(ignoreSelectMessage(stackName, region), ignoreSelectOptions(ignorable, stackName));
|
|
12699
12724
|
if (picked === void 0) {
|
|
12700
12725
|
console.error(`note: ${stackName}: ignore cancelled — config unchanged`);
|
|
12701
12726
|
return {
|
|
@@ -12873,7 +12898,7 @@ async function revertStack(p) {
|
|
|
12873
12898
|
};
|
|
12874
12899
|
}
|
|
12875
12900
|
if (!autoSelectAll) {
|
|
12876
|
-
const picked = await bulkMultiselect(revertSelectMessage(stackName), revertSelectOptions(plan));
|
|
12901
|
+
const picked = await bulkMultiselect(revertSelectMessage(stackName, region), revertSelectOptions(plan));
|
|
12877
12902
|
if (picked === void 0) {
|
|
12878
12903
|
out(style.note("aborted."));
|
|
12879
12904
|
return {
|
|
@@ -12890,7 +12915,7 @@ async function revertStack(p) {
|
|
|
12890
12915
|
};
|
|
12891
12916
|
}
|
|
12892
12917
|
}
|
|
12893
|
-
const ok = await confirm({ message: revertConfirmMessage(stackName, plan.items.reduce((n, i) => n + i.ops.length, 0), plan.notRevertable.length) });
|
|
12918
|
+
const ok = await confirm({ message: revertConfirmMessage(stackName, region, plan.items.reduce((n, i) => n + i.ops.length, 0), plan.notRevertable.length) });
|
|
12894
12919
|
if (isCancel(ok) || !ok) {
|
|
12895
12920
|
out(style.note("aborted."));
|
|
12896
12921
|
return {
|
|
@@ -13907,9 +13932,10 @@ function buildResolveOptions(actions, decidableCount, recordLabel = "snapshot")
|
|
|
13907
13932
|
/** The top-menu prompt, worded by the remaining exit state (drift vs unrecorded-only vs
|
|
13908
13933
|
* R141 no-baseline establish). `prefix` carries the `[2/3] ` multi-stack position cue
|
|
13909
13934
|
* (issue #539) — empty for a lone stack. Pure + exported. */
|
|
13910
|
-
function resolveMenuMessage(stackName, code, establishOnly = false, prefix = "") {
|
|
13911
|
-
|
|
13912
|
-
|
|
13935
|
+
function resolveMenuMessage(stackName, region, code, establishOnly = false, prefix = "") {
|
|
13936
|
+
const label = stackLabel$1(stackName, region);
|
|
13937
|
+
if (establishOnly) return `${prefix}${label}: no .cdkrd baseline yet — record the current state as your baseline?`;
|
|
13938
|
+
return code === 1 ? `${prefix}${label}: drift found — what do you want to do?` : `${prefix}${label}: potential drift found (live-only, no baseline yet) — what do you want to do?`;
|
|
13913
13939
|
}
|
|
13914
13940
|
async function resolveInteractively(p) {
|
|
13915
13941
|
const opts = baselineOpts(p);
|
|
@@ -13929,7 +13955,7 @@ async function resolveInteractively(p) {
|
|
|
13929
13955
|
const recordLabel = recordable ? "snapshot" : declaredDrift ? "establish-drift" : deletedDrift ? "establish-deleted" : "establish";
|
|
13930
13956
|
const options = buildResolveOptions(actions, decidable.length, recordLabel);
|
|
13931
13957
|
const choice = await select({
|
|
13932
|
-
message: resolveMenuMessage(p.stackName, code, establishOnly, p.positionPrefix ?? ""),
|
|
13958
|
+
message: resolveMenuMessage(p.stackName, p.region, code, establishOnly, p.positionPrefix ?? ""),
|
|
13933
13959
|
options,
|
|
13934
13960
|
initialValue: "nothing"
|
|
13935
13961
|
});
|