diff --git a/SECURITY.md b/SECURITY.md index a483da6aca..7d44020e40 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -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:` 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:` 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. diff --git a/docs/MCP_TOOLS.md b/docs/MCP_TOOLS.md index 368be43e25..1ecbc8a017 100644 --- a/docs/MCP_TOOLS.md +++ b/docs/MCP_TOOLS.md @@ -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. | @@ -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=`, 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. | @@ -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. diff --git a/openspec/changes/3230-decide-the-free-text-mcp-parameters/.openspec.yaml b/openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/.openspec.yaml similarity index 100% rename from openspec/changes/3230-decide-the-free-text-mcp-parameters/.openspec.yaml rename to openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/.openspec.yaml diff --git a/openspec/changes/3230-decide-the-free-text-mcp-parameters/design.md b/openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/design.md similarity index 78% rename from openspec/changes/3230-decide-the-free-text-mcp-parameters/design.md rename to openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/design.md index f4399d7c51..b6a481e998 100644 --- a/openspec/changes/3230-decide-the-free-text-mcp-parameters/design.md +++ b/openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/design.md @@ -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. diff --git a/openspec/changes/3230-decide-the-free-text-mcp-parameters/proposal.md b/openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/proposal.md similarity index 71% rename from openspec/changes/3230-decide-the-free-text-mcp-parameters/proposal.md rename to openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/proposal.md index 7562c799f4..9cfe3c60e9 100644 --- a/openspec/changes/3230-decide-the-free-text-mcp-parameters/proposal.md +++ b/openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/proposal.md @@ -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. @@ -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 @@ -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 diff --git a/openspec/changes/3230-decide-the-free-text-mcp-parameters/specs/mcp-tool-secrets/spec.md b/openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/specs/mcp-tool-secrets/spec.md similarity index 100% rename from openspec/changes/3230-decide-the-free-text-mcp-parameters/specs/mcp-tool-secrets/spec.md rename to openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/specs/mcp-tool-secrets/spec.md diff --git a/openspec/changes/3230-decide-the-free-text-mcp-parameters/tasks.md b/openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/tasks.md similarity index 70% rename from openspec/changes/3230-decide-the-free-text-mcp-parameters/tasks.md rename to openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/tasks.md index 60b9b2250a..da03695c21 100644 --- a/openspec/changes/3230-decide-the-free-text-mcp-parameters/tasks.md +++ b/openspec/changes/archive/2026-11-25-3230-decide-the-free-text-mcp-parameters/tasks.md @@ -4,38 +4,38 @@ Reads: `src/devops_cli/ai/mcp/generator.py`, `tests/ai/mcp/test_mcp_exposure_table.py`. Changes: `src/devops_cli/ai/mcp/generator.py`, `tests/ai/mcp/test_mcp_exposure_table.py`. -- [ ] 1.1 In `tests/ai/mcp/test_mcp_exposure_table.py`, add a test that gives a path restriction a `denied` set holding `env` and asserts that the generated schema of the tool has no `env` property +- [x] 1.1 In `tests/ai/mcp/test_mcp_exposure_table.py`, add a test that gives a path restriction a `denied` set holding `env` and asserts that the generated schema of the tool has no `env` property - Verification: `$ uv run devops ci test tests/ai/mcp/test_mcp_exposure_table.py` fails on the base -- [ ] 1.2 Read `denied` in `_introspect_command_parameters` of `src/devops_cli/ai/mcp/generator.py` and skip each parameter that it names, before any `allowed` check. Document the key in the comment above `_PATH_PARAM_RESTRICTIONS` +- [x] 1.2 Read `denied` in `_introspect_command_parameters` of `src/devops_cli/ai/mcp/generator.py` and skip each parameter that it names, before any `allowed` check. Document the key in the comment above `_PATH_PARAM_RESTRICTIONS` - Verification: `$ uv run devops ci test tests/ai/mcp/test_mcp_exposure_table.py` passes ## 2. Deny env on sandbox deploy, drop valkey set, and update dependent tests -Reads: `src/devops_cli/ai/mcp/generator.py`, `src/devops_cli/config/constants.py`, `tests/ai/mcp/test_mcp_exposure_table.py`, `tests/ai/mcp/test_mcp_tool_registry.py`. Changes: `src/devops_cli/ai/mcp/generator.py`, `src/devops_cli/config/constants.py`, `tests/ai/mcp/test_mcp_exposure_table.py`, `tests/ai/mcp/test_mcp_tool_registry.py`. +Reads: `src/devops_cli/ai/mcp/generator.py`, `src/devops_cli/config/constants.py`, `tests/ai/mcp/test_mcp_exposure_table.py`, `tests/ai/mcp/test_mcp_tool_registry.py`. Changes: `src/devops_cli/ai/mcp/generator.py`, `src/devops_cli/config/constants.py`, `src/devops_cli/roadmap/stage/stage_run_allowlist.py`, `tests/ai/mcp/test_mcp_exposure_table.py`, `tests/ai/mcp/test_mcp_tool_registry.py`, `tests/commands/test_valkey.py`. -- [ ] 2.1 In `tests/ai/mcp/test_mcp_exposure_table.py`, add a test that asserts the schema of `sandbox_deploy` has no `env` property and that the generated tool names hold no `valkey_set` +- [x] 2.1 In `tests/ai/mcp/test_mcp_exposure_table.py`, add a test that asserts the schema of `sandbox_deploy` has no `env` property and that the generated tool names hold no `valkey_set` - Verification: `$ uv run devops ci test tests/ai/mcp/test_mcp_exposure_table.py` fails on the base -- [ ] 2.2 Add `("sandbox", "deploy")` to `_PATH_PARAM_RESTRICTIONS` with `denied` holding `env`. Remove `("valkey", "set")` from `CONST_MCP_EXPOSURE_TABLE` in `src/devops_cli/config/constants.py` and from `_PATH_PARAM_RESTRICTIONS` +- [x] 2.2 Add `("sandbox", "deploy")` to `_PATH_PARAM_RESTRICTIONS` with `denied` holding `env`. Remove `("valkey", "set")` from `CONST_MCP_EXPOSURE_TABLE` in `src/devops_cli/config/constants.py` and from `_PATH_PARAM_RESTRICTIONS` - Verification: `$ uv run devops ci test tests/ai/mcp/test_mcp_exposure_table.py` passes -- [ ] 2.3 Add `("valkey", "set")` to `mcp_command_exclusions` and update `test_export_schemas_command` to check `tf_apply.json` in `tests/commands/test_mcp_tools_and_schema_export.py`. Update `floor_expected_false` in `tests/ai/mcp/test_mcp_tool_registry.py` and the input contract tests in `tests/ai/mcp/test_mcp_argument_refusal.py` to use `tf_apply` instead of `valkey_set` - - Verification: `$ uv run devops ci test tests/ai/mcp/test_mcp_exposure_table.py tests/commands/test_mcp_tools_and_schema_export.py tests/ai/mcp/test_mcp_tool_registry.py tests/ai/mcp/test_mcp_argument_refusal.py` passes +- [x] 2.3 Update `test_export_schemas_command` to check `tf_apply.json` in `tests/commands/test_mcp_tools_and_schema_export.py`. Update `ROW_COUNT` in `tests/roadmap/stage/test_stage_run_allowlist.py`, `floor_expected_false` in `tests/ai/mcp/test_mcp_tool_registry.py`, the input contract tests in `tests/ai/mcp/test_mcp_argument_refusal.py` to use `tf_apply` instead of `valkey_set`, `VALKEY_TOOL_PARAMETERS` and `VALKEY_TOOL_CALLS` in `tests/commands/test_valkey.py`, and the tool-listing snapshot. A command that the exposure table does not name is excluded, so no exclusion list needs an entry + - Verification: `$ uv run devops ci test tests/ai/mcp/test_mcp_exposure_table.py tests/commands/test_mcp_tools_and_schema_export.py tests/ai/mcp/test_mcp_tool_registry.py tests/ai/mcp/test_mcp_argument_refusal.py tests/commands/test_valkey.py tests/roadmap/stage/test_stage_run_allowlist.py` passes ## 3. Add the free-text sink guard and allow-list k8s_diff_helm values Reads: `SECURITY.md`, `src/devops_cli/ai/mcp/generator.py`, `src/devops_cli/config/constants.py`, `tests/ai/mcp/test_mcp_tool_secrets.py`. Changes: `src/devops_cli/config/constants.py`, `tests/ai/mcp/test_mcp_tool_secrets.py`. -- [ ] 3.1 In `tests/ai/mcp/test_mcp_tool_secrets.py`, add a test that registers a tool publishing a text parameter named `value` with no allow-list entry and asserts that the guard fails and names the tool and the parameter, and a test that asserts a stale entry fails +- [x] 3.1 In `tests/ai/mcp/test_mcp_tool_secrets.py`, add a test that registers a tool publishing a text parameter named `value` with no allow-list entry and asserts that the guard fails and names the tool and the parameter, and a test that asserts a stale entry fails - Verification: `$ uv run devops ci test tests/ai/mcp/test_mcp_tool_secrets.py` fails on the base -- [ ] 3.2 Add `CONST_MCP_FREE_TEXT_SINK_PARAMETER_NAMES` with `env`, `values`, `value` and `data`, and `CONST_MCP_FREE_TEXT_SINK_ALLOWLIST` with `("k8s_diff_helm", "values")` and its reason in `src/devops_cli/config/constants.py`. Add the schema scan to `tests/ai/mcp/test_mcp_tool_secrets.py` beside the guard of #3222 +- [x] 3.2 Add `CONST_MCP_FREE_TEXT_SINK_PARAMETER_NAMES` with `env`, `values`, `value` and `data`, and `CONST_MCP_FREE_TEXT_SINK_ALLOWLIST` with `("k8s_diff_helm", "values")` and its reason in `src/devops_cli/config/constants.py`. Add the schema scan to `tests/ai/mcp/test_mcp_tool_secrets.py` beside the guard of #3222 - Verification: `$ uv run devops ci test tests/ai/mcp/test_mcp_tool_secrets.py` passes ## 4. State the guard in the security policy and update documentation Reads: `SECURITY.md`, `docs/MCP_TOOLS.md`, `src/devops_cli/config/constants.py`. Changes: `SECURITY.md`, `docs/MCP_TOOLS.md`. -- [ ] 4.1 Update rule 11 of `SECURITY.md` to state five valkey commands are MCP tools and that `valkey set` is not an MCP tool. Update rule 12 with the free-text sink names, the allow-list with its reason, and the stale-entry check +- [x] 4.1 Update rule 11 of `SECURITY.md` to state five valkey commands are MCP tools and that `valkey set` is not an MCP tool. Update rule 12 with the free-text sink names, the allow-list with its reason, and the stale-entry check - Verification: `$ uv run devops ci docs` passes -- [ ] 4.2 Run `uv run devops docs generate --sync-readme` to regenerate `docs/MCP_TOOLS.md` without `valkey_set` +- [x] 4.2 Run `uv run devops docs generate` to regenerate `docs/MCP_TOOLS.md` without `valkey_set` - Verification: `$ uv run devops ci docs` passes ## Criteria diff --git a/openspec/specs/mcp-tool-secrets/spec.md b/openspec/specs/mcp-tool-secrets/spec.md index 6ff6dbd324..b9157b12dd 100644 --- a/openspec/specs/mcp-tool-secrets/spec.md +++ b/openspec/specs/mcp-tool-secrets/spec.md @@ -44,3 +44,46 @@ The MCP tool `docker_sign` SHALL accept `oidc_token` only when the value starts #### Scenario: An argument that is no JSON object - **WHEN** a tool call has an argument text that holds a GitHub token and is no JSON object - **THEN** the trace argument does not hold the token + +### Requirement: The sandbox deploy tool publishes no env parameter +The MCP tool `sandbox_deploy` SHALL publish no `env` parameter. + +#### Scenario: Published sandbox deploy schema +- **WHEN** A test generates the MCP tools and reads the schema of `sandbox_deploy`. +- **THEN** The schema has no `env` property. + +### Requirement: The server publishes no valkey set tool +The MCP server SHALL publish no `valkey_set` tool. + +#### Scenario: Published valkey tools +- **WHEN** A test generates the MCP tools and lists their names. +- **THEN** The list holds no `valkey_set` name. + +### Requirement: A denied parameter leaves the tool schema +The MCP generator SHALL omit every parameter that the `denied` set of a path restriction names. + +#### Scenario: Denied parameter in a path restriction +- **WHEN** A test gives a path restriction a `denied` set that holds `env`, and the command publishes an `env` option. +- **THEN** The generated tool schema has no `env` property. + +### Requirement: A free-text sink parameter needs an allow-list entry +The MCP schema guard SHALL fail on a published text parameter named `env`, `values`, `value` or `data` that has no allow-list entry with a reason. + +#### Scenario: Unallowed free-text sink parameter +- **WHEN** A test registers a tool that publishes a text parameter named `value`, and the allow-list holds no entry for it. +- **THEN** The guard fails and names the tool and the parameter. + +#### Scenario: Allowed free-text sink parameter +- **WHEN** A test registers a tool that publishes a text parameter named `data`, and the allow-list holds an entry for the tool and the parameter with a reason. +- **THEN** The guard passes. + +### Requirement: A free-text allow-list entry names a published parameter +The MCP schema guard SHALL fail on an allow-list entry that matches no published parameter. + +#### Scenario: Stale free-text allow-list entry +- **WHEN** The allow-list holds an entry for a tool and parameter that the server does not publish. +- **THEN** The guard fails and names the stale entry. + +#### Scenario: Live free-text allow-list entry +- **WHEN** The allow-list holds an entry for `k8s_diff_helm.values` and the server publishes `k8s_diff_helm`. +- **THEN** The guard passes. diff --git a/src/devops_cli/ai/mcp/generator.py b/src/devops_cli/ai/mcp/generator.py index a2b645fdf9..e607062264 100644 --- a/src/devops_cli/ai/mcp/generator.py +++ b/src/devops_cli/ai/mcp/generator.py @@ -34,7 +34,9 @@ # The options of a command that its MCP tool publishes. A command lists an option here when the # other options are for a person at the command line. A URL option is input from the model that # calls the tool, so the tool does not publish it. The tool queries the service that the -# configuration names. +# configuration names. A `denied` set names options that the tool never publishes, whether an +# `allowed` set exists or not: it covers a free-text option that copies a value into an +# environment, a file or a store, which a model could fill with a secret (#3230). _PATH_PARAM_RESTRICTIONS: dict[tuple[str, ...], dict[str, Any]] = { ("telemetry", "profile"): { "allowed": frozenset({"trace_id"}), @@ -47,10 +49,7 @@ ("valkey", "stats"): {"allowed": frozenset(), "required": frozenset()}, ("valkey", "info"): {"allowed": frozenset({"section"}), "required": frozenset()}, ("valkey", "get"): {"allowed": frozenset({"key"}), "required": frozenset()}, - ("valkey", "set"): { - "allowed": frozenset({"key", "value", "ex", "dry_run"}), - "required": frozenset(), - }, + ("sandbox", "deploy"): {"denied": frozenset({"env"})}, ("valkey", "flush"): { "allowed": frozenset({"all_databases", "dry_run"}), "required": frozenset(), @@ -308,11 +307,16 @@ def _introspect_command_parameters( continue if format_json and p.name in _JSON_PARAM_NAMES: continue - if restrictions and p.name not in restrictions["allowed"]: + if restrictions and ( + p.name in restrictions.get("denied", ()) + or p.name not in restrictions.get("allowed", {p.name}) + ): continue py_type = _deduce_parameter_type(p) default_val = _normalize_default(getattr(p, "default", None)) - is_required = bool(p.required or (restrictions and p.name in restrictions["required"])) + is_required = bool( + p.required or (restrictions and p.name in restrictions.get("required", ())) + ) field = _build_parameter_field( p, default_val, is_required, _PARAM_DESCRIPTIONS.get((path, p.name)) ) diff --git a/src/devops_cli/config/constants.py b/src/devops_cli/config/constants.py index 2a8b8d7d5b..9bf15dcdf4 100644 --- a/src/devops_cli/config/constants.py +++ b/src/devops_cli/config/constants.py @@ -447,7 +447,6 @@ (("valkey", "get"), 30.0, True, False), (("valkey", "info"), 30.0, True, False), (("valkey", "ping"), 30.0, True, False), - (("valkey", "set"), 30.0, False, False), (("valkey", "stats"), 30.0, True, False), (("vault", "get"), 60.0, True, False), (("vault", "status"), 30.0, True, False), @@ -626,6 +625,19 @@ "Names the Kubernetes Secret object to write. It holds no secret value." ), } +# A text parameter with one of these names is copied into an environment, a file or a store, so a +# model could fill it with a secret that no name word finds (SECURITY.md rule 12, #3230). +CONST_MCP_FREE_TEXT_SINK_PARAMETER_NAMES: Final[frozenset[str]] = frozenset( + {"env", "values", "value", "data"} +) +# The published free-text sink parameters that hold no secret, as (tool, parameter): the reason. A +# new entry needs a reason. +CONST_MCP_FREE_TEXT_SINK_ALLOWLIST: Final[dict[tuple[str, str], str]] = { + ("k8s_diff_helm", "values"): ( + "Names the Helm values files of the chart to render and compare. The command reads each " + "file and writes no value to a store." + ), +} # Root commands whose module app takes the command's own name as its first argument: CONST_CLI_ROOT_LEVEL_COMMANDS: Final[frozenset[str]] = frozenset({"format", "lint"}) # The command words that run a `devops review` command, which reads a tree devops-cli does not diff --git a/src/devops_cli/roadmap/stage/stage_run_allowlist.py b/src/devops_cli/roadmap/stage/stage_run_allowlist.py index 839b9cec91..3d77714220 100644 --- a/src/devops_cli/roadmap/stage/stage_run_allowlist.py +++ b/src/devops_cli/roadmap/stage/stage_run_allowlist.py @@ -155,11 +155,14 @@ def _permitted_parameters( it as a path or `PATH_CONFINEMENTS` names it. """ restrictions = _PATH_PARAM_RESTRICTIONS.get(path) - allowed: frozenset[str] | None = None if restrictions is None else restrictions["allowed"] + allowed: frozenset[str] | None = None if restrictions is None else restrictions.get("allowed") + denied: frozenset[str] = ( + frozenset() if restrictions is None else restrictions.get("denied", frozenset()) + ) confined = PATH_CONFINEMENTS.get(_tool_name(path), frozenset()) names: list[str] = [] for parameter in command.params: - if not _keeps_parameter(parameter, format_json, allowed): + if not _keeps_parameter(parameter, format_json, allowed, denied): continue if is_path_or_file_param(parameter) or parameter.name in confined: return REASON_PATH_OPTION @@ -167,12 +170,16 @@ def _permitted_parameters( return frozenset(names) -def _keeps_parameter(parameter: Any, format_json: bool, allowed: frozenset[str] | None) -> bool: +def _keeps_parameter( + parameter: Any, format_json: bool, allowed: frozenset[str] | None, denied: frozenset[str] +) -> bool: """Whether a tool publishes `parameter`, as `_introspect_command_parameters` publishes it.""" if parameter.name in _IGNORED_PARAM_NAMES: return False if format_json and parameter.name in _JSON_PARAM_NAMES: return False + if parameter.name in denied: + return False return allowed is None or parameter.name in allowed diff --git a/tests/ai/mcp/__snapshots__/test_mcp_tool_listing/test_the_tool_listing_matches_the_snapshot.json b/tests/ai/mcp/__snapshots__/test_mcp_tool_listing/test_the_tool_listing_matches_the_snapshot.json index 07e034b9d1..f8a7be8391 100644 --- a/tests/ai/mcp/__snapshots__/test_mcp_tool_listing/test_the_tool_listing_matches_the_snapshot.json +++ b/tests/ai/mcp/__snapshots__/test_mcp_tool_listing/test_the_tool_listing_matches_the_snapshot.json @@ -5141,21 +5141,6 @@ "description": "Preview execution plan without mutating external state.", "type": "boolean" }, - "env": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Environment variable in KEY=VALUE format." - }, "image": { "default": "python:3.14-slim", "description": "Container image for the sandbox workload.", @@ -6155,44 +6140,6 @@ "type": "object" } }, - "valkey_set": { - "description": "Set string value of key with optional expiration TTL.", - "input_schema": { - "additionalProperties": false, - "properties": { - "dry_run": { - "default": false, - "description": "Preview execution plan without mutating external state.", - "type": "boolean" - }, - "ex": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "default": null, - "description": "Expiration timeout in seconds" - }, - "key": { - "description": "Key name to set", - "type": "string" - }, - "value": { - "description": "Value to associate with key", - "type": "string" - } - }, - "required": [ - "key", - "value" - ], - "type": "object" - } - }, "valkey_stats": { "description": "Display quick diagnostic summary of server health, memory, and keys.", "input_schema": { diff --git a/tests/ai/mcp/test_mcp_argument_refusal.py b/tests/ai/mcp/test_mcp_argument_refusal.py index 5ae24395f8..3e077d90d4 100644 --- a/tests/ai/mcp/test_mcp_argument_refusal.py +++ b/tests/ai/mcp/test_mcp_argument_refusal.py @@ -151,8 +151,8 @@ async def test_a_strict_refusal_is_rendered_like_a_schema_refusal( async def test_a_refused_secret_never_reaches_the_reply(handler_runner) -> None: """An invalid call returned the secret it was given in its error text.""" - _, reply = await call_tool("valkey_set", {"key": ["bad"], "value": _SECRET_SENTINEL}) - assert ("Parameter: `key`" in reply, "sentinel-4b1d" in reply) == (True, False) + _, reply = await call_tool("tf_apply", {"directory": ["bad"], "var_file": _SECRET_SENTINEL}) + assert ("Parameter: `directory`" in reply, "sentinel-4b1d" in reply) == (True, False) async def test_an_undeclared_parameter_name_is_masked_and_bounded(handler_runner) -> None: @@ -170,7 +170,7 @@ def test_no_rejected_input_reaches_a_log_record(fastmcp_log, handler_runner) -> """FastMCP logs a refused call's pydantic error count and types, never the input. This holds FastMCP to that. It calls past the middleware, as FastMCP itself does once - middleware has run, so pydantic refuses a malformed `valkey_set` and FastMCP logs. + middleware has run, so pydantic refuses a malformed `tf_apply` and FastMCP logs. """ import asyncio @@ -178,9 +178,9 @@ def test_no_rejected_input_reaches_a_log_record(fastmcp_log, handler_runner) -> from devops_cli.ai.mcp.server import mcp - arguments = {"key": ["bad"], "value": _SECRET_SENTINEL} + arguments = {"directory": ["bad"], "var_file": _SECRET_SENTINEL} with pytest.raises(FastMCPValidationError) as raised: - asyncio.run(mcp.call_tool("valkey_set", arguments, run_middleware=False)) + asyncio.run(mcp.call_tool("tf_apply", arguments, run_middleware=False)) assert raised.value is not None assert ( "Invalid arguments for tool" in fastmcp_log.text, @@ -193,11 +193,11 @@ async def test_no_tool_argument_reaches_a_debug_record( ) -> None: """FastMCP logs every tool call's arguments at DEBUG. - With `FASTMCP_LOG_LEVEL=DEBUG`, that wrote the value of a `valkey_set` call to the log. + With `FASTMCP_LOG_LEVEL=DEBUG`, that wrote the `var_file` of a `tf_apply` call to the log. """ - await call_tool("valkey_set", {"key": "session", "value": _SECRET_SENTINEL}) + await call_tool("tf_apply", {"directory": "infra", "var_file": _SECRET_SENTINEL}) assert ( - "Handler called: call_tool valkey_set" in fastmcp_log.text, + "Handler called: call_tool tf_apply" in fastmcp_log.text, "sentinel-4b1d" in fastmcp_log.text, mcp_dispatcher.call_count, ) == (True, False, 1) diff --git a/tests/ai/mcp/test_mcp_exposure_table.py b/tests/ai/mcp/test_mcp_exposure_table.py index 86470e6746..8a7a68ec37 100644 --- a/tests/ai/mcp/test_mcp_exposure_table.py +++ b/tests/ai/mcp/test_mcp_exposure_table.py @@ -44,7 +44,8 @@ def test_mcp_tool_schema_and_argv_parsing( for p in click_cmd.params if p.name not in _IGNORED_PARAM_NAMES and not (format_json and p.name in _JSON_PARAM_NAMES) - and (not restrictions or p.name in restrictions["allowed"]) + and (not restrictions or p.name not in restrictions.get("denied", ())) + and (not restrictions or p.name in restrictions.get("allowed", {p.name})) ] schema_props = list(tool.parameters.get("properties", {}).keys()) assert schema_props == expected_params @@ -107,3 +108,27 @@ def test_the_roadmap_eval_stage_command_publishes_no_mcp_tool() -> None: exposed_paths = {entry[0] for entry in CONST_MCP_EXPOSURE_TABLE} assert ("roadmap", "eval", "stage") not in exposed_paths assert asyncio.run(mcp.get_tool("roadmap_eval_stage")) is None + + +def test_a_denied_option_leaves_the_tool_schema(monkeypatch: pytest.MonkeyPatch) -> None: + """A path restriction with `denied` omits that option, with or without an `allowed` set.""" + from devops_cli.ai.mcp import generator + + path = ("sandbox", "deploy") + command = generator.resolve_click_command(path) + with_env, _ = generator._introspect_command_parameters(command, False, ()) + monkeypatch.setitem(generator._PATH_PARAM_RESTRICTIONS, path, {"denied": frozenset({"env"})}) + without_env, _ = generator._introspect_command_parameters(command, False, path) + + assert ("env" in {p.name for p in with_env}, "env" in {p.name for p in without_env}) == ( + True, + False, + ) + + +def test_sandbox_deploy_publishes_no_env_and_valkey_set_is_no_tool() -> None: + """`env` and the `valkey set` value are free text a model could fill with a secret (#3230).""" + sandbox_deploy = asyncio.run(mcp.get_tool("sandbox_deploy")) + properties = sandbox_deploy.parameters.get("properties", {}) + + assert ("env" in properties, asyncio.run(mcp.get_tool("valkey_set"))) == (False, None) diff --git a/tests/ai/mcp/test_mcp_tool_registry.py b/tests/ai/mcp/test_mcp_tool_registry.py index cfbf210057..9e2c3c49e5 100644 --- a/tests/ai/mcp/test_mcp_tool_registry.py +++ b/tests/ai/mcp/test_mcp_tool_registry.py @@ -289,7 +289,6 @@ def test_fastmcp_tool_annotations_and_mutating_floor() -> None: "review_pr", "tf_apply", "valkey_flush", - "valkey_set", } wrong_floor = sorted( name for name in floor_expected_false if hints_by_name.get(name) is not False diff --git a/tests/ai/mcp/test_mcp_tool_secrets.py b/tests/ai/mcp/test_mcp_tool_secrets.py index 3fb1fb00b8..b064549507 100644 --- a/tests/ai/mcp/test_mcp_tool_secrets.py +++ b/tests/ai/mcp/test_mcp_tool_secrets.py @@ -15,6 +15,8 @@ from devops_cli.ai.mcp.server import mcp from devops_cli.config.constants import ( + CONST_MCP_FREE_TEXT_SINK_ALLOWLIST, + CONST_MCP_FREE_TEXT_SINK_PARAMETER_NAMES, CONST_MCP_SECRET_PARAMETER_ALLOWLIST, CONST_MCP_SECRET_PARAMETER_WORDS, ) @@ -59,6 +61,19 @@ def _secret_suggesting() -> list[tuple[str, str]]: ) +def _free_text_sinks( + published: dict[str, dict[str, dict[str, Any]]] | None = None, +) -> list[tuple[str, str]]: + """Every (tool, parameter) with a sink name that can hold text.""" + tools = _published_parameters() if published is None else published + return sorted( + (tool, name) + for tool, properties in tools.items() + for name, schema in properties.items() + if name in CONST_MCP_FREE_TEXT_SINK_PARAMETER_NAMES and _takes_text(schema) + ) + + def test_no_published_parameter_takes_a_secret_value() -> None: """Each text parameter with a secret-suggesting name is on the allow-list, with its reason.""" unlisted = [ @@ -162,3 +177,44 @@ def test_docker_sign_passes_a_keyring_reference_in_argv() -> None: argv[argv.index("--oidc-token") + 1], "env" in run.call_args.kwargs, ) == ("keyring:cosign_oidc", False) + + +def test_a_free_text_sink_parameter_needs_an_allow_list_entry() -> None: + """A tool that publishes `value` as text, with no entry, is a sink that the guard names.""" + published = {"example_store": {"value": {"type": "string"}, "ttl": {"type": "integer"}}} + unlisted = [ + pair + for pair in _free_text_sinks(published) + if pair not in CONST_MCP_FREE_TEXT_SINK_ALLOWLIST + ] + + assert unlisted == [("example_store", "value")] + + +def test_no_published_free_text_sink_lacks_an_allow_list_entry() -> None: + """`sandbox_deploy.env` and `valkey_set.value` are gone; each sink that stays has a reason.""" + unlisted = [ + pair for pair in _free_text_sinks() if pair not in CONST_MCP_FREE_TEXT_SINK_ALLOWLIST + ] + + assert unlisted == [] + + +def test_the_free_text_allow_list_holds_only_live_entries_with_a_reason() -> None: + """An entry names a published sink parameter, and says why it holds no secret.""" + live = set(_free_text_sinks()) + stale = sorted(pair for pair in CONST_MCP_FREE_TEXT_SINK_ALLOWLIST if pair not in live) + short = sorted( + pair + for pair, reason in CONST_MCP_FREE_TEXT_SINK_ALLOWLIST.items() + if len(reason.strip()) < _MIN_REASON_CHARS + ) + + assert (stale, short) == ([], []) + + +def test_the_free_text_allow_list_refuses_a_stale_entry() -> None: + """An entry for a parameter that no tool publishes is stale.""" + live = set(_free_text_sinks({"example_store": {"ttl": {"type": "integer"}}})) + + assert ("example_store", "value") not in live diff --git a/tests/commands/test_mcp_tools_and_schema_export.py b/tests/commands/test_mcp_tools_and_schema_export.py index cc7a29718d..4852c09a43 100644 --- a/tests/commands/test_mcp_tools_and_schema_export.py +++ b/tests/commands/test_mcp_tools_and_schema_export.py @@ -35,7 +35,7 @@ def test_export_schemas_command(runner: CliRunner, tmp_path: Path) -> None: out_dir = tmp_path / "mcp_schemas" result = runner.invoke(app, ["export-schemas", "--output-dir", str(out_dir)]) trivy_schema = json.loads((out_dir / "scan_trivy.json").read_text(encoding="utf-8")) - mutating_schema = json.loads((out_dir / "valkey_set.json").read_text(encoding="utf-8")) + mutating_schema = json.loads((out_dir / "tf_apply.json").read_text(encoding="utf-8")) assert ( result.exit_code, (out_dir / "instructions.md").exists(), diff --git a/tests/commands/test_valkey.py b/tests/commands/test_valkey.py index e7c20a638d..b1c484858c 100644 --- a/tests/commands/test_valkey.py +++ b/tests/commands/test_valkey.py @@ -946,7 +946,6 @@ def kubectl(call: ProcessCall) -> ProcessAnswer: "valkey_stats": [], "valkey_info": ["section"], "valkey_get": ["key"], - "valkey_set": ["key", "value", "ex", "dry_run"], "valkey_flush": ["all_databases", "dry_run"], } """Each Valkey tool and the parameters that it publishes. None of them is a URL.""" @@ -956,7 +955,6 @@ def kubectl(call: ProcessCall) -> ProcessAnswer: "valkey_stats": ({}, [["INFO"], ["DBSIZE"]]), "valkey_info": ({"section": "memory"}, [["INFO", "memory"]]), "valkey_get": ({"key": "k"}, [["GET", "k"]]), - "valkey_set": ({"key": "k", "value": "v"}, [["SET", "k", "v"]]), "valkey_flush": ({}, [["FLUSHDB"]]), } """Each Valkey tool, arguments that it accepts, and the commands that it sends to the server.""" @@ -1010,7 +1008,7 @@ async def test_a_url_argument_is_refused_and_opens_no_connection( """A call that gives a URL fails, and the server at that URL gets no connection. On `origin/main` the server at the URL received `AUTH ` and then the command of - the tool, so `valkey_set` and `valkey_flush` also wrote to it. + the tool, so `valkey_flush` also wrote to it. """ monkeypatch.setenv("DEVOPS_CLI_VALKEY_PASSWORD", _PASSWORD) arguments, _commands = VALKEY_TOOL_CALLS[tool] diff --git a/tests/roadmap/stage/test_stage_run_allowlist.py b/tests/roadmap/stage/test_stage_run_allowlist.py index ea2716ffa7..4e6190ba47 100644 --- a/tests/roadmap/stage/test_stage_run_allowlist.py +++ b/tests/roadmap/stage/test_stage_run_allowlist.py @@ -29,7 +29,7 @@ # The rows of the exposure table at this commit. The census fails when a row is added or removed, # because each new row needs a decision and the count is the record of that walk. -ROW_COUNT = 144 +ROW_COUNT = 143 def _demo_command() -> Any: