Repository navigation
fix: PE-663 pass bake metadata through the environment, not the script - #7
Merged
Merged
Conversation
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.
Parse bake metadataexpandedsteps.bake.outputs.metadatastraight into the shell script:bake's metadata carries buildkit provenance, and that includes the event payload - among other things the pull request title and body. Anyone who can open a pull request writes that text, so anyone who can open a pull request writes part of a shell script that runs on the runner. A quote ends the string and what follows runs. For the repositories that build on the self-hosted runners, that runs inside the CI cluster.
It is not theoretical: it was found because an ordinary pull request body containing an apostrophe ("fork's") broke the step with
syntax error near unexpected token. The build itself had succeeded.This passes the metadata and the git values through
env:and intojqwith--arg, so none of them is ever part of the script text.github.refhad the same problem in the jq program, since a branch name may contain a quote.Tested against the metadata from the run that failed (provenance, apostrophes and all): it now produces a valid build-index.
Callers: metadata-editor, metadata-editor-fastapi, core-geonetwork and barcode-data-portal-mwlr, all of which reference this workflow by
@main. Background and the rest of the hardening is on PE-663.