Skip to content

fix(leads): complete domain-intel input validation - #113

Merged
debpalash merged 2 commits into
mainfrom
fix/domain-intel-parser-regressions-20261023
Oct 23, 2026
Merged

debpalash merged 2 commits into
mainfrom
fix/domain-intel-parser-regressions-20261023

Conversation

@debpalash

Copy link
Copy Markdown
Owner

Summary

Continuation of #102, preserving Rudy Celekli's original commit ff77c11 and its authorship/sign-off unchanged. This replacement is on a maintainer-owned branch because the connected account cannot push to the contributor's fork.

  • Keep the original clean-domain normalization and route validation.
  • Treat URL parsing or hostname extraction failures as invalid input rather than server errors.
  • Preserve protocol-relative URLs by avoiding a second // prefix.
  • Add focused helper and route regressions, including HTTP 400 with no analysis call for malformed inputs, and successful protocol-relative normalization.

Security-sensitive path: this changes input validation before outbound domain-intelligence calls. It does not change provider destinations or the SSRF guard.

Validation

  • Reviewed the patch and preserved the original commit history.
  • Local tests were not run: no execution environment is currently available.
  • GitHub CI and independent review are required before this draft is marked ready or merged.
  • Suggested focused check: uv run --frozen pytest -q tests/test_domain_intel_route.py.

The original PR is left open for now. No merge or deployment is included in this change.

rudycelekli and others added 2 commits October 14, 2026 19:23
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>
Catch ValueError from URL parsing and hostname extraction before domain
analysis. Preserve protocol-relative URLs instead of adding a second //
prefix. Add direct and route regressions for malformed brackets, NFKC
netloc separators, and protocol-relative input.

Signed-off-by: Palash Debnath <4178343+debpalash@users.noreply.github.com>
@debpalash
debpalash marked this pull request as ready for review October 23, 2026 08:45
@debpalash
debpalash merged commit 696d5d3 into main Oct 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants