Skip to content

Commit

Permalink
WDACConfig module version 0.1.7
Browse files Browse the repository at this point in the history
Made the Edit-WDACConfig and Edit-SignedWDACConfig cmdlets resilient to errors and unexpected problems by improving their logic.
  • Loading branch information
HotCakeX committed May 28, 2023
1 parent 3264511 commit a4c5040
Show file tree
Hide file tree
Showing 7 changed files with 457 additions and 339 deletions.
435 changes: 251 additions & 184 deletions WDACConfig/Edit-SignedWDACConfig.psm1

Large diffs are not rendered by default.

320 changes: 195 additions & 125 deletions WDACConfig/Edit-WDACConfig.psm1

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions WDACConfig/New-WDACConfig.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function New-WDACConfig {
if ($Deployit -and $MakeAllowMSFTWithBlockRules) {
CiTool --update-policy "$PolicyID.cip" -json | Out-Null
Write-host "`n"
Remove-Item -Path "$PolicyID.cip" -Force
}
if ($NoCIP)
{ Remove-Item -Path "$PolicyID.cip" -Force }
Expand Down
27 changes: 4 additions & 23 deletions WDACConfig/Remove-WDACConfig.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function Remove-WDACConfig {
#region User-Configurations-Processing-Validation
if ($PSCmdlet.ParameterSetName -eq "Signed Base") {
# If any of these parameters, that are mandatory for all of the position 0 parameters, isn't supplied by user
if (!$SignToolPath -or !$CertPath -or !$CertCN) {
if (!$SignToolPath -or !$CertCN) {
# Read User configuration file if it exists
$UserConfig = Get-Content -Path "$env:USERPROFILE\.WDACConfig\UserConfigurations.json" -ErrorAction SilentlyContinue
if ($UserConfig) {
Expand All @@ -144,25 +144,8 @@ function Remove-WDACConfig {
} # If it is null, then Get-SignTool will behave the same as if it was called without any arguments.
else {
$SignToolPathFinal = Get-SignTool -SignToolExePath ($UserConfig.SignToolCustomPath ?? $null)
}

# If CertPath parameter wasn't provided by user
if (!$CertPath) {
if ($UserConfig.CertificatePath) {
# validate user config values for Certificate Path
if (Test-Path $($UserConfig.CertificatePath)) {
# If the user config values are correct then use them
$CertPath = $UserConfig.CertificatePath
}
else {
throw "The currently saved value for CertPath in user configurations is invalid."
}
}
else {
throw "CertPath parameter can't be empty and no valid configuration was found for it."
}
}

}

# If CertCN was not provided by user
if (!$CertCN) {
if ($UserConfig.CertificateCommonName) {
Expand All @@ -178,8 +161,7 @@ function Remove-WDACConfig {
else {
throw "CertCN parameter can't be empty and no valid configuration was found for it."
}
}

}
}
#endregion User-Configurations-Processing-Validation

Expand Down Expand Up @@ -367,5 +349,4 @@ Can be used with any parameter to bypass the online version check - only to be u
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
Register-ArgumentCompleter -CommandName "Remove-WDACConfig" -ParameterName "CertCN" -ScriptBlock $ArgumentCompleterCertificateCN
Register-ArgumentCompleter -CommandName "Remove-WDACConfig" -ParameterName "PolicyPaths" -ScriptBlock $ArgumentCompleterPolicyPathsBasePoliciesOnly
Register-ArgumentCompleter -CommandName "Remove-WDACConfig" -ParameterName "CertPath" -ScriptBlock $ArgumentCompleterCertPath
Register-ArgumentCompleter -CommandName "Remove-WDACConfig" -ParameterName "SignToolPath" -ScriptBlock $ArgumentCompleterSignToolPath
1 change: 1 addition & 0 deletions WDACConfig/Resources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ function Confirm-CertCN ([string]$CN) {
$WriteViolet = { Write-Output "$($PSStyle.Foreground.FromRGB(153,0,255))$($args[0])$($PSStyle.Reset)" }
$WritePink = { Write-Output "$($PSStyle.Foreground.FromRGB(255,0,230))$($args[0])$($PSStyle.Reset)" }
$WriteLavender = { Write-Output "$($PSStyle.Foreground.FromRgb(255,179,255))$($args[0])$($PSStyle.Reset)" }
$WriteTeaGreen = { Write-Output "$($PSStyle.Foreground.FromRgb(133, 222, 119))$($args[0])$($PSStyle.Reset)" }

# Define an array of cute RGB colors
$SubtleCuteColors = @(
Expand Down
10 changes: 4 additions & 6 deletions WDACConfig/WDACConfig.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# RootModule = ""

# Version number of this module.
ModuleVersion = '0.1.6'
ModuleVersion = '0.1.7'

# Supported PSEditions
CompatiblePSEditions = @("Core")
Expand Down Expand Up @@ -146,6 +146,9 @@ To get help and syntax on PowerShell console, type:
# ReleaseNotes of this module
ReleaseNotes = @"
## Version 0.1.7
Made the Edit-WDACConfig and Edit-SignedWDACConfig cmdlets resilient to errors and unexpected problems by improving their logic.
## Version 0.1.6
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.
More info about it: https://github.com/HotCakeX/Harden-Windows-Security/wiki/Set-CommonWDACConfig
Expand All @@ -157,11 +160,6 @@ Added alias for many parameters for easier access.
Added new cmdlet: New-DenyWDACConfig for creating base policies with Deny rules. They can be deployed side by side other policies without conflict.
Added argument completer for many new parameters and improved the previous ones to be smarter in their suggestions.
## Version 0.1.4
Code optimization.
Implemented a check to make sure Windows 11 22H2 is being used as it's a requirement for this module to run.
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.
Full Change log for previous versions are available on Excel online: (Copy and paste the link in your browser if it isn't clickable)
https://1drv.ms/x/s!AtCaUNAJbbvIhuVPpPeCHSjl75OqBQ?e=qgvzEt
Expand Down
2 changes: 1 addition & 1 deletion WDACConfig/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.6
0.1.7

0 comments on commit a4c5040

Please sign in to comment.