Add Group Policy template adapter - #1686
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new Rust-based DSC adapter (Microsoft.Adapter/GroupPolicyTemplate) that discovers locally installed Windows Group Policy ADMX/ADML templates and exposes them as dynamically generated DSC resources, with get/set backed by registry operations.
Changes:
- Adds a new
adapters/group_policy_templatecrate implementing ADMX parsing, schema generation, and registry-backed get/set. - Registers the adapter in the workspace (members/default-members/Windows set) and adds required dependencies (
roxmltree, Windows globalization feature). - Adds Pester + Rust unit tests to validate discovery and a basic current-user mutation scenario.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Cargo.toml | Adds the new adapter crate to workspace membership and adds dependencies/features needed for XML + locale support. |
| Cargo.lock | Locks the new adapter crate and roxmltree dependency. |
| adapters/group_policy_template/Cargo.toml | Defines the new adapter crate and its dependencies/targets. |
| adapters/group_policy_template/src/main.rs | Implements adapter CLI dispatch (list/get/set), stdout output, and structured JSON error reporting. |
| adapters/group_policy_template/src/admx.rs | Implements ADMX/ADML discovery, locale resolution, resource modeling, and JSON Schema generation. |
| adapters/group_policy_template/src/registry.rs | Implements policy state read/write logic by mapping scope to HKCU/HKLM and applying registry value semantics. |
| adapters/group_policy_template/locales/en-us.toml | Adds i18n strings for user-facing adapter messages. |
| adapters/group_policy_template/group_policy_template.dsc.resource.json | Adds the DSC adapter manifest wiring list/get/set to the new executable. |
| adapters/group_policy_template/tests/group_policy_template.tests.ps1 | Adds Pester coverage for discovery and an elevated current-user mutation test with restoration. |
| adapters/group_policy_template/.project.data.json | Registers the adapter in repo metadata/build packaging (binary + copy files). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…icy-template-adapter
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
This will also support security settings ? And GPO version change ? |
Can you be more specific on what you're asking for? (I'm not a GPO expert). This adapter is only targeting admx templates. |
Update UTF-16 decoding for the newer Clippy lint and keep localization keys aligned with their uses. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use stable ADMX category identifiers for adapted resource type names and explicitly select the adapter in mutation tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove the unsupported adapter selector from resource get and set test invocations. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Prime the lookup table with all Microsoft adapters so repeat discovery does not add Group Policy resources unexpectedly. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Windows Group Policy templates vary by machine, so DSC needs a dynamic adapter that discovers the locally installed ADMX definitions and exposes them as manageable resources.
This adds the Rust-based
Microsoft.Adapter/GroupPolicyTemplateadapter. It scans%SystemRoot%\PolicyDefinitions, resolves localized ADML strings, groups policies into adaptedGPO.<parentCategory>/<category>resources, and generates JSON Schema for policy toggles and ADMX child elements. Get and set operations map user and machine scope to HKCU and HKLM while preserving ADMX registry value types, delete semantics, policy class restrictions, and enabled/disabled value lists.Pester coverage verifies adapter discovery against installed ADMX files and includes an elevated, current-user-only mutation test with state restoration. Rust unit tests cover naming, binary parsing, and scope-to-hive mapping.
Fix #575