From 8769514f1c65f3c85bdfd934dea67270349677e2 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 28 Oct 2025 11:05:33 +0700 Subject: [PATCH] Don't deduce point on weak SPF all qualifier, when DMARC is configured --- pkg/analyzer/dns_spf.go | 16 ++++++++++++++-- web/src/lib/components/DnsRecordsCard.svelte | 2 +- web/src/lib/components/SpfRecordsDisplay.svelte | 17 ++++++++++++++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/pkg/analyzer/dns_spf.go b/pkg/analyzer/dns_spf.go index bc7a1be..4d8401a 100644 --- a/pkg/analyzer/dns_spf.go +++ b/pkg/analyzer/dns_spf.go @@ -242,6 +242,12 @@ func (d *DNSAnalyzer) calculateSPFScore(results *api.DNSResults) (score int) { // Full points for valid SPF score += 75 + // Check if DMARC is configured with strict policy as all mechanism is less significant + dmarcStrict := results.DmarcRecord != nil && + results.DmarcRecord.Valid && results.DmarcRecord.Policy != nil && + (*results.DmarcRecord.Policy == "quarantine" || + *results.DmarcRecord.Policy == "reject") + // Deduct points based on the all mechanism qualifier if mainSPF.AllQualifier != nil { switch *mainSPF.AllQualifier { @@ -249,10 +255,16 @@ func (d *DNSAnalyzer) calculateSPFScore(results *api.DNSResults) (score int) { // Strict fail - no deduction, this is the recommended policy score += 25 case "~": - // Softfail - moderate penalty + // Softfail - if DMARC is quarantine or reject, treat it mostly like strict fail + if dmarcStrict { + score += 20 + } + // Otherwise, moderate penalty (no points added or deducted) case "+", "?": // Pass/neutral - severe penalty - score -= 25 + if !dmarcStrict { + score -= 25 + } } } else { // No 'all' mechanism qualifier extracted - severe penalty diff --git a/web/src/lib/components/DnsRecordsCard.svelte b/web/src/lib/components/DnsRecordsCard.svelte index a871096..2b3c99c 100644 --- a/web/src/lib/components/DnsRecordsCard.svelte +++ b/web/src/lib/components/DnsRecordsCard.svelte @@ -111,7 +111,7 @@ {/if} - +
diff --git a/web/src/lib/components/SpfRecordsDisplay.svelte b/web/src/lib/components/SpfRecordsDisplay.svelte index 34aea8e..f9dd738 100644 --- a/web/src/lib/components/SpfRecordsDisplay.svelte +++ b/web/src/lib/components/SpfRecordsDisplay.svelte @@ -1,18 +1,27 @@ @@ -71,6 +80,8 @@
{#if spf.all_qualifier === '-'} All unauthorized servers will be rejected. This is the recommended strict policy. + {:else if dmarcStrict} + While your DMARC {dmarcRecord?.policy} policy provides some protection, consider using -all for better security with some old mailbox providers. {:else if spf.all_qualifier === '~'} Unauthorized servers will softfail. Consider using -all for stricter policy, though this rarely affects legitimate email deliverability. {:else if spf.all_qualifier === '+'}