Skip to content

Add shared typed AccessControlList library - #1761

Open
Steve Lee (SteveL-MSFT) wants to merge 8 commits into
PowerShell:mainfrom
SteveL-MSFT:stevel-msft-shared-acl-library
Open

Steve Lee (SteveL-MSFT) wants to merge 8 commits into
PowerShell:mainfrom
SteveL-MSFT:stevel-msft-shared-acl-library

Conversation

@SteveL-MSFT

Copy link
Copy Markdown
Member

Windows ACL handling was duplicated across the filesystem and registry resources and exposed raw SDDL. This change introduces a shared typed model so both resources can manage DACLs and SACLs consistently through structured ACE objects.

Changes

  • Add lib-acl with Win32-backed security descriptor, SID resolution, privilege, DACL, and SACL management.
  • Represent ACE access masks with resource-specific permission enums and accept either usernames or SIDs as principals.
  • Rename the filesystem resource to Microsoft.Filesystem/AccessControlList and replace raw SDDL inputs with accessControlList.
  • Replace the registry acl property with the same typed accessControlList shape.
  • Add _purge, defaulting to true; _purge: false merges ACL entries, removes semantic duplicates, and canonicalizes DACLs with deny ACEs first.
  • Update schemas, registry documentation, localization, and filesystem/registry integration coverage.

This intentionally changes the existing public ACL schema and filesystem resource type name. Reviewers should pay particular attention to permission mappings, SACL privilege handling, and merge/canonicalization semantics.

Validation

./build.ps1 -Project lib-acl,dsc-lib-registry,file_dsc,registry -Clippy -Test

Introduce typed DACL and SACL management for filesystem and registry resources, including SID or username principals, resource-specific permission enums, and merge behavior through _purge.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 16:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved permission-preservation, native memory-safety, privilege-handling, and desired-state comparison issues block approval.

13 open issues
What changed in this PR

Introduces a shared typed ACL library to replace duplicated SDDL handling in filesystem and registry resources.

Changes:

  • Adds structured permissions, principal resolution, and DACL/SACL operations.
  • Migrates resource inputs to accessControlList with replacement and merge modes.
  • Updates schemas, documentation, build registration, and integration tests.
File Description
resources/​registry/​tests/​registrylist_whatif.tests.ps1 Updates list ACL previews.
resources/​registry/​tests/​registrylist_set.tests.ps1 Tests typed list ACL writes.
resources/​registry/​tests/​registrylist_get.tests.ps1 Tests typed list ACL reads.
resources/​registry/​tests/​registry.config.whatif.tests.ps1 Updates ACL preview assertions.
resources/​registry/​tests/​registry.config.set.tests.ps1 Covers replacement and merge behavior.
resources/​registry/​tests/​registry.config.get.tests.ps1 Updates ACL read and validation tests.
resources/​file_dsc/​tests/​filesystem_acl.tests.ps1 Covers typed ACLs, merging, and auditing.
resources/​file_dsc/​src/​types.rs Defines filesystem permissions and ACL input.
resources/​file_dsc/​src/​main.rs Uses the renamed input type.
resources/​file_dsc/​src/​acl.rs Integrates shared ACL operations.
resources/​file_dsc/​locales/​en-us.toml Updates ACL diagnostics.
resources/​file_dsc/​file_dsc.dsc.manifests.json Renames resource and defines typed schema.
resources/​file_dsc/​Cargo.toml Adds shared library dependency.
lib/​lib-acl/​src/​win32/​sid.rs Resolves and formats principals.
lib/​lib-acl/​src/​win32/​security_descriptor.rs Reads and builds security descriptors.
lib/​lib-acl/​src/​win32/​privilege.rs Enables SACL privileges.
lib/​lib-acl/​src/​win32/​mod.rs Exposes Windows ACL helpers.
lib/​lib-acl/​src/​win32/​acl.rs Parses and builds native ACLs.
lib/​lib-acl/​src/​model.rs Defines ACL models, merging, and comparison.
lib/​lib-acl/​src/​lib.rs Exposes the shared library API.
lib/​lib-acl/​src/​error.rs Defines shared ACL errors.
lib/​lib-acl/​Cargo.toml Declares the new crate.
lib/​lib-acl/​.project.data.json Registers library metadata.
lib/​dsc-lib-registry/​src/​lib.rs Integrates typed ACLs and previews.
lib/​dsc-lib-registry/​src/​config.rs Defines registry permissions and ACL property.
lib/​dsc-lib-registry/​src/​acl.rs Uses shared Windows ACL handling.
lib/​dsc-lib-registry/​locales/​en-us.toml Updates registry ACL diagnostics.
lib/​dsc-lib-registry/​Cargo.toml Adds shared library dependency.
docs/​reference/​resources/​Microsoft/​Windows/​Registry/​index.md Documents typed ACL configuration.
data.build.json Registers the library for builds.
Cargo.toml Adds workspace integration and Windows support.
Cargo.lock Records dependency changes.

