fix: 2.1.4 aligned with test-template
This commit is contained in:
@@ -1,28 +1,39 @@
|
|||||||
function Test-SafeAttachmentsPolicy {
|
function Test-SafeAttachmentsPolicy {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
|
# Aligned
|
||||||
# Parameters can be added if needed
|
# Parameters can be added if needed
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
# Dot source the class script if necessary
|
||||||
$auditResults = @()
|
#. .\source\Classes\CISAuditResult.ps1
|
||||||
|
# Initialization code, if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
# 2.1.4 (L2) Ensure Safe Attachments policy is enabled
|
||||||
|
|
||||||
# Retrieve all Safe Attachment policies where Enable is set to True
|
# Retrieve all Safe Attachment policies where Enable is set to True
|
||||||
$safeAttachmentPolicies = Get-SafeAttachmentPolicy | Where-Object { $_.Enable -eq $true }
|
$safeAttachmentPolicies = Get-SafeAttachmentPolicy | Where-Object { $_.Enable -eq $true }
|
||||||
|
|
||||||
# If there are any enabled policies, the result is Pass. If not, it's Fail.
|
# Determine result and details based on the presence of enabled policies
|
||||||
$result = $safeAttachmentPolicies -ne $null -and $safeAttachmentPolicies.Count -gt 0
|
$result = $null -ne $safeAttachmentPolicies -and $safeAttachmentPolicies.Count -gt 0
|
||||||
$details = if ($result) {
|
$details = if ($result) {
|
||||||
"Enabled Safe Attachments Policies: $($safeAttachmentPolicies.Name -join ', ')"
|
"Enabled Safe Attachments Policies: $($safeAttachmentPolicies.Name -join ', ')"
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
"No Safe Attachments Policies are enabled."
|
"No Safe Attachments Policies are enabled."
|
||||||
}
|
}
|
||||||
$failureReason = if ($result) { "N/A" } else { "Safe Attachments policy is not enabled." }
|
|
||||||
|
|
||||||
# Create an instance of CISAuditResult and populate it
|
$failureReasons = if ($result) {
|
||||||
|
"N/A"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
"Safe Attachments policy is not enabled."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create and populate the CISAuditResult object
|
||||||
$auditResult = [CISAuditResult]::new()
|
$auditResult = [CISAuditResult]::new()
|
||||||
$auditResult.Status = if ($result) { "Pass" } else { "Fail" }
|
$auditResult.Status = if ($result) { "Pass" } else { "Fail" }
|
||||||
$auditResult.ELevel = "E5"
|
$auditResult.ELevel = "E5"
|
||||||
@@ -37,13 +48,13 @@ function Test-SafeAttachmentsPolicy {
|
|||||||
$auditResult.IG3 = $true
|
$auditResult.IG3 = $true
|
||||||
$auditResult.Result = $result
|
$auditResult.Result = $result
|
||||||
$auditResult.Details = $details
|
$auditResult.Details = $details
|
||||||
$auditResult.FailureReason = $failureReason
|
$auditResult.FailureReason = $failureReasons
|
||||||
|
|
||||||
$auditResults += $auditResult
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
# Return auditResults
|
# Return the audit result
|
||||||
return $auditResults
|
return $auditResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Additional helper functions (if any)
|
||||||
|
Reference in New Issue
Block a user