Skip to content

Commit ed3ed8f

Browse files
Randomize GITHUB_ENV delimiter in commit-message check (#1073)
Derive the GITHUB_ENV heredoc delimiter from a per-run GUID instead of a fixed marker committed to the repo. gitlint echoes the PR's own commit messages into that block, so a static marker could be reproduced in a commit to close the heredoc early and inject environment variables into later steps. A random delimiter cannot be guessed, so the content stays inert. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6dc37be commit ed3ed8f

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

.github/workflows/CommitMessage.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ jobs:
3636
Set-Content -Path check_results.log -Value $log -NoNewline
3737
# Put the results into the job summary
3838
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $log
39-
# Put the results into a multi-line environment variable to use in the next step
40-
Add-Content -Path $env:GITHUB_ENV -Value 'check_results<<###LINT_DELIMITER###'
39+
# Put the results into a multi-line environment variable to use in the next step.
40+
# $log echoes the PR's own commit messages, so a static heredoc marker could be
41+
# reproduced in a commit to close the block early and inject arbitrary variables.
42+
# A random per-run delimiter cannot be known in advance, so the content is inert.
43+
$delimiter = "LINT_EOF_$([guid]::NewGuid().ToString('N'))"
44+
Add-Content -Path $env:GITHUB_ENV -Value "check_results<<$delimiter"
4145
Add-Content -Path $env:GITHUB_ENV -Value $log
42-
Add-Content -Path $env:GITHUB_ENV -Value '###LINT_DELIMITER###'
46+
Add-Content -Path $env:GITHUB_ENV -Value $delimiter
4347
# add a comment on the PR if the commit message linting failed
4448
- name: Comment on PR
4549
if: failure()

0 commit comments

Comments
 (0)