From 090d719f0d382397f98ae73f5416cc36b3fb57b9 Mon Sep 17 00:00:00 2001 From: Ettore Dreucci Date: Sat, 18 Oct 2025 19:20:34 +0200 Subject: [PATCH] Correctly handle RRSIG records, converting numeric type codes into their textual equivalents --- src/helpers.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/helpers.py b/src/helpers.py index 341c70f..78fc6f7 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -143,22 +143,21 @@ def export_all_zones(trigger_path: str = "filesystem-change") -> list[Path]: return written_files -def replace_type_codes(content): - pattern = re.compile(r'(RRSIG\s+)(\d+)(\s+)') - - def repl(match): - num = int(match.group(2)) - try: - text_type = dns.rdatatype.to_text(dns.rdatatype.RdataType(num)) - return f"{match.group(1)}{text_type}{match.group(3)}" - except Exception as e: - logging.warning(e) - return match.group(0) - - return pattern.sub(repl, content) - - def validate_zone(zone_name, content) -> bool: + def replace_type_codes(content): + pattern = re.compile(r'(RRSIG\s+)(\d+)(\s+)') + + def repl(match): + num = int(match.group(2)) + try: + text_type = dns.rdatatype.to_text(dns.rdatatype.RdataType(num)) + return f"{match.group(1)}{text_type}{match.group(3)}" + except Exception as e: + logging.warning(e) + return match.group(0) + + return pattern.sub(repl, content) + try: dns.zone.from_text(replace_type_codes(content), zone_name + '.', relativize=False) logging.info(f"Zone {zone_name} parsed successfully")