Skip to content

fix: PE-663 pass bake metadata through the environment, not the script - #7

Merged
chriswydra merged 1 commit into
mainfrom
fix/PE-663-metadata-injection
Sep 19, 2026
Merged

chriswydra merged 1 commit into
mainfrom
fix/PE-663-metadata-injection

Conversation

@chriswydra

Copy link
Copy Markdown
Contributor

Parse bake metadata expanded steps.bake.outputs.metadata straight into the shell script:

BAKE_METADATA='${{ steps.bake.outputs.metadata }}'

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 into jq with --arg, so none of them is ever part of the script text. github.ref had 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.

@chriswydra
chriswydra merged commit 8c2d288 into main Sep 19, 2026
1 check passed
@chriswydra
chriswydra deleted the fix/PE-663-metadata-injection branch September 19, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant