fix: 6.2.2 aligned with test-template
This commit is contained in:
@@ -1,47 +1,58 @@
|
|||||||
function Test-NoWhitelistDomains {
|
function Test-NoWhitelistDomains {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
|
# Aligned
|
||||||
# Define your parameters here
|
# Define your parameters here
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
# Initialization code
|
# Dot source the class script if necessary
|
||||||
|
#. .\source\Classes\CISAuditResult.ps1
|
||||||
$auditResult = [CISAuditResult]::new()
|
# Initialization code, if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
# 6.2.2 (L1) Ensure mail transport rules do not whitelist specific domains
|
# 6.2.2 (L1) Ensure mail transport rules do not whitelist specific domains
|
||||||
$whitelistedRules = Get-TransportRule | Where-Object { $_.SetSCL -eq -1 -and $_.SenderDomainIs -ne $null }
|
|
||||||
|
|
||||||
$auditResult.CISControl = "0.0"
|
# Retrieve transport rules that whitelist specific domains
|
||||||
$auditResult.CISControlVer = "v8"
|
$whitelistedRules = Get-TransportRule | Where-Object { $_.SetSCL -eq -1 -and $null -ne $_.SenderDomainIs }
|
||||||
$auditResult.CISDescription = "Explicitly Not Mapped"
|
|
||||||
|
|
||||||
$auditResult.Rec = "6.2.2"
|
# Prepare failure reasons and details based on compliance
|
||||||
|
$failureReasons = if ($whitelistedRules) {
|
||||||
|
"There are transport rules whitelisting specific domains."
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
"N/A"
|
||||||
|
}
|
||||||
|
|
||||||
|
$details = if ($whitelistedRules) {
|
||||||
|
$ruleDetails = $whitelistedRules | ForEach-Object { "{0}: {1}" -f $_.Name, ($_.SenderDomainIs -join ', ') }
|
||||||
|
"Whitelisted Rules: $($ruleDetails -join '; ')"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
"No transport rules whitelisting specific domains found."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create and populate the CISAuditResult object
|
||||||
|
$auditResult = [CISAuditResult]::new()
|
||||||
|
$auditResult.Status = if ($whitelistedRules) { "Fail" } else { "Pass" }
|
||||||
$auditResult.ELevel = "E3"
|
$auditResult.ELevel = "E3"
|
||||||
$auditResult.ProfileLevel = "L1"
|
$auditResult.ProfileLevel = "L1"
|
||||||
|
$auditResult.Rec = "6.2.2"
|
||||||
|
$auditResult.RecDescription = "Ensure mail transport rules do not whitelist specific domains"
|
||||||
|
$auditResult.CISControlVer = "v8"
|
||||||
|
$auditResult.CISControl = "0.0"
|
||||||
|
$auditResult.CISDescription = "Explicitly Not Mapped"
|
||||||
$auditResult.IG1 = $false
|
$auditResult.IG1 = $false
|
||||||
$auditResult.IG2 = $false
|
$auditResult.IG2 = $false
|
||||||
$auditResult.IG3 = $false
|
$auditResult.IG3 = $false
|
||||||
$auditResult.RecDescription = "Ensure mail transport rules do not whitelist specific domains"
|
$auditResult.Result = -not $whitelistedRules
|
||||||
|
$auditResult.Details = $details
|
||||||
if ($whitelistedRules) {
|
$auditResult.FailureReason = $failureReasons
|
||||||
$ruleDetails = $whitelistedRules | ForEach-Object { "{0}: {1}" -f $_.Name, ($_.SenderDomainIs -join ', ') }
|
|
||||||
$auditResult.Result = $false
|
|
||||||
$auditResult.Details = "Whitelisted Rules: $($ruleDetails -join '; ')"
|
|
||||||
$auditResult.FailureReason = "There are transport rules whitelisting specific domains."
|
|
||||||
$auditResult.Status = "Fail"
|
|
||||||
} else {
|
|
||||||
$auditResult.Result = $true
|
|
||||||
$auditResult.Details = "No transport rules whitelisting specific domains found."
|
|
||||||
$auditResult.FailureReason = "N/A"
|
|
||||||
$auditResult.Status = "Pass"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
# Return auditResult
|
# Return auditResult
|
||||||
return $auditResult
|
return $auditResult
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user