Skip to content

Centralize loopback host classification - #389

Closed
shanselman with Copilot wants to merge 3 commits into
masterfrom
copilot/deep-review-duplication
Closed

shanselman with Copilot wants to merge 3 commits into
masterfrom
copilot/deep-review-duplication

Conversation

Copilot AI commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Loopback/local URL checks were duplicated across MCP, tray chat URL handling, gateway classification, and CLI token safety with subtly different parsing rules. This PR centralizes the shared host parsing while preserving each caller’s security/UX semantics.

  • Shared classifier
    • Added OpenClaw.Shared.Net.LoopbackClassifier
    • Centralizes host extraction for literals, host:port, and bracketed IPv6
    • Adds helpers for loopback endpoints, local gateway URLs, and private-network URLs
LoopbackClassifier.IsLoopbackHostString("[::1]:8765");
LoopbackClassifier.IsLoopbackEndpoint(ctx.Request.RemoteEndPoint);
LoopbackClassifier.IsPrivateNetworkUrl("ws://192.168.1.10:18789");
  • Call site consolidation

    • MCP Host-header allowlist now uses the shared loopback host parser
    • MCP remote endpoint check uses the shared endpoint helper
    • LocalGatewayUrlClassifier delegates to the shared URL classifier
    • Tray chat URL builder and CLI MCP token guard use the same loopback host logic
  • Focused coverage

    • Added tests for host parsing, endpoint classification, local gateway URLs, private-network ranges, and IPv6 loopback chat URLs

Copilot AI changed the title [WIP] Refactor loopback host check to eliminate duplication Centralize loopback host classification May 14, 2026
Copilot AI requested a review from shanselman May 14, 2026 21:25
@shanselman

Copy link
Copy Markdown
Collaborator

Closing this automation implementation as stale/superseded after the post-refactor triage. The underlying signal is preserved in #371 and the tracker update in #372: loopback host classification is retained in the #372 post-refactor tracker, but this Copilot SWE draft predates the refactor.

@shanselman shanselman closed this May 18, 2026
@shanselman
shanselman deleted the copilot/deep-review-duplication branch September 7, 2026 06:30
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.

[deep-review][duplication] D8: Loopback host check duplicated in 3 places with subtly different rules

2 participants