cdk-real-drift 0.12.47 → 0.12.49
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 +10 -4
- package/dist/cli.js +42 -28
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -670,14 +670,19 @@ If the whole invocation fails before any stack is reached (bad config, an
|
|
|
670
670
|
un-synthesizable app, or a zero-stack app), stdout is still a valid empty array
|
|
671
671
|
`[]` (exit code non-zero, the reason on stderr) — never empty bytes.
|
|
672
672
|
|
|
673
|
-
Every successfully-checked stack element
|
|
673
|
+
Every successfully-checked stack element of a baseline-consulting `check` carries a
|
|
674
|
+
`"baseline": <bool>` flag —
|
|
674
675
|
`true` when the stack has a committed `.cdkrd` baseline (its undeclared dimension is
|
|
675
676
|
**watched**), `false` when it has never been recorded. Without a baseline the
|
|
676
677
|
classification shifts: appeared-since-record out-of-band values read as `unrecorded`
|
|
677
678
|
and are excluded from `drifted`, so a QUIET never-recorded stack emits the
|
|
678
679
|
byte-identical `"drifted": 0` of a watched-clean one. A consumer summing `drifted`
|
|
679
680
|
uses `baseline` to tell an UNWATCHED stack from a watched-clean one (#1095). It is
|
|
680
|
-
omitted on the `error` / `stackDeleted`
|
|
681
|
+
omitted whenever the baseline was **not consulted**: on the `error` / `stackDeleted`
|
|
682
|
+
shapes (never reconciled against a baseline), and on every element of a
|
|
683
|
+
`--pre-deploy` or `--show-all` run (both are baseline-untouched modes, so they
|
|
684
|
+
cannot claim `false` — a committed baseline may well exist; #1335). Absent means
|
|
685
|
+
"not consulted"; `false` means "consulted, never recorded".
|
|
681
686
|
|
|
682
687
|
Each stack element is `{ "stack": "<name> (<region>)", "drifted": <n>, "baseline": <bool>, "findings": [...] }`
|
|
683
688
|
(`error` added only on a pre-check failure; `stackDeleted: true` only on a deleted
|
|
@@ -737,9 +742,10 @@ mode: a `record` / `ignore` that would need the selection prompt refuses without
|
|
|
737
742
|
`--yes` (`"refused": true`), and `revert` refuses the AWS write without `--yes`
|
|
738
743
|
(`"exit": 2`). Per-verb element:
|
|
739
744
|
|
|
740
|
-
- `record` → `{ "stack", "recorded": <n>, "wrote": <bool>, "
|
|
745
|
+
- `record` → `{ "stack", "recorded": <n>, "wrote": <bool>, "baselinePath"?: "<path>",
|
|
741
746
|
"refused"?: true, "error"?: "<reason>" }` — `recorded` is how many undeclared
|
|
742
|
-
value(s) were written
|
|
747
|
+
value(s) were written; `baselinePath` is the baseline file written (a path string,
|
|
748
|
+
deliberately NOT named `baseline` — that key is check's boolean flag; #1336).
|
|
743
749
|
- `ignore` → `{ "stack", "added": <n>, "wrote": <bool>, "config"?:
|
|
744
750
|
".cdkrd/ignore.yaml", "refused"?: true, "error"?: "<reason>" }` — `added` is how
|
|
745
751
|
many new rules were appended.
|
package/dist/cli.js
CHANGED
|
@@ -3835,16 +3835,7 @@ function parseIpv6Groups(addr) {
|
|
|
3835
3835
|
...tailGroups
|
|
3836
3836
|
];
|
|
3837
3837
|
}
|
|
3838
|
-
function
|
|
3839
|
-
const slash = s.indexOf("/");
|
|
3840
|
-
if (slash === -1) return void 0;
|
|
3841
|
-
const addr = s.slice(0, slash);
|
|
3842
|
-
const prefixStr = s.slice(slash + 1);
|
|
3843
|
-
if (!/^\d{1,3}$/.test(prefixStr)) return void 0;
|
|
3844
|
-
const prefix = Number.parseInt(prefixStr, 10);
|
|
3845
|
-
if (prefix < 0 || prefix > 128) return void 0;
|
|
3846
|
-
const groups = parseIpv6Groups(addr);
|
|
3847
|
-
if (!groups) return void 0;
|
|
3838
|
+
function formatCanonicalIpv6(groups) {
|
|
3848
3839
|
let bestStart = -1;
|
|
3849
3840
|
let bestLen = 0;
|
|
3850
3841
|
let curStart = -1;
|
|
@@ -3861,13 +3852,29 @@ function canonicalIpv6Cidr(s) {
|
|
|
3861
3852
|
curLen = 0;
|
|
3862
3853
|
}
|
|
3863
3854
|
const hex = groups.map((g) => g.toString(16));
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3855
|
+
if (bestLen >= 2) return `${hex.slice(0, bestStart).join(":")}::${hex.slice(bestStart + bestLen).join(":")}`;
|
|
3856
|
+
return hex.join(":");
|
|
3857
|
+
}
|
|
3858
|
+
function canonicalIpv6Cidr(s) {
|
|
3859
|
+
const slash = s.indexOf("/");
|
|
3860
|
+
if (slash === -1) return void 0;
|
|
3861
|
+
const addr = s.slice(0, slash);
|
|
3862
|
+
const prefixStr = s.slice(slash + 1);
|
|
3863
|
+
if (!/^\d{1,3}$/.test(prefixStr)) return void 0;
|
|
3864
|
+
const prefix = Number.parseInt(prefixStr, 10);
|
|
3865
|
+
if (prefix < 0 || prefix > 128) return void 0;
|
|
3866
|
+
const groups = parseIpv6Groups(addr);
|
|
3867
|
+
if (!groups) return void 0;
|
|
3868
|
+
return `${formatCanonicalIpv6(groups)}/${prefix}`;
|
|
3869
|
+
}
|
|
3870
|
+
function canonicalIpv6Address(s) {
|
|
3871
|
+
if (s.includes("/")) return void 0;
|
|
3872
|
+
const groups = parseIpv6Groups(s);
|
|
3873
|
+
if (!groups) return void 0;
|
|
3874
|
+
return formatCanonicalIpv6(groups);
|
|
3868
3875
|
}
|
|
3869
3876
|
function canonicalizeIpv6CidrsDeep(v) {
|
|
3870
|
-
if (typeof v === "string") return canonicalIpv6Cidr(v) ?? v;
|
|
3877
|
+
if (typeof v === "string") return canonicalIpv6Cidr(v) ?? canonicalIpv6Address(v) ?? v;
|
|
3871
3878
|
if (Array.isArray(v)) return v.map(canonicalizeIpv6CidrsDeep);
|
|
3872
3879
|
if (v && typeof v === "object") {
|
|
3873
3880
|
const out = {};
|
|
@@ -5453,13 +5460,12 @@ function twinOverlapEchoes(source, twin) {
|
|
|
5453
5460
|
return true;
|
|
5454
5461
|
}
|
|
5455
5462
|
function applyDefinitionSubstitutions(definitionString, substitutions) {
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
}
|
|
5462
|
-
return out;
|
|
5463
|
+
return definitionString.replace(/\$\{([^}]+)\}/g, (match, key) => {
|
|
5464
|
+
if (!(key in substitutions)) return match;
|
|
5465
|
+
const value = substitutions[key];
|
|
5466
|
+
if (value === null || typeof value === "object") return match;
|
|
5467
|
+
return String(value);
|
|
5468
|
+
});
|
|
5463
5469
|
}
|
|
5464
5470
|
const IAM_ATTACHMENT_SUBSET = { "AWS::IAM::ManagedPolicy": new Set([
|
|
5465
5471
|
"Roles",
|
|
@@ -7451,7 +7457,9 @@ function diffSnsTopicChildren(input) {
|
|
|
7451
7457
|
resourceType: "AWS::SNS::Subscription",
|
|
7452
7458
|
identifier: s.arn,
|
|
7453
7459
|
label: s.label ?? s.arn,
|
|
7454
|
-
live: { SubscriptionArn: s.arn }
|
|
7460
|
+
live: { SubscriptionArn: s.arn },
|
|
7461
|
+
ownerAccountId: s.owner,
|
|
7462
|
+
scopeArns: s.endpoint?.startsWith("arn:") ? [s.endpoint] : void 0
|
|
7455
7463
|
});
|
|
7456
7464
|
}
|
|
7457
7465
|
return added;
|
|
@@ -7483,7 +7491,8 @@ async function enumerateSnsTopicChildren(ctx) {
|
|
|
7483
7491
|
}), topicArn)).filter((s) => typeof s.SubscriptionArn === "string" && s.SubscriptionArn.startsWith("arn:")).map((s) => ({
|
|
7484
7492
|
arn: s.SubscriptionArn,
|
|
7485
7493
|
label: s.Protocol ? `${s.Protocol} ${s.Endpoint ?? ""}`.trim() : s.SubscriptionArn,
|
|
7486
|
-
endpoint: s.Endpoint
|
|
7494
|
+
endpoint: s.Endpoint,
|
|
7495
|
+
owner: s.Owner
|
|
7487
7496
|
}))
|
|
7488
7497
|
});
|
|
7489
7498
|
}
|
|
@@ -11921,6 +11930,11 @@ function isDefinitiveNotManaged(physicalId, accountId, region) {
|
|
|
11921
11930
|
if (arnAccount !== "" && arnAccount !== accountId) return false;
|
|
11922
11931
|
return true;
|
|
11923
11932
|
}
|
|
11933
|
+
function hasForeignScopeSignal(c, accountId, region) {
|
|
11934
|
+
const owner = c.ownerAccountId;
|
|
11935
|
+
if (typeof owner === "string" && owner !== "" && owner !== accountId) return true;
|
|
11936
|
+
return (c.scopeArns ?? []).some((arn) => arn.startsWith("arn:") && !isDefinitiveNotManaged(arn, accountId, region));
|
|
11937
|
+
}
|
|
11924
11938
|
async function probeSiblingPhysicalId(cfn, c, physicalId, cache, accountId, region) {
|
|
11925
11939
|
const cached = cache.get(physicalId);
|
|
11926
11940
|
if (cached !== void 0) return cached;
|
|
@@ -11948,7 +11962,7 @@ async function probeSiblingPhysicalId(cfn, c, physicalId, cache, accountId, regi
|
|
|
11948
11962
|
}
|
|
11949
11963
|
}
|
|
11950
11964
|
} catch (e) {
|
|
11951
|
-
if (e.name === "ValidationError" && isDefinitiveNotManaged(physicalId, accountId, region)) {
|
|
11965
|
+
if (e.name === "ValidationError" && isDefinitiveNotManaged(physicalId, accountId, region) && !hasForeignScopeSignal(c, accountId, region)) {
|
|
11952
11966
|
cache.set(physicalId, "notManaged");
|
|
11953
11967
|
return "notManaged";
|
|
11954
11968
|
}
|
|
@@ -13797,7 +13811,7 @@ function buildStackJson(rawFindings, header, hasBaseline) {
|
|
|
13797
13811
|
stack: header,
|
|
13798
13812
|
drifted,
|
|
13799
13813
|
findings: findings.map((f) => redactFinding(f)),
|
|
13800
|
-
baseline: hasBaseline
|
|
13814
|
+
...hasBaseline === void 0 ? {} : { baseline: hasBaseline }
|
|
13801
13815
|
},
|
|
13802
13816
|
code: drifted === 0 ? 0 : 1
|
|
13803
13817
|
};
|
|
@@ -17675,7 +17689,7 @@ async function runRecord(args) {
|
|
|
17675
17689
|
recorded: result.count ?? 0,
|
|
17676
17690
|
wrote: result.wrote,
|
|
17677
17691
|
...result.refused && { refused: true },
|
|
17678
|
-
...result.path !== void 0 && {
|
|
17692
|
+
...result.path !== void 0 && { baselinePath: result.path }
|
|
17679
17693
|
});
|
|
17680
17694
|
} catch (e) {
|
|
17681
17695
|
if (isStackNotDeployed(e)) {
|
|
@@ -18715,7 +18729,7 @@ async function runCheck(args) {
|
|
|
18715
18729
|
const reportHeader = `${posPrefix}${stackName} (${region})`;
|
|
18716
18730
|
let code;
|
|
18717
18731
|
if (a.json) {
|
|
18718
|
-
const { json, code: jsonCode } = buildStackJson(reconciled, reportHeader, baseline !== void 0);
|
|
18732
|
+
const { json, code: jsonCode } = buildStackJson(reconciled, reportHeader, a.showAll ? void 0 : baseline !== void 0);
|
|
18719
18733
|
jsonReports.push(json);
|
|
18720
18734
|
code = jsonCode;
|
|
18721
18735
|
} else code = report(reconciled, reportHeader, {
|