Skip to content

Commit

Permalink
version bump and error preference improvement
Browse files Browse the repository at this point in the history
version bump and error preference improvement
  • Loading branch information
HotCakeX committed Aug 26, 2024
1 parent b5fcc85 commit 8878a63
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private void Confirm(object obj)
// Create a collection view based on the security options collection
_membersView = System.Windows.Data.CollectionViewSource.GetDefaultView(_members);

// Set the ItemSource of the DataGrid in the Confirm view to the collection view
// Set the ItemSource of the DataGrid in the Confirm view to the collection view
if (HardenWindowsSecurity.ConfirmSystemComplianceGUI.membersDataGrid != null)
{
// Bind the DataGrid to the collection view
Expand Down Expand Up @@ -388,7 +388,7 @@ await System.Threading.Tasks.Task.Run(() =>
await System.Windows.Application.Current.Dispatcher.InvokeAsync(() =>
{
LoadMembers(); // Load updated security options
RefreshButton.IsChecked = false; // Uncheck the Refresh button
RefreshButton.IsChecked = false; // Uncheck the Refresh button
});
// mark as activity completed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function Confirm-SystemCompliance {
[System.Management.Automation.SwitchParameter]$Offline
)
begin {
$script:ErrorActionPreference = 'Stop'
# Makes sure this cmdlet is invoked with Admin privileges
if (-NOT ([HardenWindowsSecurity.UserPrivCheck]::IsAdmin())) {
Throw [System.Security.AccessControl.PrivilegeNotHeldException] 'Administrator'
Expand Down Expand Up @@ -155,6 +156,8 @@ function Confirm-SystemCompliance {

process {
try {
Write-Progress -Activity 'Performing Compliance Check...' -Status 'Running' -PercentComplete 50

[HardenWindowsSecurity.InvokeConfirmation]::Invoke($Categories)

# Making sure all the true/false values have the same case
Expand Down Expand Up @@ -288,6 +291,7 @@ function Confirm-SystemCompliance {
Throw $_
}
finally {
Write-Progress -Activity 'Compliance checks have been completed' -Status 'Completed' -Completed
[HardenWindowsSecurity.ControlledFolderAccessHandler]::Reset()
[HardenWindowsSecurity.Miscellaneous]::CleanUp()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ Function Protect-WindowsSecurity {
}

begin {
$script:ErrorActionPreference = 'Stop'
[HardenWindowsSecurity.Initializer]::Initialize($VerbosePreference)
[System.Boolean]$ErrorsOcurred = $false

Expand Down Expand Up @@ -407,6 +408,7 @@ Function Protect-WindowsSecurity {
# Download the required files
if (!([HardenWindowsSecurity.GlobalVars]::Offline)) {
Write-Verbose -Message 'Downloading the required files'
Write-Progress -Activity 'Downloading the required files' -Status 'Downloading' -PercentComplete 20
}
[HardenWindowsSecurity.FileDownloader]::PrepDownloadedFiles(
"$PathToLGPO",
Expand All @@ -415,6 +417,8 @@ Function Protect-WindowsSecurity {
)
Write-Verbose -Message 'Finished downloading/processing the required files'

Write-Progress -Activity 'Applying the security measures' -Status 'Protecting' -PercentComplete 50

# a label to break out of the main switch statements and run the finally block when user chooses to exit
:MainSwitchLabel switch ($Categories) {
'MicrosoftSecurityBaselines' { Invoke-MicrosoftSecurityBaselines -RunUnattended }
Expand Down Expand Up @@ -451,6 +455,7 @@ Function Protect-WindowsSecurity {
$ErrorsOcurred = $true
}
finally {
Write-Progress -Activity 'Protection completed' -Status 'Completed' -Completed
if ($null -ne $CurrentPowerShellTitle) {
Write-Verbose -Message 'Restoring the title of the PowerShell back to what it was prior to running the module'
$Host.UI.RawUI.WindowTitle = $CurrentPowerShellTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Function Unprotect-WindowsSecurity {
if (-NOT ([HardenWindowsSecurity.UserPrivCheck]::IsAdmin())) {
Throw [System.Security.AccessControl.PrivilegeNotHeldException] 'Administrator'
}
$script:ErrorActionPreference = 'Stop'
[HardenWindowsSecurity.Initializer]::Initialize($VerbosePreference)

Write-Verbose -Message 'Importing the required sub-modules'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_module_manifests

RootModule = 'Harden-Windows-Security-Module.psm1'
ModuleVersion = '0.5.6'
ModuleVersion = '0.5.7'
CompatiblePSEditions = @('Core')
GUID = 'afae7a0a-5eff-4a4d-9139-e1702b7ac426'
Author = 'HotCakeX'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$global:ErrorActionPreference = 'Stop'
$script:ErrorActionPreference = 'Stop'

try {
$PSStyle.Progress.UseOSCIndicator = $true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,19 @@
Visibility="{Binding ElementName=textBoxFilter, Path=Text.IsEmpty}" />
<TextBox Name="textBoxFilter" Style="{StaticResource filterTextBox}" />
</Grid>

<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,0,0,30">

<TextBlock x:Name="CompliantItemsTextBlock"
FontSize="15" FontWeight="SemiBold" Foreground="#121518"
HorizontalAlignment="Left" VerticalAlignment="Center"
Margin="0,0,40,0"/>
Margin="0,0,40,0"/>

<!-- Add some margin to the right -->
<TextBlock x:Name="NonCompliantItemsTextBlock"
FontSize="15" FontWeight="SemiBold" Foreground="#121518"
HorizontalAlignment="Right" VerticalAlignment="Center"/>

</StackPanel>

<!--SecOps Data Grid-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$ErrorActionPreference = 'Stop'
$script:ErrorActionPreference = 'Stop'

#Region Helper-Functions-And-ScriptBlocks
# The following functions do not rely on any script-wide or global variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function Update-self {
[ValidatePattern('^(Protect-WindowsSecurity|Unprotect-WindowsSecurity|Confirm-SystemCompliance)(?!.*[;`]).*$', ErrorMessage = 'Either Update-self function was called with an unauthorized command or it contains semicolon and/or backtick')]
[System.String]$InvocationStatement
)
$script:ErrorActionPreference = 'Stop'

# Get the current module's version
[System.Version]$CurrentVersion = (Test-ModuleManifest -Path "$([HardenWindowsSecurity.GlobalVars]::Path)\Harden-Windows-Security-Module.psd1").Version
Expand Down
6 changes: 6 additions & 0 deletions Harden-Windows-Security Module/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ namespace HardenWindowsSecurity
{
class Program
{
/// <summary>
/// You can use this method when working on the module in Visual Studio
/// Simply press F5 and the UI will boot. The same can be done in Visual Studio Code in PowerShell environment.
/// The hybrid design allows for both environments to be completely usable.
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
#region
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is for launching Harden-Windows-Security module in VS Code so that it can attach its debugger to the process

$script:ErrorActionPreference = 'Stop'

# Get the current folder of this script file
[System.String]$ScriptFilePath = ($MyInvocation.MyCommand.path | Split-Path -Parent)

Expand Down
2 changes: 1 addition & 1 deletion Harden-Windows-Security Module/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.6
0.5.7

0 comments on commit 8878a63

Please sign in to comment.