Add compiler guardrail to reject ${{ ... }} in compiled run scripts#32048
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
Add compiler guardrail for GitHub expressions in run scripts
Add compiler guardrail to reject May 14, 2026
${{ ... }} in compiled run scripts
Copilot created this pull request from a session on behalf of
pelikhan
May 14, 2026 04:18
View session
Collaborator
|
@copilot recompile |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a compiler validation guardrail to detect compiler regressions where raw GitHub Actions expressions (${{ ... }}) remain embedded in compiled run: scripts, and ensures consistent behavior across both schema-validation paths.
Changes:
- Adds a generalized
run:-block expression scanner and applies it in skip-validation mode to decide when to reparse YAML. - Introduces a parsed-workflow validator that rejects any remaining
${{ ... }}insiderun:scripts and surfaces a dedicated “compiler regression” error message. - Extends path-parity tests to assert both validation paths fail when
run:contains${{ github.token }}inline.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/template_injection_validation.go | Adds generalized run-block scanning and a new parsed-workflow guardrail validator for raw expressions in run: scripts. |
| pkg/workflow/template_injection_utils.go | Adds a dedicated error formatter for the new compiler-regression guardrail. |
| pkg/workflow/compiler.go | Wires the new guardrail into both schema-enabled and skip-validation compilation paths. |
| pkg/workflow/compiler_template_injection_both_paths_test.go | Adds regression tests to ensure both validation paths reject inline ${{ ... }} in run:. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 1
Comment on lines
+221
to
+225
| for _, runContent := range runBlocks { | ||
| expressions := inlineExpressionRegex.FindAllString(runContent, -1) | ||
| for _, expr := range expressions { | ||
| snippet := extractRunSnippet(runContent, expr) | ||
| violations = append(violations, TemplateInjectionViolation{ |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Recompiled and pushed in It includes the lockfile regeneration plus the guardrail follow-ups needed for compile to pass with the new run-script checks. |
Collaborator
|
@copilot review all comments |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Addressed the actionable review feedback and pushed Change made:
|
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.
Bug Fix
This addresses a compiler regression gap: generated
.lock.ymlfiles could still carry GitHub Actions expressions directly in shellrunscripts (for example${{ github.token }}). Compiled workflows should never do this; expressions must be rewritten intoenvbindings and referenced as shell variables.What was the bug?
Compiled workflow validation only enforced template-injection checks for selected unsafe contexts, so non-unsafe expressions could still appear inline in
runblocks and bypass the intended rewrite contract.How did you fix it?
${{ ... }}expression found insiderunscript content in compiled YAML.${{ github.token }}case to ensure both paths fail consistently when inline expressions remain inrun.Example
Testing
Covered by existing workflow/template-injection validation tests with added regression assertions for
${{ github.token }}in both compiler validation paths.