File tree Expand file tree Collapse file tree 5 files changed +83
-14
lines changed Expand file tree Collapse file tree 5 files changed +83
-14
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,9 @@ $filesForWindowsPackage = @(
4444 ' RunCommandOnSet.exe' ,
4545 ' windowspowershell.dsc.resource.json' ,
4646 ' wmi.dsc.resource.json' ,
47- ' wmi.resource.ps1'
47+ ' wmi.resource.ps1' ,
48+ ' configurations/windows_baseline.dsc.yaml' ,
49+ ' configurations/windows_inventory.dsc.yaml'
4850)
4951
5052$filesForLinuxPackage = @ (
Original file line number Diff line number Diff line change 1+ # This configuration validates a Windows system against a security baseline configuration
2+ $schema : https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
3+ metadata :
4+ Microsoft.DSC :
5+ securityContext : Elevated
6+ resources :
7+ - name : Validate the OS is Windows
8+ type : Microsoft.DSC/Assertion
9+ properties :
10+ $schema : https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
11+ resources :
12+ - name : os
13+ type : Microsoft/OSInfo
14+ properties :
15+ family : Windows
16+ - name : Registry checks
17+ type : Microsoft.DSC/Group
18+ dependsOn :
19+ - " [resourceId('Microsoft.DSC/Assertion','Validate the OS is Windows')]"
20+ properties :
21+ $schema : https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
22+ resources :
23+ - name : Default RDP port
24+ type : Microsoft.Windows/Registry
25+ metadata :
26+ area : Network Access
27+ severity : Critical
28+ properties :
29+ keyPath : HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
30+ valueName : PortNumber
31+ valueData :
32+ DWord : 3389
33+ - name : Disable SMBv1
34+ type : Microsoft.Windows/Registry
35+ metadata :
36+ area : Network Access
37+ severity : Critical
38+ properties :
39+ keyPath : HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
40+ valueName : SMB1
41+ valueData :
42+ DWord : 0 # Disabled
43+ - name : Disable Windows Search service
44+ type : Microsoft.Windows/Registry
45+ metadata :
46+ area : Services
47+ severity : Critical
48+ properties :
49+ keyPath : HKLM\SYSTEM\CurrentControlSet\Services\WSearch
50+ valueName : Start
51+ valueData :
52+ DWord : 4 # Disabled
53+ - name : Scan Removeable Drives
54+ type : Microsoft.Windows/Registry
55+ metadata :
56+ area : Services
57+ severity : Critical
58+ properties :
59+ keyPath : HKLM\SOFTWARE\Policies\Microsoft\Windows Defender
60+ valueName : DisableRemovableDriveScanning
61+ valueData :
62+ DWord : 0 # Disabled
Original file line number Diff line number Diff line change 11$schema : https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
22resources :
3+ - name : Validate the OS is Windows
4+ type : Microsoft.DSC/Assertion
5+ properties :
6+ $schema : https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
7+ resources :
8+ - name : os
9+ type : Microsoft/OSInfo
10+ properties :
11+ family : Windows
312- name : WMI
413 type : Microsoft.Windows/WMI
14+ dependsOn :
15+ - " [resourceId('Microsoft.DSC/Assertion','Validate the OS is Windows')]"
516 properties :
617 resources :
718 - name : computer system
@@ -39,4 +50,4 @@ resources:
3950 adaptertype :
4051 netconnectionid :
4152 serviceName :
42- netconnectionstatus : 2
53+ netconnectionstatus : 2 # Connected
Original file line number Diff line number Diff line change @@ -47,15 +47,15 @@ Describe 'WMI adapter resource tests' {
4747 }
4848
4949 It ' Example config works' - Skip:(! $IsWindows ) {
50- $configPath = Join-Path $PSScriptRoot ' ..\..\dsc\examples\wmi_inventory .dsc.yaml'
50+ $configPath = Join-Path $PSScriptRoot ' ..\..\configurations\windows_inventory .dsc.yaml'
5151 $r = dsc config get - p $configPath
5252 $LASTEXITCODE | Should - Be 0
5353 $r | Should -Not - BeNullOrEmpty
5454 $res = $r | ConvertFrom-Json
55- $res.results [0 ].result.actualState[0 ].Name | Should -Not - BeNullOrEmpty
56- $res.results [0 ].result.actualState[0 ].BootupState | Should - BeNullOrEmpty
57- $res.results [0 ].result.actualState[1 ].Caption | Should -Not - BeNullOrEmpty
58- $res.results [0 ].result.actualState[1 ].BuildNumber | Should - BeNullOrEmpty
59- $res.results [0 ].result.actualState[4 ].AdapterType | Should - BeLike " Ethernet*"
55+ $res.results [1 ].result.actualState[0 ].Name | Should -Not - BeNullOrEmpty
56+ $res.results [1 ].result.actualState[0 ].BootupState | Should - BeNullOrEmpty
57+ $res.results [1 ].result.actualState[1 ].Caption | Should -Not - BeNullOrEmpty
58+ $res.results [1 ].result.actualState[1 ].BuildNumber | Should - BeNullOrEmpty
59+ $res.results [1 ].result.actualState[4 ].AdapterType | Should - BeLike " Ethernet*"
6060 }
6161}
Original file line number Diff line number Diff line change @@ -165,12 +165,6 @@ elseif ($Operation -eq 'Get')
165165
166166 $result += @ ($instance_result )
167167 }
168- else
169- {
170- $errmsg = " Can not find type " + $r.type + " ; please ensure that Get-CimInstance returns this resource type"
171- Write-Trace $errmsg
172- exit 1
173- }
174168 }
175169 }
176170 else # we are processing an individual resource call
You can’t perform that action at this time.
0 commit comments