-
Notifications
You must be signed in to change notification settings - Fork 55
Add WindowsUpdate resource #1351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7cf3f7d
Add WindowsUpdate resource
a781be6
use direct COM APIs instead of IDispatch
f4ae5f1
refactor code, fix reading stdin to not block
4a4d81b
fix tests
4541bc0
code quality fixes
f0b4e17
fix test to skip on non-windows
4f20dda
update filtering rules
718c563
fix cmdline help
103ff0d
address copilot feedback, switch from minDownloadSize to recommendedH…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "Name": "windowsupdate", | ||
| "Kind": "Resource", | ||
| "IsRust": true, | ||
| "SupportedPlatformOS": "Windows", | ||
| "Binaries": [ | ||
| "wu_dsc" | ||
| ], | ||
| "CopyFiles": { | ||
| "Windows": [ | ||
| "windowsupdate.dsc.resource.json" | ||
| ] | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [package] | ||
| name = "dsc-resource-windows-update" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
|
|
||
| [[bin]] | ||
| name = "wu_dsc" | ||
| path = "src/main.rs" | ||
|
|
||
| [dependencies] | ||
| serde = { workspace = true } | ||
| serde_json = { workspace = true } | ||
|
|
||
| [target.'cfg(windows)'.dependencies] | ||
| windows = { workspace = true } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| # Microsoft.Windows/UpdateList DSC Resource | ||
|
|
||
| ## Overview | ||
|
|
||
| The `Microsoft.Windows/UpdateList` resource enables querying information about Windows Updates using the Windows Update Agent COM APIs. This resource allows you to retrieve detailed information about specific updates available on or installed on a Windows system. | ||
|
|
||
| ## Features | ||
|
|
||
| - Query Windows Update information by title | ||
| - Retrieve comprehensive update details including: | ||
| - Installation status | ||
| - Update description | ||
| - Unique update identifier | ||
| - KB article IDs | ||
| - Recommended hard disk space | ||
| - Security severity rating | ||
| - Security bulletin IDs | ||
| - Update type (Software or Driver) | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Windows operating system | ||
| - Windows Update Agent (built into Windows) | ||
| - Administrator privileges may be required for certain update queries | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Get Operation | ||
|
|
||
| The `get` operation searches for a Windows Update by title or id (as exact match) and returns detailed information about the update. | ||
|
|
||
| #### Input Schema | ||
|
|
||
| ```json | ||
| { | ||
| "updates": [{ | ||
| "title": "Security Update" | ||
| }] | ||
| } | ||
| ``` | ||
|
|
||
| #### Example DSC Configuration | ||
|
|
||
| ```yaml | ||
| # windows-update-query.dsc.yaml | ||
| $schema: https://aka.ms/dsc/schemas/v3/configuration.json | ||
| resources: | ||
| - name: QuerySecurityUpdate | ||
| type: Microsoft.Windows/UpdateList | ||
| properties: | ||
| updates: | ||
| - title: "Security Update for Windows" | ||
| ``` | ||
|
|
||
| #### Output Example | ||
|
|
||
| ```json | ||
| { | ||
| "updates": [{ | ||
| "title": "2024-01 Security Update for Windows 11 Version 22H2 for x64-based Systems (KB5034123)", | ||
| "isInstalled": true, | ||
| "description": "Install this update to resolve issues in Windows...", | ||
| "id": "12345678-1234-1234-1234-123456789abc", | ||
| "isUninstallable": true, | ||
| "kbArticleIds": ["5034123"], | ||
| "recommendedHardDiskSpace": 512, | ||
| "msrcSeverity": "Critical", | ||
| "securityBulletinIds": ["MS24-001"], | ||
| "updateType": "Software" | ||
| }] | ||
| } | ||
| ``` | ||
|
|
||
| ## Properties | ||
|
|
||
| ### Input/Output Properties | ||
|
|
||
| The resource returns an UpdateList object containing an array of updates: | ||
|
|
||
| | Property | Type | Description | | ||
| |-----------------------|-----------------|-------------------------------------------------------| | ||
| | updates | array | Array of update objects | | ||
| | updates[].title | string | The full title of the Windows Update | | ||
| | updates[].isInstalled | boolean | Whether the update is currently installed | | ||
| | updates[].description | string | Detailed description of the update | | ||
| | updates[].id | string | Unique identifier (GUID) for the update | | ||
| | updates[].isUninstallable | boolean | Whether the update can be uninstalled | | ||
| | updates[].kbArticleIds | array[string] | Knowledge Base article identifiers | | ||
| | updates[].recommendedHardDiskSpace | integer (int64) | Recommended hard disk space in megabytes (MB) | | ||
| | updates[].msrcSeverity | enum | MSRC severity: Critical, Important, Moderate, or Low | | ||
| | updates[].securityBulletinIds | array[string] | Security bulletin identifiers | | ||
| | updates[].updateType | enum | Type of update: Software or Driver | | ||
|
|
||
| ## Implementation Details | ||
|
|
||
| - **Language**: Rust | ||
| - **Executable**: `wu_dsc` | ||
| - **COM APIs Used**: Windows Update Agent (WUA) COM interfaces | ||
| - `IUpdateSession` | ||
| - `IUpdateSearcher` | ||
| - `IUpdateCollection` | ||
| - `IUpdate` | ||
|
|
||
| ## Limitations | ||
|
|
||
| - Requires Windows operating system | ||
| - Search is case-insensitive and matches partial titles | ||
|
|
||
| ## Building | ||
|
|
||
| To build the resource: | ||
|
|
||
| ```powershell | ||
| cd resources/WindowsUpdate | ||
| cargo build --release | ||
| ``` | ||
|
|
||
| The compiled executable will be located at `target/release/wu_dsc.exe`. | ||
|
|
||
| ## Testing | ||
|
|
||
| To test the resource manually: | ||
|
|
||
| ```powershell | ||
| # Create input JSON | ||
| $input = @{ updates = @(@{ title = "Security Update" }) } | ConvertTo-Json -Depth 3 | ||
|
|
||
| # Query for an update | ||
| $input | .\wu_dsc.exe get | ||
| ``` | ||
|
|
||
| ## Error Handling | ||
|
|
||
| The resource will return an error if: | ||
| - No update matching the specified title is found | ||
| - COM initialization fails | ||
| - The Windows Update service is unavailable | ||
| - Invalid input is provided | ||
|
|
||
| ## License | ||
|
|
||
| Copyright (c) Microsoft Corporation. | ||
| Licensed under the MIT License. | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.