Skip to content

fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112

Closed

Description

@dan-petty

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-60 sniffs "://" and prefixes http://. The urlsplit gate right after it (:62-67) already refuses every scheme except http and https. The value comes from ai.ollama_urls, a base_url argument, or the OLLAMA_BASE_URL environment variable (:148).
  • k8s/credentials.py:26-33 (_clean_service_base_url) prefixes http:// to a scheme-less argocd.url or grafana.url, and mint_argocd_token (:232-245) and mint_grafana_token (:327-338) then send the admin password to it over plain http. The test is case-sensitive, so HTTPS://example.com becomes http://HTTPS://example.com. commands/argo.py:170 and argo/fleet.py:48 already refuse a scheme-less argocd.url; this path does not.
  • config/settings.py:503-514 (AIConfig.get_ollama_urls) turns HTTP://example.com:11434 into http://HTTP://example.com:11434.
  • sandbox/metrics.py:645-649 (_build_scrape_url) tests startswith("http"), so a target whose host name begins with "http" (httpbin.example.com:8080) gets no scheme at all, and HTTP://example.com becomes http://HTTP://example.com.
  • security/vulnerability_lookup.py:485-489, telemetry/instruments.py:207-212 and ai/spend/pricing.py:63-87 and :104-116 sniff "://" before calling urlparse/urlsplit; pricing.py:108 also tests startswith("http+unix://").

Default-port tables (443 if https else 80):

