Validate RuntimeConfig fields at all entry points#4196
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4196 +/- ##
==========================================
- Coverage 69.13% 69.01% -0.13%
==========================================
Files 467 468 +1
Lines 46996 47047 +51
==========================================
- Hits 32492 32470 -22
- Misses 11959 11995 +36
- Partials 2545 2582 +37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
RuntimeConfig values (AdditionalPackages and BuilderImage) are interpolated into Dockerfile templates. Add input validation to harden these fields against malformed or unexpected values. Add a Validate() method on RuntimeConfig that checks package names against a strict allowlist regex and validates builder images using go-containerregistry's ParseReference. Call Validate() at all entry points: CLI flags, API requests, config file loading, and the runtime config loader in the runner package. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b75e78a to
34a0aa9
Compare
amirejaz
approved these changes
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AdditionalPackagesandBuilderImage) are interpolated into Dockerfile templates viatext/template. To harden these inputs, add strict validation at all entry points before values reach template rendering.Validate()method onRuntimeConfigthat enforces a strict allowlist regex for package names and usesgo-containerregistry/pkg/name.ParseReference()for builder image references. Call it at every path where RuntimeConfig is accepted: CLI flags, API requests, config file storage, and the runner's runtime config loader.Type of change
Test plan
task test)task lint-fix)Changes
pkg/container/templates/runtime_config.goValidate()method with package name regex and image ref validationpkg/container/templates/runtime_config_test.gocmd/thv/app/run_flags.goValidate()inconfigureRuntimeOptions()andhandleImageRetrieval()pkg/runner/protocol.goValidate()inloadRuntimeConfig()before returning overridespkg/config/config.goValidate()insetRuntimeConfig()before persistingDoes this introduce a user-facing change?
Users will now get a clear error message if they pass an invalid package name (e.g., containing shell metacharacters) via
--runtime-add-packageor an invalid image reference via--runtime-image. Previously these would be silently passed through to the Dockerfile template.Generated with Claude Code