Skip to content

Add optional vals-backed secret resolver - #233

Open
amuraru wants to merge 1 commit into
mainfrom
plan/vals
Open

amuraru wants to merge 1 commit into
mainfrom
plan/vals

Conversation

@amuraru

@amuraru amuraru commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #45

Add optional vals-backed secret resolution using the existing resolver pipeline:

password: "{{vals.ref(ref+awssecrets://app/database?region=us-east-1#/password)}}"

ValsSecretResolver sends a JSON document to vals eval -f - -o json over
stdin without a shell. It preserves returned JSON types and string whitespace,
uses the existing interpolation cache, and enforces a 60-second timeout.
Failures omit reference contents and subprocess output from error messages.

The vals executable is installed separately and only invoked for explicit vals
interpolations. Existing resolvers and Python dependencies remain unchanged.
Document installation, authentication, and trusted-configuration requirements.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test improvement

Testing

  • Tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested the changes manually

Commands run from the isolated worktree using Python 3.14:

  • .venv/bin/python -m pytest tests/ -q --tb=short --cov=himl --cov-report=term-missing --cov-fail-under=80
    — passed: 289 tests, 92.68% coverage (80% minimum).
  • .venv/bin/flake8 himl tests --count --select=E9,F63,F7,F82 --show-source --statistics
    — passed: 0 findings.
  • .venv/bin/mypy himl/ --ignore-missing-imports
    — passed: no issues in 16 source files.
  • .venv/bin/flake8 himl/secret_resolvers.py tests/test_secret_resolvers.py tests/test_inject_secrets.py --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
    — passed: 0 findings.
  • With the official, checksum-verified vals v0.50.0 macOS ARM64 executable
    temporarily on PATH, .venv/bin/python -c 'from himl.inject_secrets import SecretInjector; injector = SecretInjector(); assert injector.inject_secret("{{vals.ref(ref+echo://hello)}}") == "hello"; assert injector.inject_secret("{{vals.ref(ref+echo://hello)}}") == "hello"; print("PASS: real vals v0.50.0 echo resolution and cached reuse")'
    — passed.

New tests were observed failing before implementation. They cover typed output,
reference validation, missing/unusable executable, timeout, invalid encoding
and JSON, provider errors without secret disclosure, URI parsing, cached
resolution, full config processing, and skipping secret resolution.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Additional Notes

No explanatory code comments or downstream changes were necessary.
Authenticated cloud-provider calls, Docker builds, and the full OS/Python CI
matrix were not run locally; provider behavior is delegated to vals.

Only explicit {{vals.ref(...)}} expressions are evaluated, not plain ref+
strings. Provider authentication inherits the environment; himl's default AWS
profile is not forwarded. Configurations must be trusted because vals includes
command-execution and local-file providers. Literal parentheses in references
remain subject to the existing interpolation parser's limitations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Integrate with vals

1 participant