Skip to content

Commit f7e2b66

Browse files
author
secooond
committed
fix(doctor): require enabled accounts and gate extra warnings in allowlist scan
- Only skip top-level warning when at least one enabled account exists - Also suppress plugin extraWarningsForAccount for the top-level scope when all enabled accounts have populated allowlists - Disabled accounts no longer count as 'covered' Refs: #92684
1 parent 9f170a2 commit f7e2b66

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

‎src/commands/doctor/shared/empty-allowlist-scan.ts‎

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,20 @@ export function scanEmptyAllowlistPolicyWarnings(
6666
shouldSkipGroupWarning ?? params.shouldSkipDefaultEmptyGroupAllowlistWarning,
6767
}),
6868
);
69-
if (params.extraWarningsForAccount) {
69+
// Suppress plugin extra warnings for the top-level record when
70+
// all enabled accounts have their own allowlists (issue #92684).
71+
const skipExtras =
72+
shouldSkipGroupWarning
73+
? shouldSkipGroupWarning({
74+
account,
75+
channelName,
76+
dmPolicy,
77+
effectiveAllowFrom,
78+
parent,
79+
prefix,
80+
} as Parameters<NonNullable<typeof shouldSkipGroupWarning>>[0])
81+
: false;
82+
if (params.extraWarningsForAccount && !skipExtras) {
7083
warnings.push(
7184
...params.extraWarningsForAccount({
7285
account,
@@ -90,25 +103,27 @@ export function scanEmptyAllowlistPolicyWarnings(
90103
continue;
91104
}
92105
const accounts = asObjectRecord(channelConfig.accounts);
93-
// When the top-level groupAllowFrom is empty but every real account
106+
// When the top-level groupAllowFrom is empty but every enabled account
94107
// has its own populated groupAllowFrom/allowFrom, the parent scope is
95-
// never reached at runtime — suppress the false-positive warning
96-
// (issue #92684).
97-
const allAccountsHaveAllowlists =
98-
accounts &&
99-
Object.keys(accounts).length > 0 &&
100-
Object.values(accounts).every((entry) => {
101-
if (!entry || typeof entry !== "object" || isDisabledRecord(entry)) {
102-
return true;
103-
}
108+
// never reached at runtime — suppress the false-positive warning and
109+
// plugin extra warnings for the top-level record (issue #92684).
110+
const enabledAccounts =
111+
accounts
112+
? Object.values(accounts).filter(
113+
(entry) => entry && typeof entry === "object" && !isDisabledRecord(entry),
114+
)
115+
: [];
116+
const allEnabledAccountsHaveAllowlists =
117+
enabledAccounts.length > 0 &&
118+
enabledAccounts.every((entry) => {
104119
const rec = entry as DoctorAccountRecord;
105120
return (
106121
((rec.groupAllowFrom as DoctorAllowFromList | undefined)?.length ?? 0) > 0 ||
107122
((rec.allowFrom as DoctorAllowFromList | undefined)?.length ?? 0) > 0
108123
);
109124
});
110125
const skipForTopLevel =
111-
allAccountsHaveAllowlists ? () => true : undefined;
126+
allEnabledAccountsHaveAllowlists ? () => true : undefined;
112127

113128
checkAccount(
114129
channelConfig,

0 commit comments

Comments
 (0)