Skip to content

fix(docker-bake): prevent bash history expansion in metadata extraction#8

Merged
falcorocks merged 1 commit intomainfrom
falco/fix-bash-history-expansion
Dec 4, 2025
Merged

fix(docker-bake): prevent bash history expansion in metadata extraction#8
falcorocks merged 1 commit intomainfrom
falco/fix-bash-history-expansion

Conversation

@falcorocks
Copy link
Copy Markdown
Collaborator

Description

Use quoted heredoc to safely write bake metadata to file before processing with jq. This prevents bash history expansion issues when metadata contains special characters like ! which can cause No such file or directory errors.

Problem

The original code:

echo '${{ steps.bake.outputs.metadata }}' | jq -r '...'

Even with single quotes, bash history expansion (!) is processed before quote parsing in some shell configurations. If the Docker build provenance metadata contained strings like !--..., bash would try to expand it as "last command starting with --".

Solution

Use a quoted heredoc (<<'DELIMITER') to write the metadata to a file first:

cat <<'METADATA_EOF' > $METADATA_FILE
${{ steps.bake.outputs.metadata }}
METADATA_EOF
cat $METADATA_FILE | jq -r '...'

The single quotes around the heredoc delimiter tell bash to treat the content as 100% literal - no variable expansion, no command substitution, no history expansion.

Related

Fixes flaky CI failures observed in ethereum-optimism/optimism#18488

Use quoted heredoc to safely write bake metadata to file before processing.
This prevents bash history expansion issues when metadata contains special
characters like '!' which can cause 'No such file or directory' errors.

Fixes flaky CI failures observed in ethereum-optimism/optimism#18488
@falcorocks falcorocks self-assigned this Dec 4, 2025
@falcorocks falcorocks marked this pull request as ready for review December 4, 2025 09:45
@falcorocks falcorocks merged commit f08b1f0 into main Dec 4, 2025
4 checks passed
falcorocks added a commit to ethereum-optimism/optimism that referenced this pull request Dec 4, 2025
Updates docker-bake.yaml reference to include fix that prevents bash
history expansion issues when build metadata contains special characters
like '!'.

Ref: ethereum-optimism/factory#8
github-merge-queue bot pushed a commit to ethereum-optimism/optimism that referenced this pull request Dec 4, 2025
…18498)

Updates docker-bake.yaml reference to include fix that prevents bash
history expansion issues when build metadata contains special characters
like '!'.

Ref: ethereum-optimism/factory#8
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