Skip to content

Commit a4c5040

Browse files
committed
WDACConfig module version 0.1.7
Made the Edit-WDACConfig and Edit-SignedWDACConfig cmdlets resilient to errors and unexpected problems by improving their logic.
1 parent 3264511 commit a4c5040

7 files changed

+457
-339
lines changed

WDACConfig/Edit-SignedWDACConfig.psm1

+251-184
Large diffs are not rendered by default.

WDACConfig/Edit-WDACConfig.psm1

+195-125
Large diffs are not rendered by default.

WDACConfig/New-WDACConfig.psm1

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ function New-WDACConfig {
147147
if ($Deployit -and $MakeAllowMSFTWithBlockRules) {
148148
CiTool --update-policy "$PolicyID.cip" -json | Out-Null
149149
Write-host "`n"
150+
Remove-Item -Path "$PolicyID.cip" -Force
150151
}
151152
if ($NoCIP)
152153
{ Remove-Item -Path "$PolicyID.cip" -Force }

WDACConfig/Remove-WDACConfig.psm1

+4-23
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function Remove-WDACConfig {
124124
#region User-Configurations-Processing-Validation
125125
if ($PSCmdlet.ParameterSetName -eq "Signed Base") {
126126
# If any of these parameters, that are mandatory for all of the position 0 parameters, isn't supplied by user
127-
if (!$SignToolPath -or !$CertPath -or !$CertCN) {
127+
if (!$SignToolPath -or !$CertCN) {
128128
# Read User configuration file if it exists
129129
$UserConfig = Get-Content -Path "$env:USERPROFILE\.WDACConfig\UserConfigurations.json" -ErrorAction SilentlyContinue
130130
if ($UserConfig) {
@@ -144,25 +144,8 @@ function Remove-WDACConfig {
144144
} # If it is null, then Get-SignTool will behave the same as if it was called without any arguments.
145145
else {
146146
$SignToolPathFinal = Get-SignTool -SignToolExePath ($UserConfig.SignToolCustomPath ?? $null)
147-
}
148-
149-
# If CertPath parameter wasn't provided by user
150-
if (!$CertPath) {
151-
if ($UserConfig.CertificatePath) {
152-
# validate user config values for Certificate Path
153-
if (Test-Path $($UserConfig.CertificatePath)) {
154-
# If the user config values are correct then use them
155-
$CertPath = $UserConfig.CertificatePath
156-
}
157-
else {
158-
throw "The currently saved value for CertPath in user configurations is invalid."
159-
}
160-
}
161-
else {
162-
throw "CertPath parameter can't be empty and no valid configuration was found for it."
163-
}
164-
}
165-
147+
}
148+
166149
# If CertCN was not provided by user
167150
if (!$CertCN) {
168151
if ($UserConfig.CertificateCommonName) {
@@ -178,8 +161,7 @@ function Remove-WDACConfig {
178161
else {
179162
throw "CertCN parameter can't be empty and no valid configuration was found for it."
180163
}
181-
}
182-
164+
}
183165
}
184166
#endregion User-Configurations-Processing-Validation
185167

@@ -367,5 +349,4 @@ Can be used with any parameter to bypass the online version check - only to be u
367349
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
368350
Register-ArgumentCompleter -CommandName "Remove-WDACConfig" -ParameterName "CertCN" -ScriptBlock $ArgumentCompleterCertificateCN
369351
Register-ArgumentCompleter -CommandName "Remove-WDACConfig" -ParameterName "PolicyPaths" -ScriptBlock $ArgumentCompleterPolicyPathsBasePoliciesOnly
370-
Register-ArgumentCompleter -CommandName "Remove-WDACConfig" -ParameterName "CertPath" -ScriptBlock $ArgumentCompleterCertPath
371352
Register-ArgumentCompleter -CommandName "Remove-WDACConfig" -ParameterName "SignToolPath" -ScriptBlock $ArgumentCompleterSignToolPath

WDACConfig/Resources.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ function Confirm-CertCN ([string]$CN) {
312312
$WriteViolet = { Write-Output "$($PSStyle.Foreground.FromRGB(153,0,255))$($args[0])$($PSStyle.Reset)" }
313313
$WritePink = { Write-Output "$($PSStyle.Foreground.FromRGB(255,0,230))$($args[0])$($PSStyle.Reset)" }
314314
$WriteLavender = { Write-Output "$($PSStyle.Foreground.FromRgb(255,179,255))$($args[0])$($PSStyle.Reset)" }
315+
$WriteTeaGreen = { Write-Output "$($PSStyle.Foreground.FromRgb(133, 222, 119))$($args[0])$($PSStyle.Reset)" }
315316

316317
# Define an array of cute RGB colors
317318
$SubtleCuteColors = @(

WDACConfig/WDACConfig.psd1

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# RootModule = ""
99

1010
# Version number of this module.
11-
ModuleVersion = '0.1.6'
11+
ModuleVersion = '0.1.7'
1212

1313
# Supported PSEditions
1414
CompatiblePSEditions = @("Core")
@@ -146,6 +146,9 @@ To get help and syntax on PowerShell console, type:
146146
# ReleaseNotes of this module
147147
ReleaseNotes = @"
148148
149+
## Version 0.1.7
150+
Made the Edit-WDACConfig and Edit-SignedWDACConfig cmdlets resilient to errors and unexpected problems by improving their logic.
151+
149152
## Version 0.1.6
150153
New cmdlet Set-CommonWDACConfig, Use this cmdlet to store the values for common and frequently used parameters so that you won't have to specify them again every time.
151154
More info about it: https://github.com/HotCakeX/Harden-Windows-Security/wiki/Set-CommonWDACConfig
@@ -157,11 +160,6 @@ Added alias for many parameters for easier access.
157160
Added new cmdlet: New-DenyWDACConfig for creating base policies with Deny rules. They can be deployed side by side other policies without conflict.
158161
Added argument completer for many new parameters and improved the previous ones to be smarter in their suggestions.
159162
160-
## Version 0.1.4
161-
Code optimization.
162-
Implemented a check to make sure Windows 11 22H2 is being used as it's a requirement for this module to run.
163-
Improved Remove-WDACConfig cmdlet by making the argument completers only show policies that haven't been already deleted, also applied a fix to this cmdlet for when multiple policies with the same name are deployed.
164-
165163
Full Change log for previous versions are available on Excel online: (Copy and paste the link in your browser if it isn't clickable)
166164
https://1drv.ms/x/s!AtCaUNAJbbvIhuVPpPeCHSjl75OqBQ?e=qgvzEt
167165

WDACConfig/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.6
1+
0.1.7

0 commit comments

Comments
 (0)