Skip to content

fix(engine): mask declared secrets in dry-run previews and param-default logs - #36

Merged
orieg merged 3 commits into
mainfrom
claude/vibrant-mcnulty-9e4e40
Aug 14, 2026
Merged

orieg merged 3 commits into
mainfrom
claude/vibrant-mcnulty-9e4e40

Conversation

@orieg

@orieg orieg commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

Env vars listed under a workflow's top-level secrets: key had their raw values echoed by two display surfaces:

  • the dry-run step-input preview (execute_step)
  • the param-defaults log line emitted during engine init

This PR masks those values as *** in both places.

Changes

  • _validate_secrets() now also records the current values of the declared env vars (longest-first, so overlapping/nested values mask fully).
  • New _mask_env_values() helper does value-based replacement, so the secret is caught wherever it surfaces — templated via {{ env.X }} or embedded in a programmatically built workflow dict.
  • Applied in the param-defaults log and the dry-run input preview; masking runs before the 80-char preview truncation so a truncated value cannot leak partially.

Tests

  • Dry-run preview masks a templated declared env value.
  • Scoping: env vars not declared under secrets: remain unmasked.
  • Param-default log line is masked, verified via the workflow log file.

Test identifiers/env names avoid the word "secret" where values flow into the engine, to keep CodeQL cleartext-logging name heuristics quiet.

Verification

  • Full suite: 730 passed
  • black --check / isort --check: clean

Known limitation

Masking is scoped to these two display surfaces; a step that itself echoes the value at real execution time (e.g. a shell task printing it) is unchanged.

…ult logs

Env vars listed under the workflow's top-level 'secrets:' key had their
raw values echoed by the dry-run step-input preview and the
param-defaults log line. Record the declared values at validation time
and replace them with '***' in both surfaces (masking runs before the
80-char preview truncation so partial values cannot leak).

Tests cover dry-run masking, scoping (undeclared env vars stay
unmasked), and the param-default log line via the workflow log file.
Copilot AI lite review requested due to automatic review settings August 14, 2026 05:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents accidental exposure of environment-variable secrets declared under a workflow’s top-level secrets: key by masking their values (***) in two user-visible surfaces: engine init param-default logging and dry-run step input previews.

Changes:

  • Extend _validate_secrets() to capture current values of declared secret env vars (sorted longest-first for safer overlapping replacements).
  • Add _mask_env_values() helper and apply it to:
    • engine init “Default parameters loaded” log lines
    • dry-run step input preview output (masking before the 80-char truncation)
  • Add focused tests covering dry-run preview masking, scoping (only declared env vars), and param-default log masking via log file inspection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/yaml_workflow/engine.py Records declared secret env values and masks them in default-param logs and dry-run input previews.
tests/test_secrets.py Adds regression tests ensuring declared env values are masked in both affected display surfaces and non-declared env values remain visible.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

orieg added 2 commits August 13, 2026 23:32
…equired_env

Main's #35 renamed the original secrets helper to
_workflow_with_required_env for CodeQL; the masking tests' helper of the
same name shadowed it after merge, breaking test_secrets_not_present and
test_secrets_invalid_format. Rename it to _masking_workflow.
@orieg
orieg merged commit 25dbf04 into main Aug 14, 2026
16 checks passed
@orieg
orieg deleted the claude/vibrant-mcnulty-9e4e40 branch August 14, 2026 07:31
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.

2 participants