Repository navigation
Description
Problem Description
devops ai prewarm and devops ai preload name each Ollama server by its configured URL text. The MCP tool ai_prewarm returns that text to the model that calls it. So the model learns the URLs of ai.ollama_urls, with any user name or query value in them.
Lines cited at 5bb1ed0f (the same lines are on main after 39fae855):
src/devops_cli/ai/client/ollama.py:80and:83use the raw URL as the key of the result dictionary.src/devops_cli/commands/ai.py:710puts that dictionary in thenodesof the JSON and YAML output.src/devops_cli/commands/ai.py:722-729print the raw URL in the table output, with a success or a failure mark.src/devops_cli/commands/ai.py:537-541(devops ai preload) print the raw URL in the same way.mask_secretshides only some forms. Auser:passwordform and a user name with a port are masked. A user name with no password and no port shows in full (fix(security): redact_text leaves the user name of a URL with no password, so a token used as the user name shows in text #2662). A query value always shows in full.
The rule of #1110 and #2481 is different. A reply names a server by its host and port, never by a configured URL.
A second problem is in the same command. src/devops_cli/commands/ai.py:832-840 emit AI_PREWARMS_TOTAL with the label model=str(target_model). The calling model sets model in the MCP tool, so the label has no bound on its values. This is true before the change of #2637. The label values are a risk for a metrics backend, and a person should bound them.
Reproduction Steps
- Use a temporary
HOME, the null keyring,ai.providerset toollamaand a loopback listener on127.0.0.1. - Set
ai.ollama_urlstohttp://127.0.0.1:<port>/?x=FAKE-2637-fifth. - Call the MCP tool
ai_prewarmwith no argument, through a FastMCPClient. - Read the reply.
- Set
ai.ollama_urlstohttp://[email protected]in a test with the shared network fakes, and read the reply again.
Expected vs Actual Behavior
Expected: the reply names each server as host:port, as the benchmarks do after #2481. The JSON nodes keys have the same form. The label model of the counter has a bounded set of values.
Actual: the reply shows the URL as it is.
Environment Diagnostics
- DevOps CLI Version: 0.16.3 (
mainat5bb1ed0f) - Python Version: 3.14.10
- OS & Architecture: Linux x86_64
- Execution Environment: DevContainer
Logs, Traces, or Terminal Output
✓ http://127.0.0.1:58775/?x=FAKE-2637-fifth: confirmed HTTP 200 (keep_alive=1h)
✓ http://[email protected]: confirmed HTTP 200 (keep_alive=1h)
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Proposed design
Problem statement
The devops ai prewarm and devops ai preload commands print the full configured URL of each Ollama server. The MCP tool ai_prewarm returns that text to the calling model. A user name, password, or query value in the URL is exposed. The rule from #1110 and #2481 says a reply names a server by host and port, never by a configured URL. A second defect is in the same command: the AI_PREWARMS_TOTAL metric uses the model-supplied string as the model label, with no bound on its values. This is a risk for a metrics backend.
Acceptance criteria
Requirement: Prewarm output uses host:port
The devops ai prewarm output SHALL name each Ollama server by its host and port only, and SHALL NOT include a user name, password, or query value from the configured URL.
Scenario: URL with user name and query
- WHEN ai.ollama_urls is set to
http://user:[email protected]:8080/?x=secretand devops ai prewarm is run - THEN the output shows example.net:8080 and does not show user, pass, or x=secret
Requirement: Preload output uses host:port
The devops ai preload output SHALL name each Ollama server by its host and port only, and SHALL NOT include a user name, password, or query value from the configured URL.
Scenario: URL with user name and no port
- WHEN ai.ollama_urls is set to
http://[email protected]and devops ai preload is run - THEN the output shows example.net:80 and does not show FAKE-2637-third
Requirement: MCP tool nodes use host:port keys
The ai_prewarm MCP tool response SHALL use host:port as the key in the nodes dictionary, and SHALL NOT use the full configured URL as a key.
Scenario: MCP tool call with query in URL
- WHEN the MCP tool ai_prewarm is called and ai.ollama_urls contains
http://127.0.0.1:58775/?x=FAKE-2637-fifth - THEN the nodes dictionary key is 127.0.0.1:58775 and the value does not contain x=FAKE-2637-fifth
Requirement: Model label is bounded
The AI_PREWARMS_TOTAL metric model label SHALL contain only characters from the set a-z, A-Z, 0-9, dot, hyphen, and underscore, and SHALL NOT exceed 128 characters.
Scenario: Model name with special characters
- WHEN the MCP tool is called with a model value of my/model
@v2.0!beta - THEN the emitted label value is my/model_v2.0_beta and is at most 128 characters
Existing Tool Considered
No check has run. The need is covered by Python standard library urllib.parse.urlparse for URL decomposition into host and port. The project builds a small sanitization function for the metric label. The written cost is a helper of about 5 lines for host:port extraction and a sanitizer of about 3 lines for the label, plus test updates. Total build and maintenance cost is under 50 tokens of new code.
Key questions
- Which standard library or tool extracts host and port from a URL string?: Python standard library urllib.parse.urlparse returns a ParseResult with .hostname and .port attributes. It handles all URL forms including user:password, query strings, and missing ports (defaulting to 80 for http, 443 for https). (proposed)
- Chosen: urllib.parse.urlparse. Standard library, handles all URL forms, no dependency, already used in the project.
- Rejected: Regular expression. Fragile, does not handle edge cases like IPv6 brackets or missing ports correctly.
- Rejected: httpx.URL. Adds a dependency for a task the standard library already covers.
- Where in the code is the host:port transformation applied?: At the source in src/devops_cli/ai/client/ollama.py where the result dictionary is built (lines 80 and 83), so all consumers (JSON, YAML, table, MCP tool) receive the sanitized key. The table output in src/devops_cli/commands/ai.py (lines 722-729 and 537-541) also uses the dictionary key, so it is fixed by the same change. (best practice) [sources: src/devops_cli/ai/client/ollama.py:80, src/devops_cli/ai/client/ollama.py:83, src/devops_cli/commands/ai.py:710, src/devops_cli/commands/ai.py:722, src/devops_cli/commands/ai.py:537]
- Chosen: Transform at the source in ollama.py. One change point fixes all consumers: JSON, YAML, table, and MCP tool output.
- Rejected: Transform at each output site in ai.py. Multiple change points, higher risk of missing one, and the dictionary key still leaks in JSON/YAML.
- How is the model label of AI_PREWARMS_TOTAL bounded?: Sanitize the value to the character set [a-zA-Z0-9._-] and cap the length at 128 characters. Characters outside the set are replaced with an underscore. This follows the Prometheus and OpenTelemetry guidance that label values must be bounded to protect the metrics backend. (proposed)
- Chosen: Sanitize to safe charset and cap length. Bounded, deterministic, preserves readability, follows Prometheus and OpenTelemetry guidance.
- Rejected: Use a fixed allow-list of model names. Brittle: breaks when a new model is added. Requires maintenance of the list.
- Rejected: Remove the label. Loses the ability to break down prewarm counts by model, which is useful for operations.
- Rejected: Hash the value. Unreadable in dashboards and alerts. A person cannot identify the model from a hash.
- Does the existing mask_secrets function need to be changed?: No. The fix removes the full URL from the output entirely. The output shows only host:port, which contains no credential material. mask_secrets is not needed for this path. [sources: src/devops_cli/commands/ai.py:722, src/devops_cli/commands/ai.py:537]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 29, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
The change stops credentials and query values from appearing in terminal output and MCP tool replies.Credentials and query values are visible in terminal output and returned to the calling model.Exposed credentials in output and MCP replies are a direct security risk to users.The change touches multiple output paths (JSON, YAML, table, MCP) and adds a metric label bound.Both name Ollama servers by host:port instead of the configured URL, but #2481 covers the benchmark command and the candidate covers prewarm and preload.fix(ai): the MCP prewarm tool takes no URL from the model (#2677)
devops-cli-service commentedon Oct 29, 2026
Status set to Ready at 9e8317b (see proposed design in issue body).
chore(main): release 0.21.4 (#2741)
fix(ai): bound the number of prewarm model label values (#6391)