Skip to content

fix(lab-ops-hub): return WHATWG-normalized URLs from the container validator (#633) - #644

Merged
dezren39 merged 1 commit into
mainfrom
sweep/633-dotseg-hostcase-port
Oct 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
sweep/633-dotseg-hostcase-port

Conversation

@dezren39

@dezren39 dezren39 commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Problem

Fixes #633.

validate_crawl_url in the container crawler (pkgs/lab-ops-hub/container/app.py) returned the caller's spelling with only the character-encoding fixes of #614/#615/#618 — no WHATWG normalization — while the Worker validator returns u.toString(). For the same accepted target the two crawlers recorded and fetched different URLs:

Input Container returned Worker returns
http://example.com/a/../b http://example.com/a/../b http://example.com/b
http://example.com/%2e%2e/admin verbatim http://example.com/admin
HTTP://EXAMPLE.COM/Path http://EXAMPLE.COM/Path http://example.com/Path
http://example.com:80/x, :080 verbatim http://example.com/x

The fetcher consequence is the serious arm: _fetch_crawl sent /a/../b and /%2e%2e/admin on the wire verbatim, so an origin (or proxy/WAF) that routes on the raw request target serves the container a different resource than the Worker — and %2e%2e is the classic path-confusion spelling when one layer resolves it and another does not.

Solution

New _normalize_validated_url, applied at both validate_crawl_url return sites (DNS names and IP literals); redirect targets inherit it via _ValidatingRedirectHandler → validate_crawl_url.

No verdict changes: blocked hosts in these spellings are still refused by the ordinary checks, for the right reason (#633's controls verified).

Verification

  • Reproduced on main 9298c5f2 before the fix (all issue spellings returned verbatim).
  • New tests: Python battery (24 normalized cases + data controls + blocked controls), a redirect-handler pin (normalized target followed), a fetcher end-to-end test (the validated resolved path /b, /admin is what reaches the server), and a TS pin of the Worker form. Python 54/54, TS 37/37.
  • Ablation: with only app.py reverted, exactly the 3 new Python tests fail.
  • Differential vs the real Worker validator under Bun: byte-identical returned URLs over the full issue battery plus a 1500-case fuzz over dot-segment × host-case × port spellings (0 diffs; the only known remaining host divergence is the pre-existing, intentional IDN spelling — the container keeps münchen.de, the Worker serializes punycode).
  • ruff format applied. Single-repo: no validate_crawl_url/validateCrawlUrl copy exists in the opencode/openchamber/nix clones (grep-verified), so no cross-repo port is owed.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…lidator (#633)

validate_crawl_url returned dot segments, host case and default
ports verbatim, so the container recorded — and fetched — a
different URL than the Worker for the same accepted target
(/a/../b and /%2e%2e/admin went on the wire verbatim).

Add _normalize_validated_url, applied at both return sites:
_resolve_dot_segments resolves literal and %2e dot segments
(any case, trailing dot segments become a trailing slash, no
climbing above the root, empty segments and %252e data
preserved), the host is ASCII-lowercased (IDN spelling kept, as
before), and the port is canonicalized (scheme default dropped
including leading-zero spellings, other ports stripped of leading
zeros, empty port colon dropped). Redirect targets inherit the
form via validate_crawl_url.

Tests: Python battery + redirect-handler pin + fetcher end-to-end
(resolved path reaches the server), TS pin of the Worker form.
Differential vs the Worker validator under Bun: byte-identical
returned URLs over the issue battery and a 1500-case fuzz over
dot-segment/host-case/port spellings.
@dezren39
dezren39 requested a review from a team as a code owner October 23, 2026 04:06
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T04:06:16.886932Z 212d1a0 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 50de6c53-3279-4a91-94ed-806a5d907d71
📥 Commits

Reviewing files that changed from the base of the PR and between 9298c5f and 212d1a0.

📒 Files selected for processing: 3
  • pkgs/lab-ops-hub/container/app.py
  • pkgs/lab-ops-hub/test/lib.test.ts
  • pkgs/lab-ops-hub/test/test_container_validate.py
+------------------------------------------------+
| PENDU: Prompt Engineered Nifty Debugging Unit. |
+------------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dezren39
dezren39 merged commit 7295601 into main Oct 23, 2026
4 of 5 checks passed
@dezren39
dezren39 deleted the sweep/633-dotseg-hostcase-port branch October 23, 2026 04:07
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.

lab-ops-hub: container validator returns dot segments, host case and default ports un-normalized — fetcher requests a different path than the Worker

1 participant