Add constexpr security descriptor building#628
Open
jonwis wants to merge 6 commits intomicrosoft:masterfrom
Open
Add constexpr security descriptor building#628jonwis wants to merge 6 commits intomicrosoft:masterfrom
jonwis wants to merge 6 commits intomicrosoft:masterfrom
Conversation
…elf_relative_sd(), make_allow_ace(), make_deny_ace(),\nsd_owner(), sd_group(), and no_sid for composing self-relative\nsecurity descriptors at compile time from static SIDs and typed\nACEs. C++20 only, gated behind _HAS_CXX20.\n\nSupports allow/deny ACE types, per-ACE inheritance flags, and\noptional owner/group SIDs. Deny-before-allow ordering enforced\nvia WI_ASSERT."
…n\nParse SID string literals (e.g. \"S-1-5-32-544\") into static_sid_t\nat compile time via C++20 class-type NTTPs. The resulting SID works\nwith all existing helpers: sd_owner, sd_group, make_allow_ace, etc.\n\nGuarded behind __WIL_HAS_CLASS_NTTP which checks for class-type\nNTTP support on both MSVC and Clang."
dmachaj
reviewed
Apr 2, 2026
| size_t count = 0; | ||
| for (size_t i = 0; i < S.length; ++i) | ||
| { | ||
| if (S.data[i] == '-') |
Collaborator
There was a problem hiding this comment.
[nit] Style standard is usually to always have { } even for single line if blocks.
Member
Author
There was a problem hiding this comment.
Fair - i'll ask GHCP why it didn't follow the clang-format conventions.
| uint64_t value = 0; | ||
| while (pos < len && str[pos] >= '0' && str[pos] <= '9') | ||
| { | ||
| value = value * 10 + static_cast<uint64_t>(str[pos] - '0'); |
Collaborator
There was a problem hiding this comment.
I had to glare at this for a minute to be sure order of operations was intended. Consider adding ( ) around the multiply to make it obviously-intentional.
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.
We have a lot of code in various startup paths that uses ConvertStringSecurityDescriptorToSecurityDescriptor, or worse, does hand-building of SECURITY_DESCRIPTOR with building all the ACEs, parsing SID strings, etc.
This introduces a constexpr SD builder, skipping all that and building a self-relative SD at compile time. So now you can say things like: