fix: 2.1.2 aligned with test-template
This commit is contained in:
@@ -1,27 +1,41 @@
|
|||||||
function Test-CommonAttachmentFilter {
|
function Test-CommonAttachmentFilter {
|
||||||
[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 = @()
|
# Initialization code, if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
# 2.1.2 (L1) Ensure the Common Attachment Types Filter is enabled
|
# 2.1.2 (L1) Ensure the Common Attachment Types Filter is enabled
|
||||||
# Pass if EnableFileFilter is set to True. Fail otherwise.
|
|
||||||
|
|
||||||
|
# Retrieve the attachment filter policy
|
||||||
$attachmentFilter = Get-MalwareFilterPolicy -Identity Default | Select-Object EnableFileFilter
|
$attachmentFilter = Get-MalwareFilterPolicy -Identity Default | Select-Object EnableFileFilter
|
||||||
$result = $attachmentFilter.EnableFileFilter
|
$result = $attachmentFilter.EnableFileFilter
|
||||||
$details = "File Filter Enabled: $($attachmentFilter.EnableFileFilter)"
|
|
||||||
$failureReason = if ($result) { "N/A" } else { "Common Attachment Types Filter is disabled" }
|
|
||||||
$status = if ($result) { "Pass" } else { "Fail" }
|
|
||||||
|
|
||||||
# Create an instance of CISAuditResult and populate it
|
# Prepare failure reasons and details based on compliance
|
||||||
|
$failureReasons = if (-not $result) {
|
||||||
|
"Common Attachment Types Filter is disabled"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
"N/A"
|
||||||
|
}
|
||||||
|
|
||||||
|
$details = if ($result) {
|
||||||
|
"File Filter Enabled: True"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
"File Filter Enabled: False"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create and populate the CISAuditResult object
|
||||||
$auditResult = [CISAuditResult]::new()
|
$auditResult = [CISAuditResult]::new()
|
||||||
$auditResult.Status = $status
|
$auditResult.Status = if ($result) { "Pass" } else { "Fail" }
|
||||||
$auditResult.ELevel = "E3"
|
$auditResult.ELevel = "E3"
|
||||||
$auditResult.ProfileLevel = "L1"
|
$auditResult.ProfileLevel = "L1"
|
||||||
$auditResult.Rec = "2.1.2"
|
$auditResult.Rec = "2.1.2"
|
||||||
@@ -34,13 +48,11 @@ function Test-CommonAttachmentFilter {
|
|||||||
$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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user