Repository navigation
fix: SHA-pin the runtime setup-cli step emitted for custom steps: workflows
#38344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,18 @@ import ( | |
|
|
||
| var runtimeStepGeneratorLog = logger.New("workflow:runtime_step_generator") | ||
|
|
||
| // GenerateRuntimeSetupSteps creates GitHub Actions steps for runtime setup | ||
| func GenerateRuntimeSetupSteps(requirements []RuntimeRequirement) []GitHubActionStep { | ||
| // GenerateRuntimeSetupSteps creates GitHub Actions steps for runtime setup. | ||
| // data is the WorkflowData for the workflow being compiled; it is forwarded to | ||
| // generateSetupStep so that the gh-aw setup-cli step can use the lock-file-aware | ||
| // pin resolver (getActionPinWithData) rather than the static embedded-pins fallback. | ||
| // Pass nil when WorkflowData is not available (e.g. in tests). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doc comment actively discourages exercising the new path: "Pass 💡 Suggested replacement// data is the WorkflowData for the workflow being compiled; pass nil only in
// tests that specifically target non-gh-aw runtimes. Tests for the gh-aw
// setup-cli step should pass a populated *WorkflowData to exercise the
// lock-file pin path.Or, if nil must be supported for breadth-of-test reasons, add a nil-guard that makes the degraded behaviour explicit rather than silently falling back to the static-pin path. |
||
| func GenerateRuntimeSetupSteps(requirements []RuntimeRequirement, data *WorkflowData) []GitHubActionStep { | ||
| runtimeStepGeneratorLog.Printf("Generating runtime setup steps: requirement_count=%d", len(requirements)) | ||
| runtimeSetupLog.Printf("Generating runtime setup steps for %d requirements", len(requirements)) | ||
| var steps []GitHubActionStep | ||
|
|
||
| for _, req := range requirements { | ||
| steps = append(steps, generateSetupStep(&req)) | ||
| steps = append(steps, generateSetupStep(&req, data)) | ||
|
Comment on lines
24
to
+25
|
||
|
|
||
| // Add environment variable capture steps after setup actions for AWF chroot mode. | ||
| // Most env vars are inherited via AWF_HOST_PATH, but Go is special. | ||
|
|
@@ -50,7 +54,7 @@ func generateEnvCaptureStep(envVar string, captureCmd string) GitHubActionStep { | |
| } | ||
|
|
||
| // generateSetupStep creates a setup step for a given runtime requirement | ||
| func generateSetupStep(req *RuntimeRequirement) GitHubActionStep { | ||
| func generateSetupStep(req *RuntimeRequirement, data *WorkflowData) GitHubActionStep { | ||
| runtime := req.Runtime | ||
| version := req.Version | ||
| runtimeStepGeneratorLog.Printf("Generating setup step for runtime: %s, version=%s, if=%s", runtime.ID, version, req.IfCondition) | ||
|
|
@@ -74,7 +78,8 @@ func generateSetupStep(req *RuntimeRequirement) GitHubActionStep { | |
| ifCondition: req.IfCondition, | ||
| cliVersion: version, | ||
| actionRepo: runtime.ActionRepo, | ||
| fallbackActionRefTag: runtime.ActionVersion, | ||
| fallbackActionRefTag: version, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
💡 Why this mattersToday |
||
| workflowData: data, | ||
| withFields: allExtraFields, | ||
|
Comment on lines
80
to
84
|
||
| }) | ||
| if err != nil { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual bug fix has zero test coverage: every call to
GenerateRuntimeSetupStepsin this file passesnil, soresolveGhAwSetupActionRefnever exercises theworkflowData != nilbranch that performs SHA-pinning viagetActionPinWithData.💡 Suggested addition
Add a test that passes a
*WorkflowDatawith a mock resolver that returns a known SHA forsetup-cli@versionand asserts the generated step uses the SHA-pinned ref. Without this, a regression in the lock-file pin path — the security-relevant code added by this PR — would go undetected by the test suite.