Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ All code authored in or evaluated by DevOps CLI must strictly adhere to the foll
10. **Bounded Error Detail**: Cap each external value in an exception `details` dictionary or a structured log at 256 characters (CWE-209, CWE-400).
11. **MCP Tool Inputs**: A URL or host that a model gives to an MCP tool is untrusted input, not configuration. A tool publishes no option for it, and queries the service that the configuration names. `_PATH_PARAM_RESTRICTIONS` in `src/devops_cli/ai/mcp/generator.py` sets the options that a tool publishes. A credential goes only to the origin that the configuration names, whatever the egress level is. `_key_for` in `src/devops_cli/ai/gateway.py` applies this rule to the AI API key. A tool that publishes such an option is a defect. A file path that a model gives is untrusted input too: a tool publishes no option for a path that the command writes or reads, unless a path helper confines the path (`safe_resolve_subpath` in `src/devops_cli/core/paths.py`).

The `--url` option of the `devops valkey` commands is an accepted case. A person types it, and no model gives the URL. So `valkey.password` goes to the host that the person names. Six of the nine `devops valkey` commands are MCP tools: `valkey_ping`, `valkey_stats`, `valkey_info`, `valkey_get`, `valkey_set` and `valkey_flush`. These tools publish no URL option. The commands `valkey keys`, `valkey backup` and `valkey cli` are not MCP tools.
The `--url` option of the `devops valkey` commands is an accepted case. A person types it, and no model gives the URL. So `valkey.password` goes to the host that the person names. Five of the nine `devops valkey` commands are MCP tools: `valkey_ping`, `valkey_stats`, `valkey_info`, `valkey_get` and `valkey_flush`. `valkey set` is not an MCP tool (rule 12). These tools publish no URL option. The commands `valkey keys`, `valkey backup` and `valkey cli` are not MCP tools.

