Skip to content

Commit 469e440

Browse files
authored
Merge pull request #116 from cisagov/improvement/warning_for_sp_in_subdomain_record
Add a warning for the presence of sp in a subdomain's DMARC record
2 parents a26588a + 3c1e8f1 commit 469e440

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

trustymail/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import unicode_literals, absolute_import, print_function
22

3-
__version__ = '0.7.3'
3+
__version__ = '0.7.4'
44

55
PublicSuffixListFilename = 'public_suffix_list.dat'
66
PublicSuffixListReadOnly = False

trustymail/domain.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ def __init__(self, domain_name, timeout, smtp_timeout, smtp_localhost, smtp_port
6565

6666
self.base_domain_name = get_public_suffix(self.domain_name)
6767

68+
self.is_base_domain = True
69+
self.base_domain = None
6870
if self.base_domain_name != self.domain_name:
71+
self.is_base_domain = False
6972
if self.base_domain_name not in Domain.base_domains:
7073
# Populate DMARC for parent.
7174
domain = trustymail.scan(self.base_domain_name, timeout, smtp_timeout, smtp_localhost, smtp_ports, smtp_cache, {'mx': False, 'starttls': False, 'spf': False, 'dmarc': True}, dns_hostnames)
7275
Domain.base_domains[self.base_domain_name] = domain
7376
self.base_domain = Domain.base_domains[self.base_domain_name]
74-
else:
75-
self.base_domain = None
7677

7778
# Start off assuming the host is live unless an error tells us otherwise.
7879
self.is_live = True

trustymail/trustymail.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,11 @@ def dmarc_scan(resolver, domain):
493493
value = options.split('=')[1].strip()
494494
tag_dict[tag] = value
495495

496+
# Before we set sp=p if it is not explicitly contained in
497+
# the DMARC record, log a warning if it is explicitly set
498+
# for a subdomain of an organizational domain.
499+
if 'sp' in tag_dict and not domain.is_base_domain:
500+
handle_error('[DMARC]', domain, 'Warning: The sp tag will be ignored for DMARC records published on subdomains. See here for details: https://tools.ietf.org/html/rfc7489#section-6.3.', syntax_error=False)
496501
if 'p' not in tag_dict:
497502
msg = 'Record missing required policy (p) tag'
498503
handle_syntax_error('[DMARC]', domain, '{0}'.format(msg))
@@ -505,7 +510,7 @@ def dmarc_scan(resolver, domain):
505510
tag_dict['pct'] = 100
506511
if 'adkim' not in tag_dict:
507512
tag_dict['adkim'] = 'r'
508-
if 'aspf'not in tag_dict:
513+
if 'aspf' not in tag_dict:
509514
tag_dict['aspf'] = 'r'
510515
if 'fo' not in tag_dict:
511516
tag_dict['fo'] = '0'

0 commit comments

Comments
 (0)