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-9/

DNS Zone File Parser with Directive Support

A Python utility that parses DNS zone file text and creates DNS resource records, properly handling zone file directives like $TTL and $ORIGIN.

Capabilities

Parse zone records with $TTL directive

The parser should correctly interpret the $TTL directive and apply it to subsequent records that don't specify an explicit TTL value.

  • Parsing a zone file with "$TTL 3600" followed by "example.com. A 192.0.2.1" creates a resource record with TTL of 3600 seconds @test
  • Parsing multiple records after a $TTL directive applies the TTL to all records without explicit TTL values @test
  • An explicit TTL in a record overrides the $TTL directive value @test

Parse zone records with $ORIGIN directive

The parser should correctly interpret the $ORIGIN directive and append it to relative domain names.

  • Parsing a zone file with "$ORIGIN example.com." followed by "www A 192.0.2.1" creates a resource record for "www.example.com." @test
  • The @ symbol is replaced with the current $ORIGIN value @test
  • Absolute names (ending with a dot) are not modified by $ORIGIN @test

Parse zone files with both directives

The parser should handle zone files that use both $TTL and $ORIGIN directives together.

  • A zone file with both "$TTL 7200" and "$ORIGIN example.com." correctly applies both to subsequent records @test
  • Directives can appear multiple times and update the default values for subsequent records @test

Implementation

@generates

API

def parse_zone_file(zone_text: str) -> list:
    """
    Parses DNS zone file text and returns a list of DNS resource records.

    Handles $TTL and $ORIGIN directives according to RFC 1035 zone file format.
    Relative domain names are appended to the current $ORIGIN.
    Records without explicit TTL values use the current $TTL directive value.

    Args:
        zone_text: String containing zone file format text with directives and records

    Returns:
        List of DNS resource record objects from the zone file

    Raises:
        Exception: If the zone file format is invalid
    """
    pass

Dependencies { .dependencies }

dnslib { .dependency }

Provides DNS record parsing and zone file format support.