Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions powershell/public/cis/Test-MtCisDkim.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@
$_.domain -eq $domain.domainname
}

if (-not $dkimSigningConfig) {
$dkimRecord = [PSCustomObject]@{
domain = $domain.DomainName
pass = if ($domain.SendingFromDomainDisabled) { 'Skipped' } elseif ($domain.InitialDomain -eq $true) { 'Passed' } else { 'Failed' }
reason = if ($domain.SendingFromDomainDisabled) { 'Parked domain' } elseif ($domain.InitialDomain -eq $true) { 'Microsoft auto-signs DKIM for the initial onmicrosoft.com domain' } else { 'No DkimSigningConfig found for domain' }
dkimRecord = $null
}
$dkimRecords += $dkimRecord
continue
}

if ((Get-Date) -gt $dkimSigningConfig.RotateOnDate) {
if ($Selector -ne $dkimSigningConfig.SelectorAfterRotateOnDate) {
Write-Verbose "Using DKIM $($dkimSigningConfig.SelectorAfterRotateOnDate) based on EXO config"
Expand Down
11 changes: 11 additions & 0 deletions powershell/public/cisa/exchange/Test-MtCisaDkim.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
$dkimSigningConfig = $dkimSigningConfigs | Where-Object {`
$_.domain -eq $domain.domainname
}

if (-not $dkimSigningConfig) {
$dkimRecord = [PSCustomObject]@{
domain = $domain.DomainName
pass = if ($domain.SendingFromDomainDisabled) { 'Skipped' } elseif ($domain.InitialDomain -eq $true) { 'Passed' } else { 'Failed' }
reason = if ($domain.SendingFromDomainDisabled) { 'Parked domain' } elseif ($domain.InitialDomain -eq $true) { 'Microsoft auto-signs DKIM for the initial onmicrosoft.com domain' } else { 'No DkimSigningConfig found for domain' }
dkimRecord = $null
}
$dkimRecords += $dkimRecord
continue
}
if ((Get-Date) -gt $dkimSigningConfig.RotateOnDate) {
if ($Selector -ne $dkimSigningConfig.SelectorAfterRotateOnDate) {
Write-Verbose "Using DKIM $($dkimSigningConfig.SelectorAfterRotateOnDate) based on EXO config"
Expand Down
88 changes: 88 additions & 0 deletions powershell/tests/functions/Test-MtDkim.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
BeforeAll {
Import-Module "$PSScriptRoot/../../Maester.psd1" -Force
}

Describe 'DKIM checks with no signing configuration' -ForEach @(
@{ CommandName = 'Test-MtCisDkim' }
@{ CommandName = 'Test-MtCisaDkim' }
) {
BeforeEach {
Mock -ModuleName Maester Test-MtConnection { return $true }
Mock -ModuleName Maester Add-MtTestResultDetail { }
Mock -ModuleName Maester Get-MailAuthenticationRecord {
throw 'DNS lookup should not be attempted without a DKIM signing configuration'
}
}

It '<CommandName> returns <ExpectedOutcome> for <DomainName>' -ForEach @(
@{
DomainName = 'contoso.onmicrosoft.com'
InitialDomain = $true
IsCoexistenceDomain = $false
SendingFromDomainDisabled = $false
ExpectedOutcome = 'passed'
ExpectedResult = $true
}
@{
DomainName = 'secondary.onmicrosoft.com'
InitialDomain = $false
IsCoexistenceDomain = $false
SendingFromDomainDisabled = $false
ExpectedOutcome = 'failed'
ExpectedResult = $false
}
@{
DomainName = 'parked.example'
InitialDomain = $false
IsCoexistenceDomain = $false
SendingFromDomainDisabled = $true
ExpectedOutcome = 'skipped'
ExpectedResult = $null
}
@{
DomainName = 'contoso.mail.onmicrosoft.com'
InitialDomain = $false
IsCoexistenceDomain = $true
SendingFromDomainDisabled = $false
ExpectedOutcome = 'failed'
ExpectedResult = $false
}
@{
DomainName = 'contoso.mail.onmicrosoft.com'
InitialDomain = $false
IsCoexistenceDomain = $true
SendingFromDomainDisabled = $true
ExpectedOutcome = 'skipped'
ExpectedResult = $null
}
@{
DomainName = 'contoso.com'
InitialDomain = $false
IsCoexistenceDomain = $false
SendingFromDomainDisabled = $false
ExpectedOutcome = 'failed'
ExpectedResult = $false
}
) {
Mock -ModuleName Maester Get-MtExo {
if ($Request -eq 'AcceptedDomain') {
return [PSCustomObject]@{
DomainName = $DomainName
InitialDomain = $InitialDomain
IsCoexistenceDomain = $IsCoexistenceDomain
SendingFromDomainDisabled = $SendingFromDomainDisabled
}
}

return @()
}

$result = & $CommandName
if ($null -eq $ExpectedResult) {
$result | Should -BeNullOrEmpty
} else {
$result | Should -Be $ExpectedResult
}
Should -Invoke Get-MailAuthenticationRecord -ModuleName Maester -Exactly 0
}
}
6 changes: 6 additions & 0 deletions website/contributors/contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ alexandair:
name: Aleksandar Nikolić
title: Microsoft MVP

amlhive-tech:
name: Haris Habib
company: AMLHIVE
emails:
- tech@amlhive.com.au

amandaw33:

andremieth:
Expand Down