Repository navigation
Conversation
POST /api/leads/domain-intel passed the caller's text to RDAP, Cloudflare DoH
and crt.sh almost as typed:
- a non-string domain raised AttributeError (HTTP 500);
- replace("www.", "") removed a "www." anywhere in the name, so awww.example.com
was analyzed as aexample.com;
- the name was not lowercased, but crt.sh results are, so Example.com always
reported zero subdomains;
- a path, port, query, space or "&exclude=..." went straight into the RDAP and
crt.sh request URLs.
Add clean_domain(): take the hostname of a domain or URL, lowercase it, drop a
trailing dot and a leading www. only, convert IDNs to punycode and accept only
a valid hostname. The route returns 400 for anything else.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/leads/domain-intelpassed the caller's text to RDAP, Cloudflare DoH and crt.sh almost as typed. Four concrete problems, each reproduced against the route withanalyze_domainstubbed to record its argument:domain(42,["a.com"]) raisedAttributeErroron.strip()and returned HTTP 500.domain.replace("www.", "")removes awww.anywhere in the name:awww.example.comwas analyzed asaexample.com.get_crtsh_subdomainslowercases certificate names beforeendswith("." + domain), soExample.comalways reported zero subdomains.&exclude=nonewas interpolated into therdap.org/domain/{domain}andcrt.sh/?q=%25.{domain}&exclude=...URLs unvalidated.Security-sensitive note (per CONTRIBUTING): the endpoint is editor-only and the fixed third-party hosts do not change; this validates input going into outbound request URLs and does not touch the SSRF guard.
Change
clean_domain()indomain_intel.pytakes the hostname of a domain or URL (https://WWW.Example.com:8443/pricing?x=1becomesexample.com), lowercases it, drops a trailing dot and a leadingwww.only, converts IDNs to punycode, and accepts only a valid multi-label hostname. The route uses it and answers 400 for anything else;analyze_domainand the providers are unchanged.Evidence
New
tests/test_domain_intel_route.py(29 cases). On currentmainthe route tests fail:Verification
uv run pytest tests/test_domain_intel_route.py: 29 passed.localhostnow get 400.Commit is signed off per the DCO.