Skip to content

Commit e1d03cd

Browse files
authored
Merge pull request #1453 from SteveL-MSFT/windows-firewall
Add `Microsoft.Windows/FirewallRuleList` resource
2 parents 9d9863c + a795c26 commit e1d03cd

14 files changed

Lines changed: 1406 additions & 1 deletion

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ members = [
2121
"resources/sshdconfig",
2222
"resources/WindowsUpdate",
2323
"resources/windows_service",
24+
"resources/windows_firewall",
2425
"tools/dsctest",
2526
"tools/test_group_resource",
2627
"grammars/tree-sitter-dscexpression",
@@ -51,6 +52,7 @@ default-members = [
5152
"resources/sshdconfig",
5253
"resources/WindowsUpdate",
5354
"resources/windows_service",
55+
"resources/windows_firewall",
5456
"tools/dsctest",
5557
"tools/test_group_resource",
5658
"grammars/tree-sitter-dscexpression",
@@ -81,6 +83,7 @@ Windows = [
8183
"resources/sshdconfig",
8284
"resources/WindowsUpdate",
8385
"resources/windows_service",
86+
"resources/windows_firewall",
8487
"tools/dsctest",
8588
"tools/test_group_resource",
8689
"grammars/tree-sitter-dscexpression",
@@ -258,6 +261,7 @@ ipnetwork = { version = "0.21" }
258261
# WindowsUpdate, windows_service
259262
windows = { version = "0.62", features = [
260263
"Win32_Foundation",
264+
"Win32_NetworkManagement_WindowsFirewall",
261265
"Win32_System_Com",
262266
"Win32_System_Ole",
263267
"Win32_System_Services",

dsc/tests/dsc_resource_list.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BeforeDiscovery {
1111

1212
Describe 'Tests for listing resources' {
1313
It 'dsc resource list' {
14-
$resources = dsc resource list | ConvertFrom-Json -Depth 10
14+
$resources = dsc resource list | ConvertFrom-Json -Depth 15
1515
$LASTEXITCODE | Should -Be 0
1616
$resources | Should -Not -BeNullOrEmpty
1717
$resources.Count | Should -BeGreaterThan 0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"Name": "windows_firewall",
3+
"Kind": "Resource",
4+
"IsRust": true,
5+
"SupportedPlatformOS": "Windows",
6+
"Binaries": [
7+
"windows_firewall"
8+
],
9+
"CopyFiles": {
10+
"Windows": [
11+
"windows_firewall.dsc.resource.json"
12+
]
13+
}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "windows_firewall"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[package.metadata.i18n]
7+
available-locales = ["en-us"]
8+
default-locale = "en-us"
9+
load-path = "locales"
10+
11+
[dependencies]
12+
rust-i18n = { workspace = true }
13+
serde = { workspace = true }
14+
serde_json = { workspace = true }
15+
16+
[target.'cfg(windows)'.dependencies]
17+
windows = { workspace = true }
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
_version = 1
2+
3+
[main]
4+
missingOperation = "Missing operation. Usage: windows_firewall get --input <json> | set --input <json> | export [--input <json>]"
5+
unknownOperation = "Unknown operation: '%{operation}'. Expected: get, set, or export"
6+
missingInput = "Missing --input argument"
7+
missingInputValue = "Missing value for --input argument"
8+
invalidJson = "Invalid JSON input: %{error}"
9+
windowsOnly = "This resource is only supported on Windows"
10+
11+
[get]
12+
rulesArrayEmpty = "The rules array cannot be empty for get operations"
13+
selectorRequired = "Each firewall rule in a get request must include a name"
14+
15+
[set]
16+
rulesArrayEmpty = "The rules array cannot be empty for set operations"
17+
selectorRequired = "Each firewall rule in a set request must include a name"
18+
19+
[firewall]
20+
comInitFailed = "Failed to initialize COM for Windows Firewall access: %{error}"
21+
policyOpenFailed = "Failed to open the Windows Firewall policy: %{error}"
22+
ruleEnumerationFailed = "Failed to enumerate Windows Firewall rules: %{error}"
23+
ruleLookupFailed = "Failed to look up firewall rule '%{name}': %{error}"
24+
ruleCreateFailed = "Failed to create a firewall rule object: %{error}"
25+
ruleAddFailed = "Failed to add firewall rule '%{name}': %{error}"
26+
ruleRemoveFailed = "Failed to remove firewall rule '%{name}': %{error}"
27+
ruleUpdateFailed = "Failed to update firewall rule '%{name}': %{error}"
28+
ruleReadFailed = "Failed to read firewall rule '%{name}': %{error}"
29+
portsNotAllowed = "Ports cannot be specified for firewall rule '%{name}' because protocol %{protocol} does not support ports"
30+
invalidProfiles = "Invalid profiles value '%{value}'. Valid values are Domain, Private, Public, or All"
31+
invalidInterfaceType = "Invalid interface type '%{value}'. Valid values are RemoteAccess, Wireless, Lan, or All"
32+
invalidProtocol = "Invalid protocol number '%{value}'. Must be between 0 and 256"

0 commit comments

Comments
 (0)