Skip to content

fix: redact environment variables exposed by mittwald_stack_list - #76

Open
martin-helmich wants to merge 3 commits into
mainfrom
fix/stack-list-redact-env-vars
Open

fix: redact environment variables exposed by mittwald_stack_list#76
martin-helmich wants to merge 3 commits into
mainfrom
fix/stack-list-redact-env-vars

Conversation

@martin-helmich

Copy link
Copy Markdown
Member

Summary

  • mittwald_stack_list echoed each service's deployedState/pendingState.envs verbatim, leaking container environment variables (including secrets) on a plain discovery call. Values are now redacted to [REDACTED] by default, with a new opt-in revealEnvironmentVariables parameter to get real values when explicitly needed.
  • Replaced the hand-rolled RawStack/RawService/RawServiceState shapes with the real MittwaldAPIV2.Components.Schemas.ContainerStackResponse / ContainerServiceResponse / ContainerServiceState types from @mittwald/api-client, matching the convention in src/types/mittwald/container.ts.
  • mittwald_stack_deploy's description told callers to pre-read the existing stack via a mittwald_stack_get tool that doesn't exist (only list/ps/deploy/delete are registered for stack). Pointed it at mittwald_stack_list instead, which does return full service/volume config for merging.
  • Added a regression test proving mittwald_stack_ps does not have the same leak: formatServices() builds its output via an explicit field allowlist rather than passing the raw service object through, so envs never gets copied into the response even though the underlying API call returns the same ContainerServiceResponse shape.
  • Regenerated the affected docs/reference pages (npm run docs:generate), scoped to the stack domain plus the manifest/openapi files.

Test plan

  • npm run type-check
  • npx eslint on all touched files
  • npx vitest run tests/unit — 33 files / 360 tests passing, including two new test files:
    • tests/unit/handlers/tools/mittwald-cli/stack/list-cli.test.ts (redaction default + opt-in reveal)
    • tests/unit/handlers/tools/mittwald-cli/stack/ps-cli.test.ts (confirms no env var leak)

🤖 Generated with Claude Code

martin-helmich and others added 3 commits August 31, 2026 12:30
mittwald_stack_list exposed each service's deployedState/pendingState
envs verbatim, leaking secrets on a plain discovery call. Redact values
by default and add a revealEnvironmentVariables opt-in parameter to get
real values.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replace the hand-rolled RawStack/RawService/RawServiceState shapes with
MittwaldAPIV2.Components.Schemas.ContainerStackResponse/ContainerServiceResponse/
ContainerServiceState from @mittwald/api-client, matching the convention
already used in src/types/mittwald/container.ts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
mittwald_stack_deploy's description told callers to read the existing
stack via a "mittwald_stack_get" tool that doesn't exist (only list,
ps, deploy and delete are registered for stack). Point it at
mittwald_stack_list instead, which returns full service/volume config
for merging.

Also add a regression test proving mittwald_stack_ps does not leak
service environment variables: formatServices() in ps-cli.ts only
whitelists id/name/state/image/ports/stackId/createdAt/updatedAt, so
the deployedState/pendingState.envs the underlying API response
carries never reaches the tool output.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@martin-helmich
martin-helmich requested a review from gandie August 31, 2026 10:50
@martin-helmich
martin-helmich marked this pull request as ready for review August 31, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant