Repository navigation
Description
Problem
Lines cited at dcafadf. Paths are under src/devops_cli/ unless they start with tests/.
At 132ecc5, ai/mcp/server.py:2050 is :2073; no other cited line moved.
Several modules read a URL, or a bare host:port, with substring tests, prefix tests, split(":"), str.replace chains and hand-written default-port tables, and then hand the string to a client that parses it differently. Where the two readings disagree, a check passes for one host while the request goes to another, or a valid endpoint is refused.
Scheme sniffing and http:// prefixing:
ai/models/ollama.py:52-60sniffs"://"and prefixeshttp://. Theurlsplitgate right after it (:62-67) already refuses every scheme except http and https. The value comes fromai.ollama_urls, abase_urlargument, or theOLLAMA_BASE_URLenvironment variable (:148).k8s/credentials.py:26-33(_clean_service_base_url) prefixeshttp://to a scheme-lessargocd.urlorgrafana.url, andmint_argocd_token(:232-245) andmint_grafana_token(:327-338) then send the admin password to it over plain http. The test is case-sensitive, soHTTPS://example.combecomeshttp://HTTPS://example.com.commands/argo.py:170andargo/fleet.py:48already refuse a scheme-lessargocd.url; this path does not.config/settings.py:503-514(AIConfig.get_ollama_urls) turnsHTTP://example.com:11434intohttp://HTTP://example.com:11434.sandbox/metrics.py:645-649(_build_scrape_url) testsstartswith("http"), so a target whose host name begins with "http" (httpbin.example.com:8080) gets no scheme at all, andHTTP://example.combecomeshttp://HTTP://example.com.security/vulnerability_lookup.py:485-489,telemetry/instruments.py:207-212andai/spend/pricing.py:63-87and:104-116sniff"://"before callingurlparse/urlsplit;pricing.py:108also testsstartswith("http+unix://").
Default-port tables (443 if https else 80):
ai/benchmark/runner.py:56-63(_url_origin) feeds the trust boundary that decides whether the AI key goes to a benchmark endpoint (_key_for_endpoint, :66-93, fix(ai): the embedding benchmark takes any endpoint from an MCP client and counts failed embeddings as results #954). It fails closed today: a value with no host or a bad port gets no origin, and nothing is raised. But it calls equal origins different (an IDN host and its A-label) and repeats what the HTTP client already computes.commands/k8s/networking.py:223(_verify_url_reachability) andsandbox/probe.py:490.
Hand-split host and port:
sandbox/probe.py:485-495(_parse_target_endpoint) splits at the first ':', so[::1]:8080raisesValueError. It also returns only(host, port), so the scheme is lost: anhttps://target is probed over http at :515 and :527.telemetry/tracer.py:1121-1134(test_connection) strips schemes withstr.replaceand splits at the first ':', sogrpc://[::1]:4317andHTTP://example.com:4317report "gRPC probe failed" for a reachable collector.tracer.py:704-712chooses gRPC with":4317" in self.endpoint, which also matcheshttp://example.com:43170and any path containing:4317.tracer.py:1101-1113strips schemes with astr.replacechain before buildingOTLPSpanExporter, and setsinsecurefrom a case-sensitivestartswith("https://").sandbox/models.py:62-82(_extract_host_or_ip) splits at '/' and ':' and strips brackets by hand (:82).security/vault_broker.py:37-58(parse_vault_uri) splits '#' by hand and testsstartswith("vault://"), soVAULT://secret/data/xcomes back unchanged as a path.
model@endpoint specs are split by hand in five places and guarded by a substring test in a sixth:
ai/mcp/server.py:2050refuses an MCP model string containing any ofCONST_MODEL_ENDPOINT_MARKERS(("@", "://"),config/constants.py:269).- The splits, all at the first '@':
ai/benchmark/runner.py:216-219, andai/benchmark/embedding_runner.py:270-273,:306-309,:322and:548-550. embedding_runner.py:278-280forces the ollama provider for any endpoint containing "ollama" or ":11434".
The docs crawler:
ai/library/docs_ingester.py:297-317(_collect_child_links) compares rawnetlocstrings. From a crawl ofhttps://example.com/, links tohttps://EXAMPLE.COM/aandhttps://example.com:443/bare dropped as foreign, whilehttp://example.com/c(a downgrade) is followed.- Its directory slug (:233-237) is the path, or else the raw
netloc. Sohttps://user:[email protected]writesuser:[email protected]as a directory name, and a path of/..gives the slug... The page slug (:274-276) is built the same way from the path. - It fetches with a raw
httpx2.Client(timeout=30.0)(:244). fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 moves every client to one factory and leaves this one as a temporary exception, because this item owns the file.
Why the fix cannot use pydantic for these reads: pydantic-core follows WHATWG, where a backslash counts as a slash, while httpx2 and urllib.parse follow RFC 3986. An offline probe at the locked versions (pydantic 2.13.5, httpx2 2.13.0) showed that for https://example.com\@192.0.2.1/v1, TypeAdapter(AnyHttpUrl) reads the host as example.com, while urlsplit and httpx2.Request(...).url.host (the host actually dialled) read 192.0.2.1. A pydantic origin check would hand the AI key to that host and reopen #954, and the crawler would fetch from it.
Why a bare swap to httpx2.URL(u).origin is not enough either: the same probe showed .origin raising ValueError ("URL must be absolute to have an origin") for localhost:8000/v1, example.com, http://:8080 and a value with surrounding spaces, and raising httpx2.InvalidURL, which is not a ValueError subclass, for https://example.com:abc/v1. Configured api_base_url, gateway_url and ai.ollama_urls can still hold such values, because loading the settings does not check them (#1000). Without a guard, one malformed configured URL would make every benchmark run raise at the key boundary.
The rule for this item: parse once, with the parser of the client that sends, and check the value that is sent. No new dependency is needed.
Replacement, site by site:
- Origin helper (one function, used by
runner.py:56-93, the crawler and the provider choice below). It returnshttpx2.URL(value.strip()).origin, and returns None when that raisesValueErrororhttpx2.InvalidURL. The.strip()keeps today's_url_originbehaviour for padded values.- httpx2 2.13.0 is a direct, exact-pinned dependency (pyproject.toml:19), and
Originis public (it is inhttpx2.__all__). It fills in default ports, gives IPv6 and IDN hosts one form (xn--bcher-kva.example.comandbücher.example.comgive the same origin), and drops userinfo. - A value with no origin is never trusted and never matched, and nothing is raised. The key boundary fails closed, as it does today.
- The helper and the shared reader below live in one module that every caller imports (for example a new
src/devops_cli/http/urls.py).
- httpx2 2.13.0 is a direct, exact-pinned dependency (pyproject.toml:19), and
- The crawler (
docs_ingester.py:233-237,:274-276,:297-317).- It resolves links with
httpx2.URL(current).join(link), skips any link that raiseshttpx2.InvalidURLorValueError(a tab raisesInvalidURL), and follows a link only when its origin equals the start URL's. - Slugs are built from
httpx2.URL(url).path, else.host, which carry no userinfo or port. - httpx2 removes
/..segments but decodes%2e%2eto/... So the directory slug is used only whenpathlibresolves it to a direct child of the ingest root ((root / slug).resolve().parent == root.resolve()); otherwise the host is the slug. An offline probe showedhttps://example.com/%2e%2eandhttps://example.com/%2Efailing that test, andhttps://example.com/a/%2e%2e(sluga_..) passing it. - The page slug only names files inside that directory (
{slug}_{index:03d}.json), so it needs no such test. It falls back to the directory slug, as today.
- It resolves links with
- host:port reads.
probe.py:485-495:_parse_target_endpointreturns anhttpx2.Origininstead of a(host, port)pair. The target is read with the shared reader. When the result has a scheme, the origin is the origin helper's result. A barehost[:port](a result with no scheme) gets its host and port with schemehttpand port 80 when absent, built ashttpx2.Origin(httpx2.URL(scheme="http", host=host, port=port)). A target with no host or a malformed port is refused with aValidationErrornaming the target. Todayhttp://:8080silently probes 127.0.0.1, andexample.com:abcraises a bareValueErrorfromint()._resolve_probe_target(probe.py:392-404) returns origins for instance port bindings too (schemehttp, which is what today's probe URLs assume). The loop at :455 passesorigin.hostandorigin.portto_dispatch_probes_for_port, whose signature does not change in this item. The scheme now reaches the dispatch call. fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111 consumes it: it passes the origin into_dispatch_probes_for_portand builds the probe URLs at :515 and :527 fromorigin.scheme. Until fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111 lands, probes stay on http, as today.networking.py:223: the origin helper's.hostand.port. No origin returns False, as an unparsable URL does today.tracer.py:1121-1134uses the shared reader with.port or 4317, because 4317 is the OTLP gRPC default whatever scheme is written.tracer.py:704-712decides gRPC from the parsed scheme (grpc) and port (4317), andtest_connectionfollowsself.protocolalone.
- Shared "URL or bare authority" reader (one function, used by
vulnerability_lookup.py:485-489,instruments.py:207-212,pricing.py:63-87and:104-116,metrics.py:645-649and the bare forms above).ipaddress.ip_address(s)first (a bare IPv6 literal goes tourlsplitin its bracketed RFC 3986 form). Thenurlsplit(s), thenurlsplit("//" + s)when that found no host. The//prefix is needed because, as theurllib.parsedocumentation states, a netloc is recognised only when introduced by//.- The fallback applies only when
urlsplit(s).netlocis empty. Whenurlsplit(s)found a scheme, the fallback is kept only if it found a port.example.com:8080reads as schemeexample.comwith path8080, a bare host and port. Inhttps://andhttp:///x, by contrast, the fallback reads the scheme name as a host with no port: an offline probe showedurlsplit("//https://").hostname == "https". Sohttp://:8080,https://andhttp:///xhave no host, as they have today. The rule compares parsed components only, with no prefix or substring test on the text. - A port that does not parse (
example.com:abc) keeps the fallback, so theValueErrorreaches only callers that read.port. - An empty port after a host (
example.com:,example.com:/x) gives no host. RFC 3986 reads both as a scheme with no authority; today_extract_host_or_ipgives the host. - It returns the
SplitResultthat has a host, or None..portis read only by callers that need it, so a caller that reads only.hostnamenever sees a port error, as today. pricing.py:108comparesurlsplit(s).scheme.
- Scrape URL (
metrics.py:645-649)._build_scrape_urlreads the target with the shared reader and builds its result withhttpx2.URL(scheme=..., host=..., port=..., path=...).- The scheme is the target's, or
httpfor a bare target. - The target's path is kept: the endpoint is appended under it with one '/' between, as today's
rstrip('/')join does.http://example.com:9100/prefixwithmetricsstill giveshttp://example.com:9100/prefix/metrics. - A target with no host, or with a scheme other than http or https, is refused.
- The scheme is the target's, or
sandbox/models.py:62-82:ipaddress.ip_address(s)(a bare address, returned as is), thenipaddress.ip_network(s, strict=False)(a CIDR, returned in itsstrform), then the shared reader. Theipaddresssteps must come first, becauseurlsplit("//2001:db8::1")reads the host as2001.- An offline differential over more than 36,000 generated forms compared this with today's function. The forms were IPv4, IPv6 and IPv4-mapped addresses and host names, written bare, as CIDR, as
[v6]:port, as URLs, ashost:port/path, with userinfo, and with empty or malformed ports. It found three kinds of difference, all intended:Example.COMcomes back lowercased;[email protected]:22givesexample.com;- an empty port (
example.com:,example.com:/x) gives'', so such a whitelist entry is refused as invalid (models.py:111-113and:122-124) instead of being accepted under its host.
- An offline differential over more than 36,000 generated forms compared this with today's function. The forms were IPv4, IPv6 and IPv4-mapped addresses and host names, written bare, as CIDR, as
vault_broker.py:37-58:urllib.parse.urldefragfor the key, andurlsplit(...).scheme == "vault"(which also handlesVAULT://). Bothvalidate_no_path_traversalcalls stay. Do not use pydanticAnyUrlhere: an offline probe showed it resolvesvault://secret/data/../xtovault://secret/x, which hides the traversal from the check.ollama.py:52-60: delete it. Theurlsplitgate at :62-67 then refuses scheme-less values too, becauseurlsplitreadsexample.com:11434as schemeexample.com, and its message already asks for http or https. Add a refusal of an emptynetlocto the same gate, after the scheme test, sofile:///etc/passwdkeeps its scheme error.credentials.py:26-33andget_ollama_urls: parse withurlsplit. Refuse a value with no http(s) scheme or no host, naming the setting (argocd.url,grafana.url,ai.ollama_urls) or the option it came from. Returnurlunsplit(...), soHTTP://comes back ashttp://.- OTLP exporter (
tracer.py:1101-1113): pass the endpoint toOTLPSpanExporter(endpoint=self.endpoint, ...)unchanged. The exporter (opentelemetry-exporter-otlp-proto-grpc 1.44.0, pinned at pyproject.toml:39) parses it itself inexporter.py:314-326: it takes thenetlocwhen a scheme is present and forces TLS for https. Keepinsecureexplicit, fromurlsplit(endpoint).scheme != "https". - One
parse_model_specreplaces the five splits.model@endpointis the project's own--modelssyntax; no library parses it, sostr.partitionstays the parser, kept in one place.- It lives in a new stdlib-only module,
src/devops_cli/ai/benchmark/model_spec.py. The MCP server imports it inside_validate_mcp_benchmark_target, becauseai/benchmark/__init__.pyimports both runners. - It splits at the first '@', as today's
partition("@")does, so an endpoint's own userinfo (m@https://u:[email protected]) stays in the endpoint. - It returns
(model, endpoint): endpoint None when the entry has no '@', otherwise the text after the first '@'. The runners treat an empty endpoint as none, as today. - The same module holds the comma-separated list split that
commands/benchmark.py:58-62(_parse_model_list) does today. The CLI and the MCP guard both call it. - The MCP guard refuses any entry whose endpoint is not None, valid or not. It also refuses an entry that
httpx2.URL(entry).is_absolute_urlreads as a URL, or that httpx2 cannot read (see the key questions).CONST_MODEL_ENDPOINT_MARKERSis deleted.
- Provider for an explicit endpoint (
embedding_runner.py:278-280): compare the endpoint's origin with the origins of the configuredai.ollama_urlsentries (the raw list, notget_ollama_urls, which now refuses) andgateway_url, all through the origin helper. Any value with no origin, on either side, matches nothing and raises nothing. With a gateway provider and any other endpoint, refuse and ask for--provider; never reroute silently (see the key questions).
Acceptance criteria
- Key trust. tests/test_ai_benchmark.py:214-250 keeps its five rows and gains four. Each is (provider, configured
api_base_url, model, key):- (
openai,https://example.com/v1,m@https://example.com\@192.0.2.1/v1) gets''. The second host is an RFC 5737 address, so no subdomain is needed. - (
openai,https://example.com/v1,m@https://example.com:443/v1) gets the key. - (
openai,https://xn--bcher-kva.example.com/v1,m@https://bücher.example.com/v1) gets the key. The IDN label is the point of the row, which needs a subdomain. - (
openai,localhost:8000/v1,m@https://example.com/v1) gets'', and nothing is raised.
- (
- Key trust, direct call.
_key_for_endpoint(settings, cfg)returns''and raises nothing:- when
cfg.api_base_urlishttps://example.com:abc/v1; - when the configured
api_base_urlorgateway_urlislocalhost:8000/v1.
- when
- Crawl. tests/test_docs_ingester.py:218-253 gains cases. From
https://example.com/root:- links to
https://EXAMPLE.COM/aandhttps://example.com:443/bare followed; http://example.com/c,https://example.com\@192.0.2.1/dand a link containing a tab are not;- a start URL of
https://user:[email protected]gives a slug that contains neitherusernortoken; - with no output directory given, a start URL of
https://example.com/%2e%2ewrites its chunks into a direct child of the ingest root, not into the root or its parent.
- links to
- Crawler client. If fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898's client factory has landed when this item merges, the crawler takes its client from that factory (
docs_ingester.py:244), and the temporary exception for this file is removed from fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898's raw-clientrgcriterion. Otherwise fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 PR B moves it. - Probe.
_parse_target_endpointreturns anhttpx2.Origin. As (scheme, host, port):https://example.comgives (https,example.com, 443);127.0.0.1:9090gives (http,127.0.0.1, 9090);localhostgives (http,localhost, 80);[::1]:8080gives (http,::1, 8080);HTTPS://example.com:8443gives (https,example.com, 8443).http://:8080andexample.com:abcraise aValidationErrornaming the target.- tests/test_sandbox_probe.py:493-507, which unpacks a pair today, is rewritten to these rows.
- The caller at
probe.py:403and the loop at :455 carry origins, and probe requests are unchanged until fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111 lands. - The
_verify_url_reachabilitytests in tests/test_k8s_bootstrap.py:200-215 pass unchanged.
- Tracer, with
socket.create_connectionmocked:test_connectiondials("::1", 4317)forgrpc://[::1]:4317and("example.com", 4317)forHTTP://example.com:4317;http://example.com:43170with no protocol set getshttp/json.
- Exporter.
OTLPSpanExporterreceives the endpoint unchanged:insecure=Trueforgrpc://example.com:4317,http://example.com:4317and a bareexample.com:4317;insecure=Falseforhttps://andHTTPS://.- tests/test_telemetry.py:426-477 is updated to match.
- Credentials. A scheme-less
argocd.url(example.com) fails with an error namingargocd.url, and the mockedhttpx2.Client.postis never called.HTTPS://example.comis used ashttps://example.com. The same holds forgrafana.url. tests/test_k8s_credentials.py:86-216 gains these rows. - Ollama URLs.
get_ollama_urlsreturnshttp://example.com:11434forHTTP://example.com:11434, and refusesexample.com:11434namingai.ollama_urls. tests/test_ai_client_security.py:130-135 gains both rows.normalize_ollama_base_url("example.com:11434")raisesInvalidURLErrorinstead of returning an http URL.- tests/test_pydantic_ai_ollama.py:45-106 passes unchanged.
- Scrape URL. These are new tests; none exists today.
_build_scrape_url("httpbin.example.com:8080", "metrics") == "http://httpbin.example.com:8080/metrics". A host name beginning with "http" is the point of the row, which needs a subdomain.HTTP://example.comgiveshttp://example.com/metrics.[::1]:8080giveshttp://[::1]:8080/metrics._build_scrape_url("http://example.com:9100/prefix", "metrics") == "http://example.com:9100/prefix/metrics", and the same for the endpoint/metrics.ftp://example.comis refused.
- Host extraction. Every row of tests/test_sandbox_networking.py:421-447 and the hypothesis oracle in tests/test_sandbox_policy_properties.py:216-247 pass unchanged. New rows:
Example.COMgivesexample.com, and[email protected]:22givesexample.com;http://:8080,https://andhttp:///xgive'', as today (nothttporhttps);example.com:andexample.com:/xgive'', and_validate_public_whitelist_itemrefuses them as invalid entries.
- Vault.
parse_vault_uri("VAULT://secret/data/x#k") == ("secret/data/x", "k"). The traversal tests still raise: tests/test_vault_broker.py:19-33, tests/test_network_security_and_trace_correlation.py:44-50 and tests/test_runtime_security_and_ssrf_hardening.py:56-67. - Readers of served_by and config strings.
- tests/test_telemetry_instruments.py:422-432 and tests/test_ai_spend_pricing.py:269-302 pass unchanged.
- New:
_extract_domain_target("example.com:8080") == "example.com". Today it returns the port as part of the name.
- Model specs.
parse_model_specis the only code that splitsmodel@endpoint.parse_model_spec("m@https://u:[email protected]/v1") == ("m", "https://u:[email protected]/v1"),parse_model_spec("m") == ("m", None), andparse_model_spec("m@")gives an empty endpoint, which the runners ignore.- MCP tools refuse
x@https://example.com,bge-m3,x@https://example.com,x@andhttps://example.com/bge-m3, and acceptbge-m3,nomic-embed-textandhf.co/org/model:Q4. tests/test_mcp.py:482-490 keeps its rows (the one at :487,https://example.com/bge-m3, stays refused) and gains thex@row and the two accepted rows.
- Provider. tests/test_embedding_benchmark.py:227-240 is updated. With
ai.provider=gateway:- an embedding benchmark whose
--serversorigin matches neither a configuredai.ollama_urlsentry norgateway_urlrefuses with a--providerhint and sends no request; - an endpoint whose origin equals a configured Ollama URL runs as ollama;
- a configured
ai.ollama_urlsentryexample.com:11434(no scheme) matches nothing and raises nothing; - "ollama" in a host name no longer chooses the provider.
- an embedding benchmark whose
- No construct left.
rg -n '"://" (not )?in|443 if .* else 80|CONST_MODEL_ENDPOINT_MARKERS' src/devops_cli/ai/benchmark src/devops_cli/ai/mcp/server.py src/devops_cli/ai/models/ollama.py src/devops_cli/ai/spend/pricing.py src/devops_cli/commands/k8s/networking.py src/devops_cli/sandbox/models.py src/devops_cli/sandbox/probe.py src/devops_cli/security/vulnerability_lookup.py src/devops_cli/telemetry/instruments.py src/devops_cli/config/constants.pyprints nothing.rg -n 'startswith\(\(?"(http|https|grpc|vault)|\.replace\("(https?|grpc)://"|":4317" in|strip\("\[\]"\)' src/devops_cli/k8s/credentials.py src/devops_cli/config/settings.py src/devops_cli/sandbox/metrics.py src/devops_cli/telemetry/tracer.py src/devops_cli/security/vault_broker.py src/devops_cli/sandbox/models.py src/devops_cli/ai/models/ollama.py src/devops_cli/ai/spend/pricing.pyprints nothing.rg -n '"@" in|partition\("@"\)|split\("@"\)' src/devops_cli/ai/benchmark src/devops_cli/ai/mcp src/devops_cli/commands/benchmark.pyprints only lines insideai/benchmark/model_spec.py.rg -n 'netloc|urljoin|urlparse' src/devops_cli/ai/library/docs_ingester.pyprints nothing.- With feat(ci): hand-rolled URL and address parsing fails
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 landed, nonet-*marker is left on the lines this item rewrites, and feat(ci): hand-rolled URL and address parsing failsdevops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107's marker ceiling drops by the number removed. Among them:net-scheme-inandnet-scheme-affix;net-port-tableat runner.py:60, networking.py:223 and probe.py:490;net-url-buildat ollama.py:60 (f"http://{clean_url}") and metrics.py:647 (f"http://{target}");net-normaliseat sandbox/models.py:82 (strip("[]"));net-address-listat config/constants.py:269.
- Release.
- Tests stay offline: no DNS, no sockets.
- No dependency is added.
uv run devops cipasses.- A changelog.d fragment lists the fixes under
### Fixed. Under### Changedit lists:- the refusal of a scheme-less
argocd.url,grafana.url,ai.ollama_urlsorOLLAMA_BASE_URL; - the probe's refusal of a target with no host;
- the embedding benchmark's refusal of an unknown endpoint under a gateway provider;
- the refusal of a sandbox whitelist entry with an empty port (
example.com:).
- the refusal of a scheme-less
Key questions
- Why not read these URLs with pydantic
AnyHttpUrl? Proposed: never for an origin or trust comparison, because of the backslash disagreement shown above. Typed URL settings are refactor(config): a settings field is the one declaration, and the option, env and config-show registries become views of it #1000's, with the constraint that the value checked is the value sent. - What happens to a URL the origin helper cannot read? Proposed: it has no origin. It is never trusted and never matched, and nothing is raised, so the key boundary keeps failing closed. Refusing malformed settings at load time is refactor(config): a settings field is the one declaration, and the option, env and config-show registries become views of it #1000's job, not the key boundary's.
- May served_by and other read-only strings be a bare
host:port? Proposed: yes. served_by comes from a gateway response header (CONST_AI_GATEWAY_SERVED_BY_HEADER, read atai/client/openai.py:175and:205), not from config, and pricing and instruments only classify it or name it. They use the shared reader. - Refuse a scheme-less
argocd.url,grafana.url,ai.ollama_urlsorOLLAMA_BASE_URLinstead of prefixinghttp://? Proposed: yes, pre-1.0. Prefixing silently sends admin passwords over plain http. Other paths already refuse such values:commands/argo.py:170andargo/fleet.py:48refuse a scheme-lessargocd.url;- fix(ai): client timeouts, streamed response limits, model-resolution errors and dead round-robin state #960 refuses a scheme-less
ai.api_base_urlorai.gateway_url, naming the key (tests/test_pydantic_ai_profiles_and_providers.py:436-459). - This item stops the rewriting where the values are read; checking them when settings load is refactor(config): a settings field is the one declaration, and the option, env and config-show registries become views of it #1000's job. The changelog says so, and nothing rewrites a user's config.yaml.
- Does the probe parser return the scheme, or does fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111 parse the target again? Proposed: it returns the scheme, as an
httpx2.Origin, so the target is parsed once. fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111 builds the probe URLs from that origin. - Does the MCP guard still refuse a model string that contains
://but no '@'? Proposed: yes, with httpx2 reading the entry instead of a substring test. The guard refuses an entry for whichhttpx2.URL(entry).is_absolute_urlis true, or which httpx2 cannot read, and tests/test_mcp.py:487 stays refused.- An offline probe showed
is_absolute_urlfalse forbge-m3,nomic-embed-text:latest,qwen3:30b-a3b,BAAI/bge-m3andhf.co/org/model:Q4, and true forhttps://example.com/bge-m3andHTTPS://example.com/x. - Once
parse_model_specis the only reader, no code treats such a string as an endpoint, so dropping the refusal would be safe. It would still loosen a fix(ai): the embedding benchmark takes any endpoint from an MCP client and counts failed embeddings as results #954 guard, which this item does not need; any such relaxation is a separate decision.
- An offline probe showed
- How is the embedding provider chosen for an explicit endpoint? Proposed: by origin. An endpoint matching a configured
ai.ollama_urlsentry runs as ollama, and one matchinggateway_urlruns as gateway; otherwise the configured provider is used. The exception is a gateway provider with any other endpoint: the run refuses and asks for--provider._openai_compatible_base_url(ai/rag/embeddings.py:784-789) sends gateway requests togateway_urlwhatever endpoint was named, so without the refusal the benchmark would silently measure a different server. - Pass the OTLP endpoint through, or keep stripping it? Proposed: pass it through, and keep
insecureexplicit. Withinsecure=None, the exporter treats onlyhttpas plaintext, sogrpc://and bare endpoints would switch to TLS and break today's plaintext collectors. - Is yarl needed? Proposed: no.
httpx2.Origincovers origins. yarl is only a transitive dependency (1.24.5, via aiohttp), and a second URL parser is exactly the mismatch this item removes. - Include
commands/sandbox.py:445and:662("://" in identifier or ":" in identifier)? Proposed: no. Those lines choose between a sandbox name and a target. They keep their feat(ci): hand-rolled URL and address parsing failsdevops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 markers, and the target they pass on goes through this item's parsers.
Strategic alignment
- Priority P2. The fixes:
- the new fix(ai): the embedding benchmark takes any endpoint from an MCP client and counts failed embeddings as results #954 rows guard the AI-key boundary against a future parser swap, and the origin helper keeps it failing closed on malformed settings;
- the credentials fix stops admin passwords going out over plain http by default;
- bracketed IPv6 and upper-case-scheme endpoints stop failing in the probe and the tracer, and upper-case schemes stop being doubled in the Ollama and credentials settings.
- Size: medium, about 25 sites in 18 files, plus two small new modules. No new dependency: stdlib
urllib.parseandipaddress, httpx2, and the OTLP exporter's own parsing. - Proposed milestone: backlog (P2), picked by the release-start fill. It runs in parallel with the other parse-with-the-library items once feat(ci): hand-rolled URL and address parsing fails
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 has landed. - Depends on feat(ci): hand-rolled URL and address parsing fails
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 (markers and ceiling). - Out of scope:
- the default-port tables at
core/validation.py:250andtelemetry/waterfall.py:139, which leave with fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898's resolve paths; - the valkey URL parsing in
config/settings.py:203-240, which is fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113; - typed URL settings, which are refactor(config): a settings field is the one declaration, and the option, env and config-show registries become views of it #1000;
- building the probe URLs from the origin's scheme (
probe.py:515,:527), which is fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111.
- the default-port tables at
- Merge order on shared files:
commands/k8s/networking.pylands after fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897, fix(k8s): tunnel sync and url setup still overwrite settings they should keep #794 and fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887, then fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111 and fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113;sandbox/probe.pylands after fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898, then fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111, which consumes the origin this item returns;ai/library/docs_ingester.pyis shared with fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898. If fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898's factory (PR A) has landed first, this item moves the crawler's client onto it. Otherwise fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 PR B moves it after this item;security/vault_broker.pyandsandbox/metrics.pyare shared with fix(security): URL credential masking uses urllib and httpx2, so passwords containing '@' and non-http schemes are masked and IPv6 hosts stay intact #1109, on other lines (vault_broker.py:71-88, :122, :162, :170-171 and metrics.py:446). The two run in parallel, and whichever lands second rebases;sandbox/models.py,sandbox/metrics.py,ai/spend/pricing.pyandai/mcp/server.pyare also edited by fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897, on other lines (for example_ALLOWED_LOCAL_HOSTSat metrics.py:398); whichever lands second rebases;config/constants.py:269is deleted here; refactor(ai): the model client, gateway, mcp and tool tables move out of config/ next to their owners #1027 leaves it in place for this item;- use changelog.d fragments only.
- Related: fix(ai): the embedding benchmark takes any endpoint from an MCP client and counts failed embeddings as results #954 and fix(ai): client timeouts, streamed response limits, model-resolution errors and dead round-robin state #960 (the key boundary and the URL-key errors this extends), refactor(config): a settings field is the one declaration, and the option, env and config-show registries become views of it #1000, fix(security): URL credential masking uses urllib and httpx2, so passwords containing '@' and non-http schemes are masked and IPv6 hosts stay intact #1109 (masks served_by where it enters, and shares two files).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
Placed in v0.2.32 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: URLs and host keys read by the library that dials, ollama hardening, and pull-request test-quality tooling. Position 1 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.
fix(security): URL and host:port reads use the sending client's parser (
dan-petty-bot commentedon Oct 9, 2026
What changed
#1506, merged into
release/v0.2.32as 77dadbb.34 file(s) changed.
How it was verified
Check runs at 192ff82:
Acceptance Criteria of
docs/agent/tasks/task-1112-url-and-host-port-client-parsers.md:_key_for_endpointfail closed on malformed URLs._parse_target_endpointreturnshttpx2.Originwith scheme, host, and port, and raisesValidationErroron malformed targets.argocd.urlandgrafana.urlwithConfigurationError.get_ollama_urlsnormalizes uppercase schemes and refuses scheme-less URLs._build_scrape_urlpreserves target paths and handles hosts starting with "http".VAULT://URIs.x@...) and accept valid multi-model specs.fix(k8s): service URLs bracket IPv6 hosts and proxy boundaries (#1111) (
feat(release): v0.2.32 (#1516)
fix(rag): name the Qdrant span server by host and port (#2705)