Files
rengine/scripts/fetch_subdomain_wordlist.py
T
Yogesh OjhaandClaude Opus 5 2cb8d73280 style: strip explanatory comments across the codebase
The comment rule in CLAUDE.md is one line maximum, never narration: no
multi-line blocks, no module-header explainers, no sentences that explain or
justify the code to the reader. The tree had drifted a long way from it, and
most of the drift is mine.

Removed:
  232  lines of multi-line comment blocks
  203  single-line comments that argued instead of stating
  154  comments joined by so/because/otherwise/rather-than
  143  narrating comments in the frontend
  112  test docstrings (the test name already says what it asserts)
   25  test module docstrings and 25 decorative section dividers

Collapsed:
  324  multi-line docstrings to one factual line
  271  one-line docstrings that had a justifying clause bolted on

Kept: functional directives, section dividers, short field labels, alembic
revision headers, and the eight FastAPI route docstrings that render in /docs.
Where a fact was load-bearing it is in CLAUDE.md, which is where it belongs.

284 python tests and 34 frontend tests pass, ruff and ruff-format clean across
ten packages, svelte-check 0 errors, prettier and eslint clean, app.main imports.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013dKUV96WkQQETZBMoAG98C
2026-09-11 14:11:23 +05:30

52 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Regenerate tools/data/subdomains.txt from SecLists' DNS discovery list."""
from __future__ import annotations
import argparse
import re
import sys
import urllib.request
from pathlib import Path
SOURCE = (
"https://raw.githubusercontent.com/danielmiessler/SecLists/master/"
"Discovery/DNS/subdomains-top1million-{size}.txt"
)
SIZES = (5000, 20000, 110000)
OUTPUT = Path(__file__).resolve().parent.parent / "tools" / "data" / "subdomains.txt"
_LABEL = re.compile(r"^[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9_])?$")
def fetch(size: int) -> list[str]:
with urllib.request.urlopen(SOURCE.format(size=size), timeout=60) as response: # noqa: S310
body = response.read().decode("utf-8", errors="replace")
seen: set[str] = set()
labels: list[str] = []
for raw in body.splitlines():
label = raw.strip().lower()
if not label or label in seen or not _LABEL.match(label):
continue
seen.add(label)
labels.append(label)
return labels
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--size", type=int, default=5000, choices=SIZES)
args = parser.parse_args()
labels = fetch(args.size)
if len(labels) < args.size // 2:
print(f"only {len(labels)} usable labels, refusing to write", file=sys.stderr)
return 1
OUTPUT.write_text("\n".join(labels) + "\n")
print(f"wrote {OUTPUT} ({len(labels)} labels)")
return 0
if __name__ == "__main__":
raise SystemExit(main())