fix(replacetags): stop deleting split-image blocks with no tag source match - #34
Open
taleodor-claude wants to merge 1 commit into
Open
fix(replacetags): stop deleting split-image blocks with no tag source match#34taleodor-claude wants to merge 1 commit into
taleodor-claude wants to merge 1 commit into
Conversation
… match Two bugs in the bitnami / tag-as-digest path, both reachable from a plain `devops replacetags` run. An image block written as separate registry / repository / tag keys is claimed by validateAndParseBitnamiLines, which then only emits lines when it found a substitution for that image. With no match it returned an empty slice while still reporting the block as handled, so the caller took it at its word and the entire block vanished from the output -- comments, pullPolicy, pullSecrets and all. It is silent, and the file still parses afterwards, so it surfaces later as the chart quietly falling back to whatever the subchart ships. That is not hypothetical: running replacetags over the ReARM chart's own values with a tag source that happens not to carry the postgres image drops 21 lines of postgresql.image. Any chart processed with a partial tag source is exposed. Such a block is now handed back unclaimed, so it goes through the normal line-by-line path like any other content -- preserved, and still open to property and secret resolution. Second, a source reference carrying a digest but no tag produced `tag: @sha256:...`, which is not a valid reference. Charts that take a digest through the tag field accept a bare `sha256:...`, so that is what is written when there is no tag to combine. Both new tests fail without the fix. The existing nine still pass, so the full-bitnami and sha-field shapes are unaffected. ReARM-Agentic-Session: 9083aa16-4486-4bc0-8fc4-0eb6e6783f33 ReARM-Agent: 703fbe71-5a15-4bd3-b601-ce3f0d7d225b
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.
Two bugs in the bitnami / tag-as-digest path of
devops replacetags, both reachable from a plain run. Found while pinning image digests in the Dependency-Track 5 helm chart (relizaio/rearm#227), whose subchart expresses a digest through thetagfield.1. Unmatched blocks were deleted
An image written as separate
registry/repository/tagkeys is claimed byvalidateAndParseBitnamiLines, which only emits lines when it found a substitution for that image. With no match it returned an empty slice while still reporting the block as handled — soparseBitnamiLinestook it at its word and the whole block disappeared from the output, comments,pullPolicyandpullSecretsincluded.It fails silently and the file still parses, so it shows up later as the chart quietly falling back to whatever the subchart ships.
Not hypothetical — running replacetags over the ReARM chart's own values with a tag source that happens not to carry the postgres image:
Any chart processed with a partial tag source is exposed, not just the one that surfaced it.
Such a block is now handed back unclaimed (
return nil, false) so it flows through the normal line-by-line path like any other content — preserved, and still open to property and secret resolution. That seemed better than returning the lines verbatim from the bitnami path, which would have skipped that resolution.2. Digest-only references produced an invalid tag
A source reference carrying a digest but no tag left
replacedSubst.Tagempty and wrote:Charts that take a digest through the tag field accept a bare
sha256:...(the Dependency-Track v2 chart documents exactly that), so that is what is written when there is no tag to combine:Tests
Two added, both verified to fail without the fix:
TestReplaceTagsTagAsDigest— tag source covers one of two images; the matched block is rewritten and the unmatched one comes through untouchedTestReplaceTagsTagAsDigestWithoutTag— digest-only source yields a bare digestThe existing nine still pass, so the full-bitnami and sha-field shapes are unaffected.
Also re-checked end to end with a locally built binary: the ReARM chart values are now preserved byte for byte (bar the trailing newline the CLI always adds), the DT5 chart values are untouched by a non-matching source, and a matching source still replaces every image as before.
🤖 Generated with Claude Code