or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/dnslib@0.9.x
tile.json

tessl/pypi-dnslib

tessl install tessl/pypi-dnslib@0.9.0

Simple library to encode/decode DNS wire-format packets

Agent Success

Agent success rate when using this tile

97%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.76x

Baseline

Agent success rate without this tile

55%

task.mdevals/scenario-8/

DNS Zone File Parser and Validator

A utility for parsing DNS zone file records and validating their correctness for a domain authorization system.

Context

You need to build a tool that reads DNS zone file format records and validates them according to specific business rules for a domain authorization system. The system must parse zone-formatted DNS records, extract key information, and ensure they meet certain criteria before being accepted.

Capabilities

Parse basic DNS records from zone format

  • Given a string containing an A record in zone format, the parser extracts the domain name, TTL, and IP address @test
  • Given a string containing a CNAME record in zone format, the parser extracts the alias and canonical name @test
  • Given a string containing an MX record in zone format, the parser extracts the preference and mail server @test

Handle zone file directives and conventions

  • Given zone records with a $TTL directive, subsequent records without explicit TTL use the directive value @test
  • Given zone records with a $ORIGIN directive, relative domain names are correctly expanded @test
  • Given a record using the @ symbol, it is correctly interpreted as the origin domain @test

Validate parsed records

  • Given a zone record with an invalid IP address format, the parser raises an appropriate error @test

Requirements

Your implementation should:

  1. Accept zone-formatted DNS record strings as input
  2. Parse the records to extract structured information (domain name, record type, TTL, record data)
  3. Properly handle zone file directives like $TTL and $ORIGIN
  4. Return parsed records as structured data (dictionaries)
  5. Raise clear exceptions for malformed or invalid records

Implementation

@generates

API

def parse_zone_records(zone_text: str, origin: str = None, default_ttl: int = 3600) -> list:
    """
    Parse DNS records from zone file format.

    Args:
        zone_text: String containing one or more zone-formatted DNS records
        origin: Default origin domain for relative names
        default_ttl: Default TTL value if not specified in records

    Returns:
        List of dictionaries, each containing:
        - 'name': The domain name (str)
        - 'ttl': Time to live in seconds (int)
        - 'record_type': The DNS record type (str)
        - 'data': Record-specific data (dict or str)

    Raises:
        ValueError: If zone text is malformed or invalid
    """
    pass

Dependencies { .dependencies }

dnslib { .dependency }

Provides DNS wire-format packet encoding/decoding and zone file format support.