Skip to content

fix(provenance): use flow style for arrays to avoid PGP dash-escaping#31997

Open
karimzakzouk wants to merge 1 commit intohelm:mainfrom
karimzakzouk:fix-issue-31866
Open

fix(provenance): use flow style for arrays to avoid PGP dash-escaping#31997
karimzakzouk wants to merge 1 commit intohelm:mainfrom
karimzakzouk:fix-issue-31866

Conversation

@karimzakzouk
Copy link
Copy Markdown

@karimzakzouk karimzakzouk commented Apr 2, 2026

Fixes #31866

What this PR does / why we need it:
When a Chart.yaml contains list fields like keywords or sources, the generated .prov file ends up with double-nested arrays (- - foo). This happens because PGP clearsign dash-escapes any line starting with -, and the default YAML marshaler uses block-style arrays where every item starts with - .

Fix is to serialize sequences in flow style ([foo, bar]) so no lines start with - and PGP has nothing to escape.

Special notes for your reviewer:

  • Added provenance.MarshalMetadata in sign.go which uses go.yaml.in/yaml/v3 to recursively set flow style on all sequence nodes.
  • go.yaml.in/yaml/v3 moved from indirect to direct in go.mod.
  • Tests check the actual .prov output after ClearSign runs, not just the metadata bytes before signing.

If applicable:

  • this PR contains user facing changes
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

Copilot AI review requested due to automatic review settings April 2, 2026 21:49
@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates provenance metadata serialization to prevent OpenPGP clearsign “dash-escaping” from corrupting YAML list fields (e.g., keywords, sources) in generated .prov files.

Changes:

  • Add provenance.MarshalMetadata to force YAML sequences into flow style ([a, b]) before signing.
  • Switch helm package --sign to use the new metadata marshaler when producing .prov files.
  • Add unit tests covering flow-style output and ensuring the signed output doesn’t contain the double-nested - - list artifact.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
pkg/provenance/sign.go Introduces MarshalMetadata and recursive node-walk to set flow style on sequences.
pkg/provenance/sign_test.go Adds tests validating flow-style arrays and clearsign output behavior.
pkg/action/package.go Uses provenance.MarshalMetadata instead of direct YAML marshaling when signing charts.
go.mod Promotes gopkg.in/yaml.v3 to a direct dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/provenance/sign.go Outdated
Comment thread pkg/provenance/sign_test.go Outdated
Comment thread go.mod Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/provenance/sign.go
Fixes helm#31866

This fixes an issue where array fields like keywords and sources were double-nested ('- - foo') when serializing Chart metadata into provenance files. By forcing flow-style YAML arrays for these embedded blocks we successfully bypass openpgp cleartext dash-escaping.

Signed-off-by: Karim Farid <karimzakzouk69@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provenance file chart.yaml doesn't match the source

2 participants