@@ -14,12 +14,11 @@ Describe "BOSH.WindowsUpdates" {
1414 Describe " Disable-AutomaticUpdates" {
1515 BeforeEach {
1616 $oldWuauStatus = (Get-Service wuauserv).Status
17- $oldWuauStartMode = ( Get-Service wuauserv).StartType
17+ $oldWuauStartMode = (Get-Service wuauserv).StartType
1818
1919 { Set-Service - Name wuauserv - StartupType " Manual" } | Should -Not - Throw
2020 { Set-Service - Name wuauserv - Status " Running" } | Should -Not - Throw
2121
22-
2322 $oldAUOptions = (Get-ItemProperty - Path ' HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' ).AUOptions
2423 $oldEnableFeaturedSoftware = (Get-ItemProperty - Path ' HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' ).EnableFeaturedSoftware
2524 $oldIncludeRecUpdates = (Get-ItemProperty - Path ' HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' ).IncludeRecommendedUpdates
@@ -80,185 +79,4 @@ Describe "BOSH.WindowsUpdates" {
8079 (Get-ItemProperty - Path ' HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update' ).IncludeRecommendedUpdates | Should - Be " 0"
8180 }
8281 }
83-
84- Describe " Enable-SecurityPatches" {
85- It " enables CVE-2015-6161" {
86- $handlerHardeningPath32Exists = $false
87- $oldIExplore32 = " "
88- if (Test-Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" )
89- {
90- $handlerHardeningPathExists32 = $true
91- $oldIExplore32 = (Get-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" ).' iexplore.exe'
92- }
93-
94- $handlerHardeningPath64Exists = $false
95- $oldIExplore64 = " "
96- if (Test-Path " HKLM:\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" )
97- {
98- $handlerHardeningPath64Exists = $true
99- $oldIExplore64 = (Get-ItemProperty - Path " HKLM:\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" ).' iexplore.exe'
100- }
101-
102- { Enable-CVE - 2015 - 6161 } | Should -Not - Throw
103-
104- (Get-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" ).' iexplore.exe' | Should - Be " 1"
105- (Get-ItemProperty - Path " HKLM:\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" ).' iexplore.exe' | Should - Be " 1"
106-
107- if ($handlerHardeningPath32Exists )
108- {
109- if ($oldIExplore32 -eq " " )
110- {
111- Remove-Item - Property - Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" - Name " iexplore.exe"
112- }
113- else
114- {
115- Set-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" - Value $oldIExplore32 - Name " iexplore.exe"
116- }
117- }
118- else
119- {
120- Remove-Item " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING"
121- }
122-
123- if ($handlerHardeningPath32Exists )
124- {
125- if ($oldIExplore64 -eq " " )
126- {
127- Remove-Item - Property - Path " HKLM:\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" - Name " iexplore.exe"
128- }
129- else
130- {
131- Set-ItemProperty - Path " HKLM:\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING" - Value $oldIExplore64 - Name " iexplore.exe"
132- }
133- }
134- else
135- {
136- Remove-Item " HKLM:\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING"
137- }
138- }
139-
140- It " enables CVE-2017-8529" {
141- $disclosureFixPathExists32 = $false
142- $oldIExplore32 = " "
143- if (Test-Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" )
144- {
145- $disclosureFixPathExists32 = $true
146- $oldIExplore32 = (Get-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" ).' iexplore.exe'
147- }
148-
149- $disclosureFixPathExists64 = $false
150- $oldIExplore64 = " "
151- if (Test-Path " HKLM:\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" )
152- {
153- $disclosureFixPathExists64 = $true
154- $oldIExplore64 = (Get-ItemProperty - Path " HKLM:\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" ).' iexplore.exe'
155- }
156-
157- { Enable-CVE - 2017 - 8529 } | Should -Not - Throw
158-
159- (Get-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" ).' iexplore.exe' | Should - Be " 1"
160- (Get-ItemProperty - Path " HKLM:\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" ).' iexplore.exe' | Should - Be " 1"
161-
162- if ($disclosureFixPathExists32 )
163- {
164- if ($oldIExplore32 -eq " " )
165- {
166- Remove-Item - Property - Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" - Name " iexplore.exe"
167- }
168- else
169- {
170- Set-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" - Value $oldIExplore32 - Name " iexplore.exe"
171- }
172- }
173- else
174- {
175- Remove-Item " HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX"
176- }
177-
178- if ($disclosureFixPathExists64 )
179- {
180- if ($oldIExplore64 -eq " " )
181- {
182- Remove-Item - Property - Path " HKLM:\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" - Name " iexplore.exe"
183- }
184- else
185- {
186- Set-ItemProperty - Path " HKLM:\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX" - Value $oldIExplore64 - Name " iexplore.exe"
187- }
188- }
189- else
190- {
191- Remove-Item " HKLM:\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PRINT_INFO_DISCLOSURE_FIX"
192- }
193- }
194-
195- It " enables CredSSP" {
196- $credSSPPathExists = $false
197- $credSSPParamPathExists = $false
198- $oldEcryptOracle = " "
199- if (Test-Path " HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP" )
200- {
201- $credSSPPathExists = $true
202- if (Test-Path " HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters" )
203- {
204- $credSSPParamPathExists = $true
205- $oldEcryptOracle = (Get-ItemProperty - Path " HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters" ).AllowEncryptionOracle
206- }
207- }
208-
209- { Enable-CredSSP } | Should -Not - Throw
210-
211- (Get-ItemProperty - Path " HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters" ).AllowEncryptionOracle | Should - Be " 1"
212-
213- if ($credSSPPathExists )
214- {
215- if ($credSSPParamPathExists )
216- {
217- if ($oldEcryptOracle -eq " " )
218- {
219- Remove-Item - Property - Path " HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters" - Name " AllowEncryptionOracle"
220- }
221- else
222- {
223- Set-ItemProperty - Path " HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters" - Value $oldEcryptOracle - Name " AllowEncryptionOracle"
224- }
225- }
226- else
227- {
228- Remove-Item " HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters"
229- }
230- }
231- else
232- {
233- Remove-Item " HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP" - Recurse
234-
235- }
236- }
237- }
238-
239- Describe " Upgrade-PSVersion" {
240- It " Only installs if powershell 5.1 or above is not installed" {
241- Mock - ModuleName BOSH.WindowsUpdates Test-PSVersion { $true }
242- Mock - ModuleName BOSH.WindowsUpdates Invoke-WebRequest { }
243- Mock - ModuleName BOSH.WindowsUpdates Start-Process { }
244-
245- { Upgrade- PSVersion } | Should -Not - Throw
246-
247- Assert-MockCalled Test-PSVersion - Times 1 - Scope It - ModuleName BOSH.WindowsUpdates
248- Assert-MockCalled Invoke-WebRequest - Times 0 - Scope It - ModuleName BOSH.WindowsUpdates
249- Assert-MockCalled Start-Process - Times 0 - Scope It - ModuleName BOSH.WindowsUpdates
250- }
251-
252- It " Only installs if powershell 5.1 or above is not installed" {
253- Mock - ModuleName BOSH.WindowsUpdates Test-PSVersion { $false }
254- Mock - ModuleName BOSH.WindowsUpdates Invoke-WebRequest { }
255- Mock - ModuleName BOSH.WindowsUpdates Start-Process { }
256-
257- { Upgrade- PSVersion } | Should -Not - Throw
258-
259- Assert-MockCalled Test-PSVersion - Times 1 - Scope It - ModuleName BOSH.WindowsUpdates
260- Assert-MockCalled Invoke-WebRequest - Times 1 - Scope It - ParameterFilter { $Uri -eq " https://go.microsoft.com/fwlink/?linkid=839516" -and $Outfile -eq " C:\provision\PS51.msu" -and $UseBasicParsing.IsPresent } - ModuleName BOSH.WindowsUpdates
261- Assert-MockCalled Start-Process - Times 1 - Scope It - ParameterFilter { $FilePath -eq " C:\provision\PS51.msu" -and $ArgumentList -eq ' /quiet /norestart /log:"C:\provision\psupgrade.log"' -and $Wait.IsPresent -and $Passthru.IsPresent } - ModuleName BOSH.WindowsUpdates
262- }
263- }
26482}
0 commit comments