fix(plugin): resolve admin group references case-insensitively (#1503) - #1524
Merged
Merged
Conversation
SourceMod's admin cache matches group names case-sensitively, so a group defined as "admin" in sb_admin_groups.cfg but referenced as "Admin" in sb_admins.cfg (or in a group-immunity line) failed with a spurious "Unknown group" error and silently dropped the admin's group inheritance. The case drift comes from legacy AMXBans / SourceBans imports, manual DB edits, case-sensitive DB collations, or an older generator build. Fix the config reader (not the generator) since the reader must tolerate a mismatch regardless of its source, and the generator's in-memory path already normalises on the canonical srvgroups.name: - Track parsed server-group names in a StringMap keyed by the case-folded name as sb_admin_groups.cfg is read (RegisterGroupName), cleared and repopulated on every AdminCache_Groups rebuild so stored GroupIds never outlive the group cache they describe. - Add FindAdmGroupInsensitive: exact-case FindAdmGroup first (covers groups from any plugin), then the case-folded map fallback. - Route the admin "group" key and the group-immunity references through it. - Skip pushing an invalid id after the "Unknown group" ParseError. Plugin-reader-only change; sb_main generator and config shape are untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1503. SourceMod's admin cache matches group names case-sensitively, so a server group defined as
admininsb_admin_groups.cfgbut referenced asAdmininsb_admins.cfgfails with a spuriousUnknown group "Admin"error and silently drops the admin's group inheritance (flags, immunity). The same drift breaks group-immunity references between groups.The case mismatch originates upstream of the reader: legacy AMXBans / SourceBans imports, manual DB edits, case-sensitive DB collations, or an older generator build that copied the admin's raw
srv_groupstring instead of the canonicalsrvgroups.name.Root cause & scope
FindAdmGroup()(SourceMod native) is case-sensitive and there is no native to enumerate loaded groups. The fix lives in the config reader (sbpp_admcfg), not the generator (sbpp_main):srvgroups.namevia SQL, soBackupConfigs 0(in-memory) deployments don't exhibit the drift. Touching the DB-facing generator would add risk without covering the file-based path this issue reports.Changes
sbpp_admcfg.sp— newg_GroupNameMap(StringMap, case-folded name →GroupId) plus helpersLowercaseCopy,RegisterGroupName, andFindAdmGroupInsensitive(exact-caseFindAdmGroupfirst, then the case-folded fallback). Released inOnPluginEnd.sbpp_admcfg/sbpp_admin_groups.sp— register each parsed group's name; clear+repopulate the map on everyAdminCache_Groupsrebuild so storedGroupIds never outlive the group cache; route group-immunity references through the case-insensitive lookup.sbpp_admcfg/sbpp_admin_users.sp— route the admingroupkey through the case-insensitive lookup; skip pushing an invalid id after theUnknown groupParseError.Group creation stays case-sensitive (SourceMod owns that); only references are resolved leniently, and only as a fallback after the exact-case match misses.
Adversarial review
Self-reviewed with an adversarial pass. No blockers. Addressed non-blocking findings: documented the map's freshness invariant (groups always rebuild before admins), clarified the case-collapse ("last one wins") comment, added a
maxlength <= 0guard toLowercaseCopy, noted the ASCII-onlyCharToLowerlimitation (benign — non-ASCII bytes pass through identically on both sides), and added explicit map teardown on unload. Confirmed the two-pass immunity parse fully populates the map in pass 1,view_as<GroupId>round-trips cleanly, and the immunityParseErrorparity matches upstream.Test plan
spcomp 1.12compilessbpp_admcfg.spclean (exit 0, no warnings) — matches theplugin-build.ymlgate.adminand an admin referencingAdmin; confirm noUnknown groupin the SM log and the admin inherits the group's flags/immunity.Unknown group.