The `streamable-http` transport is a network listener. See [MCP Server on the Network](#mcp-server-on-the-network).

12. **MCP Tool Secrets**: A model writes the arguments of an MCP tool call. A secret in an argument passes through the model context, the provider, the LLM cache and the run trace, and the model can send it to another tool. So a tool publishes no parameter that takes a secret value (a password, a token, an API key or a private key). A credential for a call is carried on the connection, as a header that the harness sets, or the server reads it from its configuration, or it is an opaque reference that the server resolves from the secret store, such as `keyring:<name>` for the OIDC token of `docker_sign`. A tool never returns or logs a credential, so `vault_get` publishes no `show` option, and `vault_set` is not a tool. `CONST_MCP_SECRET_PARAMETER_WORDS` in `src/devops_cli/config/constants.py` lists the words that make a parameter name suggest a secret. `tests/ai/mcp/test_mcp_tool_secrets.py` reads the published schema of every tool and fails on a text parameter whose name holds one of them. `CONST_MCP_SECRET_PARAMETER_ALLOWLIST` names the parameters that hold no secret value, such as the name of a Kubernetes Secret. A new entry needs a reason, and the test fails on an entry that matches no parameter. `RunTrace` hides the value of an argument under such a name, and `mask_secrets` is the second guard. `ArgumentValueLogFilter` keeps all arguments out of the FastMCP log.
12. **MCP Tool Secrets**: A model writes the arguments of an MCP tool call. A secret in an argument passes through the model context, the provider, the LLM cache and the run trace, and the model can send it to another tool. So a tool publishes no parameter that takes a secret value (a password, a token, an API key or a private key). A credential for a call is carried on the connection, as a header that the harness sets, or the server reads it from its configuration, or it is an opaque reference that the server resolves from the secret store, such as `keyring:<name>` for the OIDC token of `docker_sign`. A tool never returns or logs a credential, so `vault_get` publishes no `show` option, and `vault_set` is not a tool. `CONST_MCP_SECRET_PARAMETER_WORDS` in `src/devops_cli/config/constants.py` lists the words that make a parameter name suggest a secret. `tests/ai/mcp/test_mcp_tool_secrets.py` reads the published schema of every tool and fails on a text parameter whose name holds one of them. `CONST_MCP_SECRET_PARAMETER_ALLOWLIST` names the parameters that hold no secret value, such as the name of a Kubernetes Secret. A new entry needs a reason, and the test fails on an entry that matches no parameter. A name word cannot find a free-text parameter that is copied into an environment, a file or a store, so `valkey_set` is not a tool and `sandbox_deploy` publishes no `env` (the `denied` key of `_PATH_PARAM_RESTRICTIONS` in `src/devops_cli/ai/mcp/generator.py` omits an option). `CONST_MCP_FREE_TEXT_SINK_PARAMETER_NAMES` lists the names `env`, `values`, `value` and `data`. `CONST_MCP_FREE_TEXT_SINK_ALLOWLIST` names each published parameter with such a name that holds no secret, with its reason, and the same test fails on a stale entry. `RunTrace` hides the value of an argument under such a name, and `mask_secrets` is the second guard. `ArgumentValueLogFilter` keeps all arguments out of the FastMCP log.

13. **Hosted Models**: The LiteLLM gateway serves five groups that call a provider outside the cluster: `gemini-3.8-flash`, `claude-sonnet-5-5`, `claude-haiku-5-5`, `deepseek-v4.1-flash-1017` and `deepseek-v4.1-flash` (the last two through OpenRouter, which picks a third-party provider and is asked to skip providers that store or train on prompts). A prompt sent to one of them leaves the cluster, and the provider bills each token. So no pool names a hosted group, no fallback sends a group that is not hosted to a hosted group, and a request reaches a provider only when its caller names a hosted group. The Service config names `deepseek-v4.1-flash-1017` for `ai.model`, the task `chat` and each task of a roadmap job except `intake`, `retitle`, `refine` and `alternatives`, which name the local `qwen3.8:27b` (`k8s/devops/configmap.example.yaml`, owner decisions of 2026-11-07, #3874, 2026-11-10, #4369, 2026-11-15 and 2026-11-16; each job has a task of its own since #5903). So the code of the repositories of the Service, which can be private, leaves the cluster to OpenRouter in the prompts of a step, and so do the titles and bodies of the issues in the prompts of the stage job and chat. A job task, such as `stage` or `refine`, names `claude-sonnet-5-5` only in a trial: its prompts, which hold the issue and the repository text that the job reads, then leave the cluster to Anthropic. The ladders of the `edit` and `repair` steps of the implement job name only DeepSeek, one tier each (owner decision of 2026-11-10, #4371): a Sonnet tier there is a later trial, and its prompts, which hold repository code, would leave the cluster to Anthropic. Project text and project code can go to a hosted provider, Jev included, but a secret or personal data, such as an email address, never goes. The owner holds `claude-sonnet-5-5` since 2026-11-11: run no trial, eval or comparison with it until the owner lifts the hold. The embedding slot and the tasks `intake`, `retitle`, `refine` and `alternatives` stay in the cluster. Two fallbacks link hosted groups. `claude-sonnet-5-5` to `deepseek-v4.1-flash-1017` (#3152) sends the prompt of a failed Claude call to OpenRouter, not to Anthropic. `deepseek-v4.1-flash-1017` to `deepseek-v4.1-flash` (#5564) sends the prompt of a failed call to the same provider, OpenRouter, with the same filters. The keys are optional keys of the Secret `llm/llm-gateway-secrets` (keyring: `gemini.api_key`, `anthropic.api_key`, `openrouter.api_key`). The gateway NetworkPolicy admits TCP 443 to public addresses and to no private or metadata range. A Claude group sets its prices, drops the sampling parameters that its API refuses, and sets `supports_native_structured_output` and `supports_response_schema`, or a structured call becomes a forced tool call that Sonnet 5.5 refuses (#3140). TypeSafe Jev (`typesafe/jev-1.14`) is no group: the gateway passes `POST /v1/systemone` to the System One endpoint of OpenRouter with the OpenRouter key of the gateway, for a caller that holds a valid gateway key (#4289). A prompt sent to it leaves the cluster, and the pass-through cannot set `data_collection`, so the privacy setting of the OpenRouter account applies. `tests/ai/benchmark/test_k8s_llm_gateway.py` fails when any of this breaks. `tests/ai/test_jev_gateway_route.py` fails when the client path and the pass-through differ.

Expand Down
17 changes: 0 additions & 17 deletions docs/MCP_TOOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ The `devops-cli` FastMCP server exposes DevOps automation and AI review capabili
| [`valkey_get`](#valkey_get) | `true` | Retrieve string value stored at key. |
| [`valkey_info`](#valkey_info) | `true` | Inspect server configuration, memory allocation, and operational metrics. |
| [`valkey_ping`](#valkey_ping) | `true` | Test connection and measure round-trip latency to the Valkey server. |
| [`valkey_set`](#valkey_set) | `false` | Set string value of key with optional expiration TTL. |
| [`valkey_stats`](#valkey_stats) | `true` | Display quick diagnostic summary of server health, memory, and keys. |
| [`vault_get`](#vault_get) | `true` | Fetch a secret from Vault, or from the OS keyring when Vault cannot answer. The keyring answers only with no usable token, when Vault has no value at the path, or when Vault is unreachable; never after Vault rejects the token. The output names the source. |
| [`vault_status`](#vault_status) | `true` | Inspect HashiCorp Vault cluster health and initialization status. The health endpoint needs no token, and none is sent. The Token row names where the token other commands would use comes from, and why a stored token is not used for this address. |
Expand Down Expand Up @@ -2005,7 +2004,6 @@ Deploy an isolated background container sandbox with security containment.
| `network_mode` | `string` | No | - | Multi-tier network mode: isolated | sandbox_namespace | public_whitelist | local_whitelist | bridge |
| `public_whitelist` | `string` | No | - | Comma-separated public domains/IPs allowed for egress |
| `local_whitelist` | `string` | No | - | Comma-separated local URLs/IPs allowed for egress |
| `env` | `array[string]` | No | - | Environment variable in KEY=VALUE format. |
| `seccomp_profile` | `string` | No | - | Seccomp profile file for the container, in the JSON format of `docker --security-opt seccomp=<file>`, in place of the engine's default profile. Its defaultAction must refuse the system calls that it does not name. |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

Expand Down Expand Up @@ -2444,21 +2442,6 @@ Test connection and measure round-trip latency to the Valkey server.

*No parameters required.*

### `valkey_set`

Set string value of key with optional expiration TTL.

**Annotations:** `readOnlyHint: false`

**Parameters:**

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `key` | `string` | Yes | - | Key name to set |
| `value` | `string` | Yes | - | Value to associate with key |
| `ex` | `integer` | No | - | Expiration timeout in seconds |
| `dry_run` | `boolean` | No | `False` | Preview execution plan without mutating external state. |

### `valkey_stats`

Display quick diagnostic summary of server health, memory, and keys.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- **A path restriction takes a `denied` set, and the generator omits each parameter that it names.**: It removes `env` from `sandbox_deploy` and keeps every other option of the command published, so the tool keeps its useful work.
- **The `valkey_set` tool leaves the exposure table and the restriction table.**: Its `value` argument is the cache value itself and the command resolves no reference from the secret store, so the tool cannot publish it and stay within rule 12.
- **Tests referencing `valkey_set` update to `tf_apply` or add exclusion entries.**: `test_export_schemas_command` in `tests/commands/test_mcp_tools_and_schema_export.py` tests `tf_apply.json`. Contract tests in `tests/ai/mcp/test_mcp_tool_registry.py` and `tests/ai/mcp/test_mcp_argument_refusal.py` test `tf_apply`. `mcp_command_exclusions` in `tests/ai/mcp/test_mcp_exposure_table.py` records `("valkey", "set")` so command coverage tests pass.
- **Tests referencing `valkey_set` update to `tf_apply` or remove `valkey_set` from MCP tool lists.**: `test_export_schemas_command` in `tests/commands/test_mcp_tools_and_schema_export.py` tests `tf_apply.json`. Contract tests in `tests/ai/mcp/test_mcp_tool_registry.py` and `tests/ai/mcp/test_mcp_argument_refusal.py` test `tf_apply`. `tests/commands/test_valkey.py` removes `valkey_set` from `VALKEY_TOOL_PARAMETERS` and `VALKEY_TOOL_CALLS`, `tests/roadmap/stage/test_stage_run_allowlist.py` updates `ROW_COUNT`, and the MCP tool listing snapshot removes `valkey_set` and `sandbox_deploy.env`. Any command omitted from `CONST_MCP_EXPOSURE_TABLE` is excluded automatically.
- **The free-text guard fails on the exact names `env`, `values`, `value` and `data`, with an allow-list that carries a reason.**: It mirrors the guard of #3222, so one pattern covers both guards, and it avoids the false positives of a substring match on names such as `field_value`.
- **`k8s_diff_helm.values` is allow-listed with an explicit reason.**: The parameter takes paths to local YAML files to override Helm values, not arbitrary secret payloads.
- **The guard also fails on an allow-list entry that matches no published parameter.**: A stale entry would otherwise allow a name that a later tool publishes for no reason.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ The MCP guard of #3222 finds a secret parameter by the words of its name, so a p
- `_PATH_PARAM_RESTRICTIONS` in `src/devops_cli/ai/mcp/generator.py` takes an optional `denied` set, and `_introspect_command_parameters` omits each parameter that it names.
- The `("sandbox", "deploy")` restriction denies `env`, so the tool publishes no `env` parameter.
- The `("valkey", "set")` row leaves `CONST_MCP_EXPOSURE_TABLE` and `_PATH_PARAM_RESTRICTIONS`, so the server publishes no `valkey_set` tool.
- `tests/ai/mcp/test_mcp_exposure_table.py` adds `("valkey", "set")` to `mcp_command_exclusions`, and `test_export_schemas_command` in `tests/commands/test_mcp_tools_and_schema_export.py` verifies `tf_apply.json` instead of `valkey_set.json`.
- `tests/ai/mcp/test_mcp_tool_registry.py` drops `valkey_set` from `floor_expected_false`, and `tests/ai/mcp/test_mcp_argument_refusal.py` tests input validation and log masking with `tf_apply`.
- `tests/ai/mcp/test_mcp_exposure_table.py` handles `denied` restrictions when comparing schema properties, `tests/roadmap/stage/test_stage_run_allowlist.py` updates `ROW_COUNT` for the dropped row, `tests/commands/test_mcp_tools_and_schema_export.py` verifies `tf_apply.json` instead of `valkey_set.json`, and `tests/commands/test_valkey.py` removes `valkey_set` from its MCP Valkey tool lists.
- `tests/ai/mcp/test_mcp_tool_registry.py` drops `valkey_set` from `floor_expected_false`, `tests/ai/mcp/test_mcp_argument_refusal.py` tests input validation and log masking with `tf_apply`, and `tests/ai/mcp/__snapshots__/test_mcp_tool_listing/test_the_tool_listing_matches_the_snapshot.json` removes `valkey_set` and `sandbox_deploy.env`.
- `CONST_MCP_FREE_TEXT_SINK_PARAMETER_NAMES` and `CONST_MCP_FREE_TEXT_SINK_ALLOWLIST` in `src/devops_cli/config/constants.py` name the free-text sink names and the allowed parameters with a reason.
- `CONST_MCP_FREE_TEXT_SINK_ALLOWLIST` names `("k8s_diff_helm", "values")` with its reason.
- A new guard test in `tests/ai/mcp/test_mcp_tool_secrets.py` fails on an unallowed sink parameter, and on an allow-list entry that matches no parameter.
- `SECURITY.md` rules 11 and 12 state the new guard and list `valkey set` among commands that are not MCP tools.
- `devops docs generate --sync-readme` updates `docs/MCP_TOOLS.md`.
- `uv run devops docs generate` updates `docs/MCP_TOOLS.md`.
- The change alters what an MCP client observes, so it carries a spec delta and `skip_specs` is false.
- The change fits one pull request.

Expand All @@ -31,9 +31,9 @@ None.

## Impact

- Code: `src/devops_cli/ai/mcp/generator.py`, `src/devops_cli/config/constants.py`
- Code: `src/devops_cli/ai/mcp/generator.py`, `src/devops_cli/config/constants.py`, `src/devops_cli/roadmap/stage/stage_run_allowlist.py`
- Documents: `SECURITY.md`, `docs/MCP_TOOLS.md`
- Tests: `tests/ai/mcp/test_mcp_exposure_table.py`, `tests/commands/test_mcp_tools_and_schema_export.py`, `tests/ai/mcp/test_mcp_tool_secrets.py`, `tests/ai/mcp/test_mcp_tool_registry.py`, `tests/ai/mcp/test_mcp_argument_refusal.py`
- Tests: `tests/ai/mcp/test_mcp_exposure_table.py`, `tests/commands/test_mcp_tools_and_schema_export.py`, `tests/commands/test_valkey.py`, `tests/ai/mcp/test_mcp_tool_secrets.py`, `tests/ai/mcp/test_mcp_tool_registry.py`, `tests/ai/mcp/test_mcp_argument_refusal.py`, `tests/roadmap/stage/test_stage_run_allowlist.py`, `tests/ai/mcp/__snapshots__/test_mcp_tool_listing/test_the_tool_listing_matches_the_snapshot.json`

## Feasibility

Expand All @@ -42,7 +42,7 @@ None.
- A check of all published FastMCP tools finds three parameters matching the free-text sink names `env`, `values`, `value`, `data`: `sandbox_deploy.env`, `valkey_set.value`, and `k8s_diff_helm.values`.
- `sandbox_deploy.env` is omitted through `denied`, and `valkey_set` is removed.
- `k8s_diff_helm.values` accepts paths to values YAML files and stays published with an entry in `CONST_MCP_FREE_TEXT_SINK_ALLOWLIST`.
- `tests/ai/mcp/test_mcp_tool_registry.py` and `tests/ai/mcp/test_mcp_argument_refusal.py` and `tests/ai/mcp/test_mcp_exposure_table.py` and `tests/commands/test_mcp_tools_and_schema_export.py` reference `valkey_set` and are updated to use `tf_apply` and list `valkey set` under exclusions.
- `tests/ai/mcp/test_mcp_tool_registry.py`, `tests/ai/mcp/test_mcp_argument_refusal.py`, `tests/ai/mcp/test_mcp_exposure_table.py`, `tests/commands/test_mcp_tools_and_schema_export.py`, `tests/commands/test_valkey.py`, `tests/roadmap/stage/test_stage_run_allowlist.py`, and the tool-listing snapshot reference `valkey_set` or its row count and are updated.
- Verification commands: `uv run devops ci test tests/ai/mcp/test_mcp_tool_secrets.py`, `uv run devops ci test tests/ai/mcp/test_mcp_exposure_table.py`, `uv run devops ci test tests/commands/test_mcp_tools_and_schema_export.py`, `uv run devops ci test tests/ai/mcp/test_mcp_tool_registry.py`, `uv run devops ci test tests/ai/mcp/test_mcp_argument_refusal.py`, and `uv run devops ci docs`.

## Existing Tool Considered
Expand Down
Loading