Hand-split host and port:

  • sandbox/probe.py:485-495 (_parse_target_endpoint) splits at the first ':', so [::1]:8080 raises ValueError. It also returns only (host, port), so the scheme is lost: an https:// target is probed over http at :515 and :527.
  • telemetry/tracer.py:1121-1134 (test_connection) strips schemes with str.replace and splits at the first ':', so grpc://[::1]:4317 and HTTP://example.com:4317 report "gRPC probe failed" for a reachable collector.
  • tracer.py:704-712 chooses gRPC with ":4317" in self.endpoint, which also matches http://example.com:43170 and any path containing :4317.
  • tracer.py:1101-1113 strips schemes with a str.replace chain before building OTLPSpanExporter, and sets insecure from a case-sensitive startswith("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 tests startswith("vault://"), so VAULT://secret/data/x comes 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:2050 refuses an MCP model string containing any of CONST_MODEL_ENDPOINT_MARKERS (("@", "://"), config/constants.py:269).
  • The splits, all at the first '@': ai/benchmark/runner.py:216-219, and ai/benchmark/embedding_runner.py:270-273, :306-309, :322 and :548-550.
  • embedding_runner.py:278-280 forces the ollama provider for any endpoint containing "ollama" or ":11434".

The docs crawler:

  • ai/library/docs_ingester.py:297-317 (_collect_child_links) compares raw netloc strings. From a crawl of https://example.com/, links to https://EXAMPLE.COM/a and https://example.com:443/b are dropped as foreign, while http://example.com/c (a downgrade) is followed.
  • Its directory slug (:233-237) is the path, or else the raw netloc. So https://user:[email protected] writes user:[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 returns httpx2.URL(value.strip()).origin, and returns None when that raises ValueError or httpx2.InvalidURL. The .strip() keeps today's _url_origin behaviour for padded values.
    • httpx2 2.13.0 is a direct, exact-pinned dependency (pyproject.toml:19), and Origin is public (it is in httpx2.__all__). It fills in default ports, gives IPv6 and IDN hosts one form (xn--bcher-kva.example.com and bücher.example.com give 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).
  • The crawler (docs_ingester.py:233-237, :274-276, :297-317).
    • It resolves links with httpx2.URL(current).join(link), skips any link that raises httpx2.InvalidURL or ValueError (a tab raises InvalidURL), 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%2e to /... So the directory slug is used only when pathlib resolves it to a direct child of the ingest root ((root / slug).resolve().parent == root.resolve()); otherwise the host is the slug. An offline probe showed https://example.com/%2e%2e and https://example.com/%2E failing that test, and https://example.com/a/%2e%2e (slug a_..) 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.
  • host:port reads.
    • probe.py:485-495: _parse_target_endpoint returns an httpx2.Origin instead 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 bare host[:port] (a result with no scheme) gets its host and port with scheme http and port 80 when absent, built as httpx2.Origin(httpx2.URL(scheme="http", host=host, port=port)). A target with no host or a malformed port is refused with a ValidationError naming the target. Today http://:8080 silently probes 127.0.0.1, and example.com:abc raises a bare ValueError from int().
    • _resolve_probe_target (probe.py:392-404) returns origins for instance port bindings too (scheme http, which is what today's probe URLs assume). The loop at :455 passes origin.host and origin.port to _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_port and builds the probe URLs at :515 and :527 from origin.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 .host and .port. No origin returns False, as an unparsable URL does today.
    • tracer.py:1121-1134 uses the shared reader with .port or 4317, because 4317 is the OTLP gRPC default whatever scheme is written. tracer.py:704-712 decides gRPC from the parsed scheme (grpc) and port (4317), and test_connection follows self.protocol alone.
  • Shared "URL or bare authority" reader (one function, used by vulnerability_lookup.py:485-489, instruments.py:207-212, pricing.py:63-87 and :104-116, metrics.py:645-649 and the bare forms above).
    • ipaddress.ip_address(s) first (a bare IPv6 literal goes to urlsplit in its bracketed RFC 3986 form). Then urlsplit(s), then urlsplit("//" + s) when that found no host. The // prefix is needed because, as the urllib.parse documentation states, a netloc is recognised only when introduced by //.
    • The fallback applies only when urlsplit(s).netloc is empty. When urlsplit(s) found a scheme, the fallback is kept only if it found a port. example.com:8080 reads as scheme example.com with path 8080, a bare host and port. In https:// and http:///x, by contrast, the fallback reads the scheme name as a host with no port: an offline probe showed urlsplit("//https://").hostname == "https". So http://:8080, https:// and http:///x have 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 the ValueError reaches 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_ip gives the host.
    • It returns the SplitResult that has a host, or None. .port is read only by callers that need it, so a caller that reads only .hostname never sees a port error, as today.
    • pricing.py:108 compares urlsplit(s).scheme.
  • Scrape URL (metrics.py:645-649). _build_scrape_url reads the target with the shared reader and builds its result with httpx2.URL(scheme=..., host=..., port=..., path=...).
    • The scheme is the target's, or http for 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/prefix with metrics still gives http://example.com:9100/prefix/metrics.
    • A target with no host, or with a scheme other than http or https, is refused.
  • sandbox/models.py:62-82: ipaddress.ip_address(s) (a bare address, returned as is), then ipaddress.ip_network(s, strict=False) (a CIDR, returned in its str form), then the shared reader. The ipaddress steps must come first, because urlsplit("//2001:db8::1") reads the host as 2001.
    • 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, as host:port/path, with userinfo, and with empty or malformed ports. It found three kinds of difference, all intended:
      • Example.COM comes back lowercased;
      • [email protected]:22 gives example.com;
      • an empty port (example.com:, example.com:/x) gives '', so such a whitelist entry is refused as invalid (models.py:111-113 and :122-124) instead of being accepted under its host.
  • vault_broker.py:37-58: urllib.parse.urldefrag for the key, and urlsplit(...).scheme == "vault" (which also handles VAULT://). Both validate_no_path_traversal calls stay. Do not use pydantic AnyUrl here: an offline probe showed it resolves vault://secret/data/../x to vault://secret/x, which hides the traversal from the check.
  • ollama.py:52-60: delete it. The urlsplit gate at :62-67 then refuses scheme-less values too, because urlsplit reads example.com:11434 as scheme example.com, and its message already asks for http or https. Add a refusal of an empty netloc to the same gate, after the scheme test, so file:///etc/passwd keeps its scheme error.
  • credentials.py:26-33 and get_ollama_urls: parse with urlsplit. 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. Return urlunsplit(...), so HTTP:// comes back as http://.
  • OTLP exporter (tracer.py:1101-1113): pass the endpoint to OTLPSpanExporter(endpoint=self.endpoint, ...) unchanged. The exporter (opentelemetry-exporter-otlp-proto-grpc 1.44.0, pinned at pyproject.toml:39) parses it itself in exporter.py:314-326: it takes the netloc when a scheme is present and forces TLS for https. Keep insecure explicit, from urlsplit(endpoint).scheme != "https".
  • One parse_model_spec replaces the five splits.
    • model@endpoint is the project's own --models syntax; no library parses it, so str.partition stays 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, because ai/benchmark/__init__.py imports 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_url reads as a URL, or that httpx2 cannot read (see the key questions). CONST_MODEL_ENDPOINT_MARKERS is deleted.
  • Provider for an explicit endpoint (embedding_runner.py:278-280): compare the endpoint's origin with the origins of the configured ai.ollama_urls entries (the raw list, not get_ollama_urls, which now refuses) and gateway_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_url is https://example.com:abc/v1;
    • when the configured api_base_url or gateway_url is localhost:8000/v1.
  • Crawl. tests/test_docs_ingester.py:218-253 gains cases. From https://example.com/root:
    • links to https://EXAMPLE.COM/a and https://example.com:443/b are followed;
    • http://example.com/c, https://example.com\@192.0.2.1/d and a link containing a tab are not;
    • a start URL of https://user:[email protected] gives a slug that contains neither user nor token;
    • with no output directory given, a start URL of https://example.com/%2e%2e writes its chunks into a direct child of the ingest root, not into the root or its parent.
  • 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-client rg criterion. 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_endpoint returns an httpx2.Origin. As (scheme, host, port):
    • https://example.com gives (https, example.com, 443);
    • 127.0.0.1:9090 gives (http, 127.0.0.1, 9090);
    • localhost gives (http, localhost, 80);
    • [::1]:8080 gives (http, ::1, 8080);
    • HTTPS://example.com:8443 gives (https, example.com, 8443).
    • http://:8080 and example.com:abc raise a ValidationError naming the target.
    • tests/test_sandbox_probe.py:493-507, which unpacks a pair today, is rewritten to these rows.
    • The caller at probe.py:403 and 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_reachability tests in tests/test_k8s_bootstrap.py:200-215 pass unchanged.
  • Tracer, with socket.create_connection mocked:
    • test_connection dials ("::1", 4317) for grpc://[::1]:4317 and ("example.com", 4317) for HTTP://example.com:4317;
    • http://example.com:43170 with no protocol set gets http/json.
  • Exporter. OTLPSpanExporter receives the endpoint unchanged:
    • insecure=True for grpc://example.com:4317, http://example.com:4317 and a bare example.com:4317;
    • insecure=False for https:// and HTTPS://.
    • tests/test_telemetry.py:426-477 is updated to match.
  • Credentials. A scheme-less argocd.url (example.com) fails with an error naming argocd.url, and the mocked httpx2.Client.post is never called. HTTPS://example.com is used as https://example.com. The same holds for grafana.url. tests/test_k8s_credentials.py:86-216 gains these rows.
  • Ollama URLs.
    • get_ollama_urls returns http://example.com:11434 for HTTP://example.com:11434, and refuses example.com:11434 naming ai.ollama_urls. tests/test_ai_client_security.py:130-135 gains both rows.
    • normalize_ollama_base_url("example.com:11434") raises InvalidURLError instead 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.com gives http://example.com/metrics.
    • [::1]:8080 gives http://[::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.com is 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.COM gives example.com, and [email protected]:22 gives example.com;
    • http://:8080, https:// and http:///x give '', as today (not http or https);
    • example.com: and example.com:/x give '', and _validate_public_whitelist_item refuses 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_spec is the only code that splits model@endpoint.
    • parse_model_spec("m@https://u:[email protected]/v1") == ("m", "https://u:[email protected]/v1"), parse_model_spec("m") == ("m", None), and parse_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@ and https://example.com/bge-m3, and accept bge-m3,nomic-embed-text and hf.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 the x@ row and the two accepted rows.
  • Provider. tests/test_embedding_benchmark.py:227-240 is updated. With ai.provider=gateway:
    • an embedding benchmark whose --servers origin matches neither a configured ai.ollama_urls entry nor gateway_url refuses with a --provider hint and sends no request;
    • an endpoint whose origin equals a configured Ollama URL runs as ollama;
    • a configured ai.ollama_urls entry example.com:11434 (no scheme) matches nothing and raises nothing;
    • "ollama" in a host name no longer chooses the provider.
  • 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.py prints 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.py prints nothing.
    • rg -n '"@" in|partition\("@"\)|split\("@"\)' src/devops_cli/ai/benchmark src/devops_cli/ai/mcp src/devops_cli/commands/benchmark.py prints only lines inside ai/benchmark/model_spec.py.
    • rg -n 'netloc|urljoin|urlparse' src/devops_cli/ai/library/docs_ingester.py prints 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, no net-* marker is left on the lines this item rewrites, and 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's marker ceiling drops by the number removed. Among them:
      • net-scheme-in and net-scheme-affix;
      • net-port-table at runner.py:60, networking.py:223 and probe.py:490;
      • net-url-build at ollama.py:60 (f"http://{clean_url}") and metrics.py:647 (f"http://{target}");
      • net-normalise at sandbox/models.py:82 (strip("[]"));
      • net-address-list at config/constants.py:269.
  • Release.
    • Tests stay offline: no DNS, no sockets.
    • No dependency is added.
    • uv run devops ci passes.
    • A changelog.d fragment lists the fixes under ### Fixed. Under ### Changed it lists:
      • the refusal of a scheme-less argocd.url, grafana.url, ai.ollama_urls or OLLAMA_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:).

Key questions

Strategic alignment

Activity

  1. added
    type/security
    scope/ai
    scope/k8s
    scope/security
    scope/telemetry
    priority/p2-medium
    on Oct 3, 2026
  2. added this to the v0.2.32 milestone on Oct 8, 2026
  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    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.

  4. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1506, merged into release/v0.2.32 as 77dadbb.

    Summary

    Fixes #1112.

    URL, endpoint, and authority reads across benchmark runners, docs ingester, telemetry exporters, vulnerability lookups, and pricing now use sending client parsers (httpx2.URL and read_url_or_authority), preventing scheme sniffing and port mismatch bugs.

    34 file(s) changed.

    How it was verified

    Check runs at 192ff82:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1112-url-and-host-port-client-parsers.md:

    • Key trust tests verify backslash mismatches fail closed, IDN origins match, and unparseable URLs return empty keys without raising.
    • Direct calls to _key_for_endpoint fail closed on malformed URLs.
    • Docs ingester follows links on same origin, skips scheme downgrades and invalid URLs, and confines directory slugs to children of the ingest root.
    • Network probe _parse_target_endpoint returns httpx2.Origin with scheme, host, and port, and raises ValidationError on malformed targets.
    • OTLP telemetry client preserves endpoints, dials correct host/port, and infers protocol from port 4317.
    • Credentials minting refuses scheme-less argocd.url and grafana.url with ConfigurationError.
    • get_ollama_urls normalizes uppercase schemes and refuses scheme-less URLs.
    • _build_scrape_url preserves target paths and handles hosts starting with "http".
    • Sandbox whitelist host extraction normalizes case and rejects empty port entries.
    • Vault broker parses uppercase VAULT:// URIs.
    • MCP tools reject endpoint overrides (x@...) and accept valid multi-model specs.
    • Embedding runner selects provider based on origin matching or refuses unknown endpoints under gateway provider.
    • No forbidden parsing constructs remain across modified files.
    • All automated tests pass offline without external network dependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/aiscope/k8sscope/securityscope/telemetrytype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions