Skip to content

Add support for Microsoft Exo Hybrid domain in DKIM#1464

Open
brianreidc7 wants to merge 1 commit intomaester365:mainfrom
brianreidc7:patch-8
Open

Add support for Microsoft Exo Hybrid domain in DKIM#1464
brianreidc7 wants to merge 1 commit intomaester365:mainfrom
brianreidc7:patch-8

Conversation

@brianreidc7
Copy link
Contributor

Description

This test errors when it encounters the tenantname.mail.onmicrosoft.com domain. Added a elseif to deal with this case. This domain name occurs whenever Exchange Online Hybrid Mode has been implemented.

Contribution Checklist

Before submitting this PR, please confirm you have completed the following:

  • 📖 Read the guidelines for contributing to this repository.
  • 🧪 Ensure the build and unit tests pass by running /powershell/tests/pester.ps1 on your local system.

 

Join us at the Maester repository discussions 💬 or Entra Discord 🧑‍💻 for more help and conversations!

This test errors when it encounters the tenantname.mail.onmicrosoft.com domain. Added a elseif to deal with this case.
@brianreidc7 brianreidc7 requested a review from a team as a code owner February 25, 2026 10:43
@SamErde SamErde requested a review from Copilot February 25, 2026 14:19
@SamErde SamErde added the exchange Microsoft Exchanage label Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the CIS DKIM check to handle Exchange Online hybrid coexistence domains (*.mail.onmicrosoft.com) without erroring, aligning the DKIM DNS lookup logic with how these domains behave in hybrid deployments.

Changes:

  • Add detection for *.mail.onmicrosoft.com accepted domains.
  • Adjust DKIM DNS name selection so hybrid domains don’t use the .onmicrosoft.com CNAME-based path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +58 to 62
$isMicrosoftExoHybridDomain = $domain.DomainName.EndsWith(".mail.onmicrosoft.com")
$dkimDnsName = if ($isMicrosoftExoHybridDomain) {
"$($Selector)._domainkey.$($domain.DomainName)"
} elseif ($isMicrosoftDomain) {
$dkimSigningConfig."$($selector)CNAME"
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if ($isMicrosoftExoHybridDomain) branch produces the same DKIM DNS name as the final else branch, so this conditional can be simplified (e.g., treat only “.onmicrosoft.com” excluding “.mail.onmicrosoft.com” as the special CNAME case). This will make the intent clearer and reduce duplicated logic.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order is intentional. If the other way around then onmicrosoft.com is checked first and that matches mail onmicrosoft.com as well.

Comment on lines +58 to +60
$isMicrosoftExoHybridDomain = $domain.DomainName.EndsWith(".mail.onmicrosoft.com")
$dkimDnsName = if ($isMicrosoftExoHybridDomain) {
"$($Selector)._domainkey.$($domain.DomainName)"
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR title/description suggests adding support for ExO hybrid “*.mail.onmicrosoft.com” handling in DKIM checks; note that Test-MtCisaDkim has the same onmicrosoft CNAME logic but was not updated, so CISA DKIM checks may still hit the same hybrid-domain scenario. If the intent is repo-wide DKIM support, consider applying the same handling there too.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does but the code I have on my machine hasn't been updated for years for this module and the code in github.com looks different than what I see deployed. The deployed code has no section for onmicrosoft.com handling - or maybe I'm looking in the wrong place (I'm no developer and all this git stuff is confusing) so I tried to find the other module and update it but it looks nothing like the copy on my PC. So I left that one well alone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. It sounds like you may be working on an outdated fork. I'll review and help get it synced with the upstream main branch.

@SamErde
Copy link
Contributor

SamErde commented Feb 25, 2026

@brianreidc7, can you please review the two comments above from the GitHub Copilot review. They look relevant to me. I'll perform a final review myself on Friday if this is ready!

@brianreidc7
Copy link
Contributor Author

This cisa one also throws an error for the same reason I fixed the cis one, but the cisa code doesn't have any onmicrosoft.com handling in it or I was looking at the wrong file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exchange Microsoft Exchanage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants