Refs #406: Reject dotless public URL hosts#522
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ChangesHostname Validation Refactor
Possibly related PRs
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
GHX5T-SOL
left a comment
There was a problem hiding this comment.
Reviewed current head 9e8812d72f52543402b7b70091253783723d2138.
I do not see a blocker. The diff is focused on public URL validation for bounty #406: validate_public_url() now validates IDNA-decoded DNS labels once, keeps the existing malformed-label and length checks, and rejects dotless non-IP hosts with the same public-host error used for non-global IPs. Existing public DNS names and trailing-dot normalization remain in the existing validation path, and the regression adds https://internal/... to the non-public host cases without broadening unrelated ledger behavior.
Code paths checked:
app/ledger/service.py: hostname normalization, DNS label validation, and the newlen(labels) < 2public-host guard.tests/test_security_url_validation.py: non-public host coverage now includes a dotless DNS hostname alongside localhost/private/shared IP cases.
Validation run locally on this exact head:
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ./.venv/bin/python -m pytest tests/test_security_url_validation.py -q->5 passedPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ./.venv/bin/python -m pytest tests/test_security.py tests/test_security_url_validation.py -q->53 passedPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ./.venv/bin/python -m pytest -q->414 passed./.venv/bin/python -m ruff check .-> passed./.venv/bin/python -m ruff format --check .->79 files already formattedPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ./.venv/bin/python -m mypy app-> successPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ./.venv/bin/python scripts/docs_smoke.py-> docs smoke okgit diff --check upstream/main...HEAD-> clean- diff-only Gitleaks scan -> no leaks found
GitHub readback before review: PR is open, non-draft, CLEAN, with Quality and CodeRabbit successful. No secrets, wallet material, private data, production mutation, signing, fund movement, price/exchange/liquidity claim, bridge promise, or off-ramp claim was used.
weilixiong
left a comment
There was a problem hiding this comment.
QUALITY_GATE: LOW risk ✅
2 files, +5/-1: Rejects dotless/single-label hostnames like https://internal/ as non-public, preventing private-network bounty URLs.
app/ledger/service.py: +4/-1 (extract labels before check +len(labels) < 2raises LedgerError)tests/test_security_url_validation.py: +1 line (addshttps://internal/test case)
Verification: pytest tests/test_security_url_validation.py -k non_public → 1/1 passed (0.76s)
Thanhdn1984
left a comment
There was a problem hiding this comment.
Reviewed PR #522 for bounty #447.\n\nEvidence:\n- ........................................................................ [ 72%]
........................... [100%]
99 passed in 13.11s → 99 passed.\n- All checks passed! → passed.\n- → clean.\n\nCode review notes:\n- The new reuse keeps the existing per-label regex validation while adding the intended dotless-host rejection.\n- Error split looks correct: malformed host still raises ; syntactically valid but non-public dotless host now raises .\n- Added regression coverage for through the create-bounty path.\n\nNo blockers found.
Summary
Validation
Summary by CodeRabbit
Bug Fixes
Tests