Skip to content

feat(email): generate DMARC recommendation, fix DNS TXT-record verification precision - #304

Open
clau1902 wants to merge 1 commit into
gotempsh:mainfrom
clau1902:fix/email-dmarc-and-dns-verification
Open

feat(email): generate DMARC recommendation, fix DNS TXT-record verification precision#304
clau1902 wants to merge 1 commit into
gotempsh:mainfrom
clau1902:fix/email-dmarc-and-dns-verification

Conversation

@clau1902

Copy link
Copy Markdown
Contributor

Summary

Independent of the other email-hardening PRs in this series — touches only dns.rs, domain_service.rs, and setup_dns in domains.rs.

  • Adds a DMARC record (_dmarc.<domain>, v=DMARC1; p=quarantine; pct=100) to the domain's DNS records list for display. Informational only: deliberately excluded from setup_dns's auto-create (publishing a DMARC policy isn't additive like SPF/DKIM/MX — it sets a policy for the entire domain and can affect mail from senders other than Temps, e.g. the company's regular Google Workspace/M365 mail, if their SPF/DKIM alignment isn't already clean) and from the domain verification status computation (so no already-verified domain regresses to pending/failed just because it doesn't have a DMARC record — DMARC is recommended, not required).
  • Fixes a false-positive bug in TXT record verification: the check accepted a match if expected_value.contains(&txt_data) as well as the correct txt_data.contains(expected_value) direction. That backward check is a trap — any short, unrelated TXT record (e.g. a single stray character) is trivially a substring of a long expected DKIM key, so a domain could be reported "Verified" with a DNS record that has nothing to do with the expected value.

Test plan

  • cargo test -p temps-email --lib — 157 tests pass, including updated test_build_dns_records (now asserts the DMARC record is present alongside SPF/DKIM/MX)

🤖 Generated with Claude Code

…cation precision

- Adds a DMARC record (_dmarc.<domain>, "v=DMARC1; p=quarantine; pct=100")
  to the domain's DNS records list for display. Informational only:
  deliberately excluded from setup_dns's auto-create (publishing a DMARC
  policy isn't additive like SPF/DKIM/MX — it can affect mail from other
  senders on the domain) and from the domain verification status computation
  (so no already-verified domain regresses to pending/failed just because
  it doesn't have a DMARC record).
- Fixes a false-positive bug in TXT record verification: the check accepted
  a match if `expected_value.contains(&txt_data)` as well as the correct
  direction, which meant any short, unrelated TXT record (e.g. a single
  stray character) was trivially a substring of a long expected DKIM key —
  a domain could be reported "Verified" with a DNS record that had nothing
  to do with the expected value.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant