Repository navigation
fix(grok): keep the proxy override on Grok's own hosts - #55
Merged
Merged
Conversation
GROK_CLI_CHAT_PROXY_BASE_URL could point the Grok CLI token at any host. The override is now honoured only for https URLs on grok.com, x.ai or their subdomains, with no userinfo and no port other than 443. Anything else is ignored and the default cli-chat-proxy.grok.com is used.
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.
GROK_CLI_CHAT_PROXY_BASE_URLwas used as the base for the Grok billing and settings calls with no check. Setting it would send the Grok CLI bearer token to any host. teknium1 raised this in the catalog re-review (#53, item 2).The new
_grok_proxy_base()honours the override only when it ishttps, its host isgrok.com,x.aior a subdomain of either, and it has no userinfo and no port other than 443. In every other case it returns empty and the probe uses the defaulthttps://cli-chat-proxy.grok.com/v1. I kept the override, not dropped it, so the Grok CLI's own staging and regional endpoints still work.Tests: two new tests in
test_grok_usage.py, run against bothprobe.pyandcatalog/desktop/probe.py. They record which host each request reaches. Seven rejected overrides all end up oncli-chat-proxy.grok.com: another domain, plainhttp,grok.com.attacker.example,evilgrok.com, userinfo, port 8443 and a malformed URL. Three accepted overrides reach their own host. Without the fix, 6 subtests fail and 2 error. All workflow steps pass locally:test_catalog_policy,py_compileandnode --checkNot tested against a live Grok account.
Refs #53