diff --git a/source/tests/Test-ReportSecurityInTeams.ps1 b/source/tests/Test-ReportSecurityInTeams.ps1 index f7ac954..479847b 100644 --- a/source/tests/Test-ReportSecurityInTeams.ps1 +++ b/source/tests/Test-ReportSecurityInTeams.ps1 @@ -1,21 +1,20 @@ function Test-ReportSecurityInTeams { [CmdletBinding()] param ( + # Aligned # Parameters can be defined here if needed ) begin { - # Dot source the class script - - $auditResults = @() + # Dot source the class script if necessary + #. .\source\Classes\CISAuditResult.ps1 + # Initialization code, if needed } process { # 8.6.1 (L1) Ensure users can report security concerns in Teams - # Connect to Teams PowerShell using Connect-MicrosoftTeams - # Connect to Exchange Online PowerShell using Connect-ExchangeOnline - + # Retrieve the necessary settings for Teams and Exchange Online $CsTeamsMessagingPolicy = Get-CsTeamsMessagingPolicy -Identity Global | Select-Object -Property AllowSecurityEndUserReporting $ReportSubmissionPolicy = Get-ReportSubmissionPolicy | Select-Object -Property ReportJunkToCustomizedAddress, ReportNotJunkToCustomizedAddress, ReportPhishToCustomizedAddress, ReportChatMessageToCustomizedAddressEnabled @@ -25,32 +24,40 @@ function Test-ReportSecurityInTeams { $ReportSubmissionPolicy.ReportPhishToCustomizedAddress -and $ReportSubmissionPolicy.ReportChatMessageToCustomizedAddressEnabled - # Create an instance of CISAuditResult and populate it - $auditResult = [CISAuditResult]::new() - $auditResult.CISControlVer = "v8" - $auditResult.CISControl = "0.0" # Explicitly Not Mapped as per the image provided - $auditResult.CISDescription = "Explicitly Not Mapped" - $auditResult.Rec = "8.6.1" - $auditResult.ELevel = "E3" - $auditResult.ProfileLevel = "L1" - $auditResult.IG1 = $false # Set based on the CIS Controls image - $auditResult.IG2 = $false # Set based on the CIS Controls image - $auditResult.IG3 = $false # Set based on the CIS Controls image - $auditResult.RecDescription = "Ensure users can report security concerns in Teams" - $auditResult.Result = $securityReportEnabled - $auditResult.Details = "AllowSecurityEndUserReporting: $($CsTeamsMessagingPolicy.AllowSecurityEndUserReporting); " + + # Prepare failure reasons and details based on compliance + $failureReasons = if (-not $securityReportEnabled) { + "Users cannot report security concerns in Teams due to one or more incorrect settings" + } + else { + "N/A" + } + + $details = "AllowSecurityEndUserReporting: $($CsTeamsMessagingPolicy.AllowSecurityEndUserReporting); " + "ReportJunkToCustomizedAddress: $($ReportSubmissionPolicy.ReportJunkToCustomizedAddress); " + "ReportNotJunkToCustomizedAddress: $($ReportSubmissionPolicy.ReportNotJunkToCustomizedAddress); " + "ReportPhishToCustomizedAddress: $($ReportSubmissionPolicy.ReportPhishToCustomizedAddress); " + "ReportChatMessageToCustomizedAddressEnabled: $($ReportSubmissionPolicy.ReportChatMessageToCustomizedAddressEnabled)" - $auditResult.FailureReason = if (-not $securityReportEnabled) { "Users cannot report security concerns in Teams due to one or more incorrect settings" } else { "N/A" } - $auditResult.Status = if ($securityReportEnabled) { "Pass" } else { "Fail" } - $auditResults += $auditResult + # Create and populate the CISAuditResult object + $auditResult = [CISAuditResult]::new() + $auditResult.Status = if ($securityReportEnabled) { "Pass" } else { "Fail" } + $auditResult.ELevel = "E3" + $auditResult.ProfileLevel = "L1" + $auditResult.Rec = "8.6.1" + $auditResult.RecDescription = "Ensure users can report security concerns in Teams" + $auditResult.CISControlVer = "v8" + $auditResult.CISControl = "0.0" + $auditResult.CISDescription = "Explicitly Not Mapped" + $auditResult.IG1 = $false + $auditResult.IG2 = $false + $auditResult.IG3 = $false + $auditResult.Result = $securityReportEnabled + $auditResult.Details = $details + $auditResult.FailureReason = $failureReasons } end { - # Return auditResults - return $auditResults + # Return auditResult + return $auditResult } }