Skip to content

fix(provenance): fix multi-block armored keyring parsing on arbitrary alignments - #32610

Open
zanarellidev wants to merge 2 commits into
helm:mainfrom
zanarellidev:fix/multi-block-keyring-alignment
Open

zanarellidev wants to merge 2 commits into
helm:mainfrom
zanarellidev:fix/multi-block-keyring-alignment

Conversation

@zanarellidev

Copy link
Copy Markdown

What this PR does / why we need it:

When parsing armored PGP keyrings with multiple blocks in pkg/provenance/sign.go:loadArmoredKeyRing, armor.Decode(in) uses an internal buffered reader (bufio.NewReaderSize(in, 100)). When a block ends, any remaining bytes buffered across the boundary to the next block are discarded upon creating the next decoder. For keyrings formatted with short base64 lines (e.g. 32–56 characters), subsequent PGP keys are silently dropped without error.

This PR splits each armored block (-----BEGIN ... -----END ) before feeding it into a fresh bytes.NewReader, preventing buffer readahead from dropping keys across multi-block armored keyrings.

Which issue(s) this PR fixes:

Fixes #32567

Special notes for your reviewer:

  • Added TestLoadKeyRingArmoredMultiBlockLineAlignments in pkg/provenance/sign_test.go covering 8 different line-length alignments (32 to 56 chars) to ensure full regression coverage.

@pull-request-size pull-request-size Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 1, 2026
@github-actions github-actions Bot added the v4.x Issues and Pull Requests related to the major version v4 label Sep 1, 2026
@zanarellidev

Copy link
Copy Markdown
Author

Hi maintainers, this PR has been ready for review since 01/09. Could you please advise whether a rebase or any further change is needed? I am ready to update it promptly.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 21:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zanarellidev
zanarellidev force-pushed the fix/multi-block-keyring-alignment branch from 87fc54c to eb1cb84 Compare October 2, 2026 00:53
Copilot AI balanced review requested due to automatic review settings October 2, 2026 00:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files. v4.x Issues and Pull Requests related to the major version v4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

provenance: multi-block armored keyrings silently drop keys depending on block alignment

2 participants