Add legacy tools/cli.py shim, document it, and tighten apex domain logic#22
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if parts[0] in COMMON_HOST_PREFIXES and len(parts) >= 3: | ||
| candidate = ".".join(parts[1:]) | ||
| candidate_suffix2 = ".".join(candidate.split(".")[-2:]) | ||
| if candidate_suffix2 not in COMMON_PUBLIC_SUFFIX_2: | ||
| return candidate |
There was a problem hiding this comment.
Strip only rare prefixes breaks subdomain probing
Because _apex_domain now only strips the first label when it is in COMMON_HOST_PREFIXES, common inputs like api.example.com or staging.example.com are treated as the “apex” and the function falls through to return the full host. That means _probe_subdomains will generate admin.api.example.com, www.staging.example.com, etc., instead of probing siblings such as admin.example.com, which is the behavior implied by the default subdomains list. This is a regression for typical URLs where the first label is not in {www,m,app,beta}, and it will silently miss the intended subdomain checks.
Useful? React with 👍 / 👎.
Motivation
python tools/cli.pyby providing a minimal shim that forwards to the unified CLI entrypoint.co.ukwhen computing apex domains.Description
tools/cli.pythat importsmainfromtools.cli.mainand exits with its return code to keeppython tools/cli.pyworking.tools/cli/README.mdwith usage examples and migration guidance._apex_domainintools_v2/categories/security_audit_tools.pyto return the originalhostby default and only strip a known host prefix when the resulting candidate does not collapse into a known two-level public suffix.COMMON_PUBLIC_SUFFIX_2logic to ensure three-part apex domains are returned for those suffixes.Testing
pytest, or CI) were executed after these changes.pytest -q) and CI pipelines to validate runtime behavior and prevent regressions.Codex Task
Note
Introduces a legacy CLI shim and refines domain handling.
tools/cli.pyshim that forwards totools.cli.mainto preservepython tools/cli.pyentrypointtools/cli/README.md_apex_domainintools_v2/categories/security_audit_tools.pyto default to the originalhost, preserve two-level public suffix handling (e.g.,co.uk), and strip common prefixes only when safe to avoid off-target FQDNsWritten by Cursor Bugbot for commit e37059f. Configure here.