mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix NSEC record conversion
NSEC record needs special treatment as it is not composed from a fixed set of DNS parts divided by space, but it contains a multivalued DNS part "types" containing a list of RR types it covers. There was already a special method for parsing raw NSEC record to DNS parts, but the other direction was missing. This patch adds special NSEC convertor to fix this issue. https://fedorahosted.org/freeipa/ticket/2307
This commit is contained in:
@@ -292,6 +292,11 @@ class DNSRecord(Str):
|
||||
return None
|
||||
return tuple(values)
|
||||
|
||||
def _part_values_to_string(self, values, index):
|
||||
self._validate_parts(values)
|
||||
return u" ".join(super(DNSRecord, self)._convert_scalar(v, index) \
|
||||
for v in values if v is not None)
|
||||
|
||||
def get_parts_from_kw(self, kw, raise_on_none=True):
|
||||
part_names = tuple(self.part_name_format % (self.rrtype.lower(), part.name) \
|
||||
for part in self.parts)
|
||||
@@ -316,10 +321,7 @@ class DNSRecord(Str):
|
||||
|
||||
def _convert_scalar(self, value, index=None):
|
||||
if isinstance(value, (tuple, list)):
|
||||
# convert parsed values to the string
|
||||
self._validate_parts(value)
|
||||
return u" ".join(super(DNSRecord, self)._convert_scalar(v, index) \
|
||||
for v in value if v is not None)
|
||||
return self._part_values_to_string(value, index)
|
||||
return super(DNSRecord, self)._convert_scalar(value, index)
|
||||
|
||||
def normalize(self, value):
|
||||
@@ -795,10 +797,10 @@ class NSECRecord(DNSRecord):
|
||||
_domain_name_validator,
|
||||
label=_('Next Domain Name'),
|
||||
),
|
||||
StrEnum('types',
|
||||
StrEnum('types+',
|
||||
label=_('Type Map'),
|
||||
multivalue=True,
|
||||
values=_allowed_types,
|
||||
csv=True,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -810,6 +812,16 @@ class NSECRecord(DNSRecord):
|
||||
|
||||
return (values[0], tuple(values[1:]))
|
||||
|
||||
def _part_values_to_string(self, values, index):
|
||||
self._validate_parts(values)
|
||||
values_flat = [values[0],] # add "next" part
|
||||
types = values[1]
|
||||
if not isinstance(types, (list, tuple)):
|
||||
types = [types,]
|
||||
values_flat.extend(types)
|
||||
return u" ".join(Str._convert_scalar(self, v, index) \
|
||||
for v in values_flat if v is not None)
|
||||
|
||||
class NSEC3Record(DNSRecord):
|
||||
rrtype = 'NSEC3'
|
||||
rfc = 5155
|
||||
|
||||
Reference in New Issue
Block a user