diff --git a/source/tests/Test-NotifyMalwareInternal.ps1 b/source/tests/Test-NotifyMalwareInternal.ps1 index 90e7f74..d198668 100644 --- a/source/tests/Test-NotifyMalwareInternal.ps1 +++ b/source/tests/Test-NotifyMalwareInternal.ps1 @@ -1,12 +1,14 @@ function Test-NotifyMalwareInternal { [CmdletBinding()] param ( + # Aligned # Parameters can be added if needed ) begin { - - $auditResults = @() + # Dot source the class script if necessary + #. .\source\Classes\CISAuditResult.ps1 + # Initialization code, if needed } process { @@ -24,10 +26,23 @@ function Test-NotifyMalwareInternal { # Determine the result based on the presence of custom policies without notifications $result = $policiesToReport.Count -eq 0 - $details = if ($result) { "All custom malware policies have notifications enabled." } else { "Misconfigured Policies: $($policiesToReport -join ', ')" } - $failureReason = if ($result) { "N/A" } else { "Some custom policies do not have notifications for internal users sending malware enabled." } - # Create an instance of CISAuditResult and populate it + # Prepare failure reasons and details based on compliance + $failureReasons = if ($result) { + "N/A" + } + else { + "Some custom policies do not have notifications for internal users sending malware enabled." + } + + $details = if ($result) { + "All custom malware policies have notifications enabled." + } + else { + "Misconfigured Policies: $($policiesToReport -join ', ')" + } + + # Create and populate the CISAuditResult object $auditResult = [CISAuditResult]::new() $auditResult.Status = if ($result) { "Pass" } else { "Fail" } $auditResult.ELevel = "E3" @@ -42,13 +57,11 @@ function Test-NotifyMalwareInternal { $auditResult.IG3 = $true $auditResult.Result = $result $auditResult.Details = $details - $auditResult.FailureReason = $failureReason - - $auditResults += $auditResult + $auditResult.FailureReason = $failureReasons } end { - # Return auditResults - return $auditResults + # Return the audit result + return $auditResult } -} +} \ No newline at end of file