fix: 2.1.5 simplified output and added object comment
This commit is contained in:
@@ -288,6 +288,17 @@ function Get-CISExoOutput {
|
|||||||
# Retrieve the ATP policies for Office 365 and check Safe Attachments settings
|
# Retrieve the ATP policies for Office 365 and check Safe Attachments settings
|
||||||
$atpPolicies = Get-AtpPolicyForO365
|
$atpPolicies = Get-AtpPolicyForO365
|
||||||
# Check if the required ATP policies are enabled
|
# Check if the required ATP policies are enabled
|
||||||
|
# $atpPolicyResult Mock Object:
|
||||||
|
<#
|
||||||
|
$atpPolicyResult = @(
|
||||||
|
[PSCustomObject]@{
|
||||||
|
Name = "Default"
|
||||||
|
EnableATPForSPOTeamsODB = $true
|
||||||
|
EnableSafeDocs = $true
|
||||||
|
AllowSafeDocsOpen = $false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
#>
|
||||||
$atpPolicyResult = $atpPolicies | Where-Object {
|
$atpPolicyResult = $atpPolicies | Where-Object {
|
||||||
$_.EnableATPForSPOTeamsODB -eq $true -and
|
$_.EnableATPForSPOTeamsODB -eq $true -and
|
||||||
$_.EnableSafeDocs -eq $true -and
|
$_.EnableSafeDocs -eq $true -and
|
||||||
|
@@ -5,7 +5,6 @@ function Test-SafeAttachmentsTeams {
|
|||||||
# Aligned
|
# Aligned
|
||||||
# Parameters can be added if needed
|
# Parameters can be added if needed
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
# Dot source the class script if necessary
|
# Dot source the class script if necessary
|
||||||
#. .\source\Classes\CISAuditResult.ps1
|
#. .\source\Classes\CISAuditResult.ps1
|
||||||
@@ -28,32 +27,58 @@ function Test-SafeAttachmentsTeams {
|
|||||||
|
|
||||||
# Initialization code, if needed
|
# Initialization code, if needed
|
||||||
$recnum = "2.1.5"
|
$recnum = "2.1.5"
|
||||||
|
Write-Verbose "Running Test-SafeAttachmentsTeams for $recnum..."
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
# $atpPolicyResult Mock Object
|
||||||
|
<#
|
||||||
|
$atpPolicyResult = @(
|
||||||
|
[PSCustomObject]@{
|
||||||
|
Name = "Default"
|
||||||
|
EnableATPForSPOTeamsODB = $true
|
||||||
|
EnableSafeDocs = $true
|
||||||
|
AllowSafeDocsOpen = $false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
#>
|
||||||
$atpPolicyResult = Get-CISExoOutput -Rec $recnum
|
$atpPolicyResult = Get-CISExoOutput -Rec $recnum
|
||||||
if ($atpPolicyResult -ne 1) {
|
if ($atpPolicyResult -ne 1) {
|
||||||
try {
|
try {
|
||||||
# Condition A: Check Safe Attachments for SharePoint
|
# Condition A: Check Safe Attachments for SharePoint
|
||||||
# Condition B: Check Safe Attachments for OneDrive
|
# Condition B: Check Safe Attachments for OneDrive
|
||||||
# Condition C: Check Safe Attachments for Microsoft Teams
|
# Condition C: Check Safe Attachments for Microsoft Teams
|
||||||
|
|
||||||
# Determine the result based on the ATP policy settings
|
# Determine the result based on the ATP policy settings
|
||||||
$result = $null -ne $atpPolicyResult
|
$result = $null -ne $atpPolicyResult
|
||||||
|
$atpPolicyResult | Where-Object { $_.Identity -eq "Default" }
|
||||||
|
if ($result) {
|
||||||
|
$detailpass = [PSCustomObject]@{
|
||||||
|
Name = $atpPolicyResult.Name
|
||||||
|
EnableATPForSPOTeamsODB = $atpPolicyResult.EnableATPForSPOTeamsODB
|
||||||
|
EnableSafeDocs = $atpPolicyResult.EnableSafeDocs
|
||||||
|
AllowSafeDocsOpen = $atpPolicyResult.AllowSafeDocsOpen
|
||||||
|
}
|
||||||
|
$detailsString = $detailpass | ForEach-Object {
|
||||||
|
@"
|
||||||
|
Name: $($_.Name)
|
||||||
|
EnableATPForSPOTeamsODB: $($_.EnableATPForSPOTeamsODB)
|
||||||
|
EnableSafeDocs: $($_.EnableSafeDocs)
|
||||||
|
AllowSafeDocsOpen: $($_.AllowSafeDocsOpen)
|
||||||
|
`n
|
||||||
|
"@
|
||||||
|
}
|
||||||
|
}
|
||||||
$details = if ($result) {
|
$details = if ($result) {
|
||||||
"ATP for SharePoint, OneDrive, and Teams is enabled with correct settings."
|
$detailsString
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
"ATP for SharePoint, OneDrive, and Teams is not enabled with correct settings."
|
"ATP for SharePoint, OneDrive, and Teams is not enabled with correct settings."
|
||||||
}
|
}
|
||||||
|
|
||||||
$failureReasons = if ($result) {
|
$failureReasons = if ($result) {
|
||||||
"N/A"
|
"N/A"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
"ATP policy for SharePoint, OneDrive, and Microsoft Teams is not correctly configured."
|
"ATP policy for SharePoint, OneDrive, and Microsoft Teams is not correctly configured."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create and populate the CISAuditResult object
|
# Create and populate the CISAuditResult object
|
||||||
$params = @{
|
$params = @{
|
||||||
Rec = $recnum
|
Rec = $recnum
|
||||||
@@ -66,13 +91,10 @@ function Test-SafeAttachmentsTeams {
|
|||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Error "An error occurred during the test: $_"
|
Write-Error "An error occurred during the test: $_"
|
||||||
|
|
||||||
# Retrieve the description from the test definitions
|
# Retrieve the description from the test definitions
|
||||||
$testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum }
|
$testDefinition = $script:TestDefinitionsObject | Where-Object { $_.Rec -eq $recnum }
|
||||||
$description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" }
|
$description = if ($testDefinition) { $testDefinition.RecDescription } else { "Description not found" }
|
||||||
|
|
||||||
$script:FailedTests.Add([PSCustomObject]@{ Rec = $recnum; Description = $description; Error = $_ })
|
$script:FailedTests.Add([PSCustomObject]@{ Rec = $recnum; Description = $description; Error = $_ })
|
||||||
|
|
||||||
# Call Initialize-CISAuditResult with error parameters
|
# Call Initialize-CISAuditResult with error parameters
|
||||||
$auditResult = Initialize-CISAuditResult -Rec $recnum -Failure
|
$auditResult = Initialize-CISAuditResult -Rec $recnum -Failure
|
||||||
}
|
}
|
||||||
@@ -88,7 +110,6 @@ function Test-SafeAttachmentsTeams {
|
|||||||
$auditResult = Initialize-CISAuditResult @params
|
$auditResult = Initialize-CISAuditResult @params
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
# Return the audit result
|
# Return the audit result
|
||||||
return $auditResult
|
return $auditResult
|
||||||
|
Reference in New Issue
Block a user