Browse Source

Record validation for double dots ..

pull/1203/head
Ross McFarland 1 year ago
parent
commit
40b30e5124
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
3 changed files with 30 additions and 0 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +3
    -0
      octodns/record/base.py
  3. +26
    -0
      tests/test_octodns_record.py

+ 1
- 0
CHANGELOG.md View File

@ -1,5 +1,6 @@
## v1.?.? - 2024-??-?? - ???
* Record validation checks for double dots in names
* MetaProcessor.include_extra to add support for arbitrary extra values to be
set on the meta record.
* Correctly handled quoted svcparams when parsing SVCB/HTTPS rdata text


+ 3
- 0
octodns/record/base.py View File

@ -102,6 +102,9 @@ class Record(EqualityTupleMixin):
f'invalid label, "{label}" is too long at {n}'
' chars, max is 63'
)
# in the case of endswith there's an implicit second . from the Zone
if '..' in name or name.endswith('.'):
reasons.append(f'invalid name, double `.` in "{idna_decode(fqdn)}"')
# TODO: look at the idna lib for a lot more potential validations...
try:
ttl = int(data['ttl'])


+ 26
- 0
tests/test_octodns_record.py View File

@ -666,6 +666,32 @@ class TestRecordValidation(TestCase):
# does)
self.assertEqual('Label too long', reason)
# double dots are not valid, ends with
with self.assertRaises(ValidationError) as ctx:
Record.new(
self.zone,
'this.ends.with.a.dot.',
{'ttl': 301, 'type': 'A', 'value': '1.2.3.4'},
)
reason = ctx.exception.reasons[0]
self.assertEqual(
'invalid name, double `.` in "this.ends.with.a.dot..unit.tests."',
reason,
)
# double dots are not valid when eplxicit
with self.assertRaises(ValidationError) as ctx:
Record.new(
self.zone,
'this.has.double..dots',
{'ttl': 301, 'type': 'A', 'value': '1.2.3.4'},
)
reason = ctx.exception.reasons[0]
self.assertEqual(
'invalid name, double `.` in "this.has.double..dots.unit.tests."',
reason,
)
# no ttl
with self.assertRaises(ValidationError) as ctx:
Record.new(self.zone, '', {'type': 'A', 'value': '1.2.3.4'})


Loading…
Cancel
Save