A utility to parse DNS BIND zone and view files and convert them to CSV format.
Project description
๐ DNS BIND Zone & View Parser
๐ Transform DNS BIND zone and view files into structured CSV data with ease
A powerful Python CLI tool that parses DNS BIND zone files and view configurations, extracting all DNS records into clean, structured CSV format. Built with modern Python tooling and comprehensive error handling.
โจ Features
- ๐ฏ Comprehensive DNS Support: Handles all standard DNS record types (A, AAAA, CNAME, MX, TXT, NS, SOA, PTR, etc.)
- ๐ Smart Fallback Parsing: Gracefully handles unknown record types and malformed entries
- ๐ CSV Export: Clean, structured output with standardized columns
- ๐ฅ๏ธ CLI Interface: Intuitive command-line interface with auto-completion
- ๐ Zone & View Parsing: Supports both zone files and view configurations
- โก Fast & Reliable: Built on dnspython with optimized parsing algorithms
- ๐งช Well Tested: Comprehensive test suite with 66% coverage
๐ Quick Start
Installation
# Clone the repository
git clone https://github.com/your-username/pybind2csv.git
cd pybind2csv
# Install with uv (recommended)
uv sync
# Or install with pip
pip install .
Basic Usage
# Parse a single zone file
uv run pybind2csv parse-single example.zone --zone-name example.com
# Parse zone and view files together
uv run pybind2csv parse-zone example.zone example.vroaming --output dns_records.csv
# Get help
uv run pybind2csv --help
๐ Requirements
- Python: 3.12 or higher
- Dependencies: Managed automatically via
uvorpip - OS: Windows, macOS, Linux compatible
๐ ๏ธ Usage Guide
CLI Commands
parse-single - Parse Individual Files
uv run pybind2csv parse-single [OPTIONS] FILE
Options:
--zone-name TEXT DNS zone name (e.g., example.com)
--view-name TEXT DNS view name (e.g., internal, external)
--output PATH Output CSV file path
--verbose Enable verbose logging
parse-zone - Parse Zone & View Files
uv run pybind2csv parse-zone [OPTIONS] ZONE_FILE VIEW_FILE
Options:
--output PATH Output CSV file path [default: output.csv]
--verbose Enable verbose logging
Examples
Example 1: Basic Zone Parsing
# Parse a zone file with auto-detected zone name
uv run pybind2csv parse-single tests/example.vlocal --zone-name example.com --view-name local
Example 2: Production Zone & View
# Parse production zone and view files
uv run pybind2csv parse-zone production.zone production.vroaming --output production_dns.csv
Example 3: Verbose Mode
# Get detailed parsing information
uv run pybind2csv parse-single example.zone --zone-name example.com --verbose
๐ Output Format
The parser generates CSV files with the following standardized columns:
| Column | Description | Example |
|---|---|---|
zone |
DNS zone name | example.com |
view |
DNS view name | local |
name |
Record name | www |
type |
DNS record type | A, AAAA, CNAME, etc. |
ttl |
Time to live | 300 |
data |
Record data | 192.0.2.1 |
Sample Output
zone,view,name,type,ttl,data
example.com,local,example.com,SOA,300,ns1.example.com. admin.example.com. 2024010101 3600 1800 604800 86400
example.com,local,example.com,NS,300,ns1.example.com.
example.com,local,www,A,300,192.0.2.1
example.com,local,mail,MX,300,10 mail.example.com.
๐งช Development
Setup Development Environment
# Clone and setup
git clone https://github.com/your-username/pybind2csv.git
cd pybind2csv
# Install with dev dependencies
uv sync --dev
# Run tests
uv run pytest -v --cov=pybind2csv
# Run linting
uv run ruff check .
uv run ruff format .
Project Structure
pybind2csv/
โโโ pybind2csv/
โ โโโ __init__.py # Package initialization
โ โโโ __main__.py # CLI entry point
โ โโโ main.py # CLI commands and interface
โ โโโ parser.py # Core DNS parsing logic
โโโ tests/
โ โโโ test_parser.py # Comprehensive test suite
โ โโโ example.vlocal # Sample zone file
โ โโโ example.vroaming # Sample view file
โโโ pyproject.toml # Project configuration
โโโ README.md # This file
Testing
Run the comprehensive test suite:
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=pybind2csv --cov-report=html
# Run specific test
uv run pytest tests/test_parser.py::test_parse_zone_file_valid -v
๐ Troubleshooting
Common Issues
Unknown Record Types
The parser includes a fallback mechanism for unknown record types. Warnings will be displayed but parsing will continue.
# Example warning
WARNING: Unknown rdatatype 'DSYNC' - using fallback parsing
Large Zone Files
For very large zone files, use verbose mode to monitor progress:
uv run pybind2csv parse-large large.zone --zone-name example.com --verbose
Debug Mode
Enable debug logging for detailed parsing information:
export LOGURU_LEVEL=DEBUG
uv run pybind2csv parse-single example.zone --zone-name example.com
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
Quick Contribution Steps
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run tests:
uv run pytest - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- dnspython - The excellent DNS toolkit powering our parsing
- typer - For the beautiful CLI interface
- uv - For lightning-fast Python package management
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@example.com
Made with โค๏ธ by the DNS Community
Transform your DNS data with confidence and precision
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybind2csv-0.1.2.tar.gz.
File metadata
- Download URL: pybind2csv-0.1.2.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2108455e8110f61da605245f6bd6e479d577729281da2a569b78d29a482bcb64
|
|
| MD5 |
06531c445668ca27f80a7732f120f389
|
|
| BLAKE2b-256 |
613abb4c5cefc2a0a3b59907f1371c3127dc929977b597988744a57e24b9ce14
|
File details
Details for the file pybind2csv-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pybind2csv-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c94b58136d2bdf7a7e81a1b2d179bdc86db819f35aeeb2fc5d9e72268ba472e5
|
|
| MD5 |
7e025bbe61cb963f59e3acf32ea24f27
|
|
| BLAKE2b-256 |
ae57823f397d097152ec6b8231827846ce30fdc757a03c09ea4856c06999cdb1
|