Review effort: Balanced

Comment thread lib/dsc-lib-registry/src/lib.rs
Comment thread lib/lib-acl/src/model.rs Outdated
Comment thread lib/lib-acl/src/win32/acl.rs Outdated
Comment thread lib/lib-acl/src/win32/security_descriptor.rs Outdated
Comment thread lib/lib-acl/src/win32/security_descriptor.rs Outdated
Comment thread lib/dsc-lib-registry/src/config.rs Outdated
Comment thread lib/dsc-lib-registry/src/lib.rs Outdated
Comment thread lib/lib-acl/src/model.rs
Comment thread lib/lib-acl/src/model.rs Outdated
Comment thread lib/lib-acl/src/win32/sid.rs Outdated
Add native registry test support, preserve complete access masks and canonical ACE ordering, harden raw Win32 boundaries, and align merge and desired-state semantics.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Comment thread lib/dsc-lib-registry/src/lib.rs
Comment thread lib/lib-acl/src/win32/security_descriptor.rs Outdated
Comment thread lib/lib-acl/src/win32/security_descriptor.rs
Comment thread resources/file_dsc/file_dsc.dsc.manifests.json Outdated
Validate ACL operations before registry mutation, represent absent SACLs as empty audit lists, map generic rights for semantic comparison, and align the filesystem schema contract.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The Content resource schema requires a forbidden property, making every instance invalid and blocking its DSC operations.

1 open issue
4 resolved since last review

Review effort: Balanced

Comment thread resources/file_dsc/file_dsc.dsc.manifests.json Outdated
Require accessControlList on the ACL resource without invalidating File/Content instances.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive registry SACL writes and privilege activation still need reliable regression coverage.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Add round-trip coverage for registry SACL writes

lib/​dsc-lib-registry/​src/​acl.rs:178

The new registry SACL write has no round-trip test: current registry SACL tests cover access flags, can_set, and what-if, but never execute this RegSetKeySecurity call. Add an elevated Set/Get/Test case in resources/registry/tests/registry.config.set.tests.ps1 that verifies audit entries, systemProtected, and preservation of the unrequested DACL. Use a temporary key with guaranteed cleanup. The filesystem SACL test uses a different Windows setter and does not cover this path.

Medium severity Privilege availability test leaves SeSecurityPrivilege enabled

lib/​dsc-lib-registry/​src/​acl.rs:471

This availability check enables SeSecurityPrivilege on the process token before can_set runs and leaves it enabled. The test therefore still passes if privilege setup is removed from can_set. Exercise the check against an existing temporary key in an isolated process with the privilege held but initially disabled, and verify that removing privilege setup makes the test fail. Do not disable the shared test process's privilege, since other Rust tests can run concurrently.

1 resolved since last review

Review effort: Balanced

Round-trip registry audit ACLs and verify privilege activation from an isolated process with SeSecurityPrivilege initially disabled.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive Win32 changes and unresolved correctness issues require Windows-focused human review.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Prepare ACL changes before writing registry values

lib/​dsc-lib-registry/​src/​lib.rs:417

With _purge: false, a valid request can pass preflight but fail when effective reads an existing DACL containing a conditional or object-specific ACE that parse_acl rejects. If the request also changes a value, reg_key.set_value at line 398 has already run, so the command fails after modifying registry data. For existing keys, prepare the effective merged descriptor before writing the value and reuse it for the ACL write. Add a regression test showing that an unsupported existing ACE leaves the value unchanged.

Review effort: Balanced

Comment thread lib/lib-acl/src/win32/sid.rs
Steve Lee (POWERSHELL HE/HIM) (from Dev Box) and others added 2 commits October 17, 2026 15:46
Reject embedded NUL principals and prepare reusable merged security descriptors before registry value mutations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The security-sensitive Win32 rewrite needs Windows-focused human validation, particularly for inherited-permission previews.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity What-if omits inherited ACL entries for missing keys

lib/​dsc-lib-registry/​src/​acl.rs:263

For a missing key under a parent with inheritable ACEs, _purge: false previews a different ACL from the one Set applies. Real Set creates the key first (lib.rs:310), then reads and merges its inherited entries through prepare (lib.rs:325). This preview starts from an empty ACL, omitting permissions that will remain after Set. Pass the target path into this helper and compute the new key's inherited ACL without mutation before merging. Add a regression test comparing what-if with subsequent Set/Get under a parent with inheritable entries.

Low severity Localize ACL error templates and diagnostic reasons

lib/​lib-acl/​src/​error.rs:13

These error templates and the validation/resolution reasons are returned unchanged by both resources, so hard-coded English bypasses localization. The existing registry errors use t!-backed formats (lib/dsc-lib-registry/src/error.rs:10–38). Add rust-i18n initialization and an en-us.toml catalog to lib-acl, and localize both its error templates and diagnostic reasons.

1 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive Win32 ACL writes, privilege handling, and inheritance simulation warrant final Windows-focused human review.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants