From 59478e9c7c92b0c33b957987b7d1ce545d1fd156 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Thu, 29 Jun 2023 10:12:52 -0700 Subject: [PATCH 1/2] Correctly handle trailing . in TinyDNS source fqdns --- octodns/source/tinydns.py | 11 +++++++---- tests/zones/tinydns/example.com | 12 ++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/octodns/source/tinydns.py b/octodns/source/tinydns.py index 9a8bffb..4d32e52 100755 --- a/octodns/source/tinydns.py +++ b/octodns/source/tinydns.py @@ -133,7 +133,7 @@ class TinyDnsBaseSource(BaseSource): '3': 'AAAA', '6': 'AAAA', } - name_re = re.compile(fr'((?P.+)\.)?{zone.name[:-1]}$') + name_re = re.compile(fr'((?P.+)\.)?{zone.name[:-1]}\.?$') data = defaultdict(lambda: defaultdict(list)) for line in self._lines(): @@ -172,7 +172,7 @@ class TinyDnsBaseSource(BaseSource): ) def _populate_in_addr_arpa(self, zone, lenient): - name_re = re.compile(fr'(?P.+)\.{zone.name[:-1]}$') + name_re = re.compile(fr'(?P.+)\.{zone.name[:-1]}\.?$') for line in self._lines(): _type = line[0] @@ -188,11 +188,11 @@ class TinyDnsBaseSource(BaseSource): if line[0].endswith('in-addr.arpa'): # since it's already in in-addr.arpa format match = name_re.match(line[0]) - value = f'{line[1]}.' + value = line[1] else: addr = ip_address(line[1]) match = name_re.match(addr.reverse_pointer) - value = f'{line[0]}.' + value = line[0] if match: try: @@ -200,6 +200,9 @@ class TinyDnsBaseSource(BaseSource): except IndexError: ttl = self.default_ttl + if value[-1] != '.': + value = f'{value}.' + name = match.group('name') record = Record.new( zone, diff --git a/tests/zones/tinydns/example.com b/tests/zones/tinydns/example.com index ae8b5bd..a1f983f 100755 --- a/tests/zones/tinydns/example.com +++ b/tests/zones/tinydns/example.com @@ -4,12 +4,12 @@ # Multi-value A +example.com:10.2.3.4:30 -+example.com:10.2.3.5:30 ++example.com.:10.2.3.5:30 Ccname.other.foo:www.other.foo # A+PTR -=some-host-abc123.example.com:10.2.3.7:1800 +=some-host-abc123.example.com.:10.2.3.7:1800 # A+PTR with duplicate address, fine for A's, but warning on PTRs =has-dup-def123.example.com:10.2.3.8 =has-dup-def456.example.com:10.2.3.8 @@ -26,21 +26,21 @@ Ccname.other.foo:www.other.foo # MX @example.com::smtp-1-host.example.com:10 -@example.com::smtp-2-host.example.com:20 +@example.com.::smtp-2-host.example.com:20 # MX with ttl @smtp.example.com::smtp-1-host.example.com:30:1800 -@smtp.example.com::smtp-2-host.example.com:40:1800 +@smtp.example.com.::smtp-2-host.example.com:40:1800 # NS .sub.example.com::ns3.ns.com:30 -.sub.example.com::ns4.ns.com:30 +.sub.example.com.::ns4.ns.com:30 # A, under sub +www.sub.example.com::1.2.3.4 # Top-level NS .example.com::ns1.ns.com -.example.com::ns2.ns.com +.example.com.::ns2.ns.com # sub special cases +a1.blah-asdf.subtest.com:10.2.3.5 From 33f464a17dde560fa46f3565ee09a2e38c160687 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Thu, 29 Jun 2023 10:16:00 -0700 Subject: [PATCH 2/2] Changelog entry for tinydns . fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9bbf10..4a59c14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ownership to be marked in the same zone for delegation NS records. * octodns-report access --lenient flag to allow running reports with records sourced from providers with non-compliant record data. +* Correctly handle FQDNs in TinyDNS config files that end with trailing .'s ## v1.0.0.rc0 - 2023-05-16 - First of the ones