Make RightToSDDL reverse map deterministic for colliding mask values (#81)#88
Merged
Merged
Conversation
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.
Linked Issue
Closes #81Motivation
RightToSDDLwas built ininit()by ranging overSDDLToRightand assigningRightToSDDL[right] = sddl. Two distinct tokens map to the same mask —"KR"(KEY_READ) and"KX"(KEY_EXECUTE) are both0x00020019— so the surviving token for that value depended on Go's randomized map-iteration order and changed between runs. Any consumer rendering a mask back to an SDDL token got an unstable, sometimes-wrong abbreviation.What Changed
init()now collects theSDDLToRighttokens, sorts them, and inserts intoRightToSDDLkeeping the first (lexicographically smallest) token for each mask. For the colliding value this deterministically yields"KR"(since"KR" < "KX").sortimport.Design Notes
Lexicographic first-wins is a deterministic, documented tie-break that requires no second source of truth to maintain.
"KR"is the natural canonical token for0x00020019(KEY_READ is the conventional rendering of that mask). The forwardSDDLToRightmap is unchanged, so both"KR"and"KX"still parse to0x00020019.Acceptance Criteria Check
RightToSDDL[0x00020019]returns the same token on every run —TestRightToSDDL_CollisionDeterministicasserts it is"KR"; the sorted-iteration construction makes it run-independent.TestRightToSDDL_CollisionDeterministicandTestRightToSDDL_IsValidInverse(every reverse entry maps back to its mask, and every forward mask is representable).SDDLToRightparsing behavior — the forward map is untouched.How Verified
sddl/rights/rights_test.go—TestRightToSDDL_CollisionDeterministic,TestRightToSDDL_IsValidInverse.go build ./...andgo test ./...pass.Test Coverage
sddl/rightspackage).Scope of Change
sddl/rights/rights.go,sddl/rights/rights_test.goRightToSDDLlookups become deterministicRisk and Rollout
Trivial and local; only the previously-random winner for colliding masks is now fixed. Safe to merge.