Add step authoring guidance to .github/aw instruction files#40413
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Hey One small gap to close:
If you'd like a hand:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the .github/aw instruction docs to add explicit guidance for authoring steps:, pre-steps:, and post-steps: with a clear preference order and concrete shell-injection mitigation patterns.
Changes:
- Adds a new “Step Authoring Guidance” section describing when to prefer
actions/github-scriptvsrun:vs Python. - Documents a safe pattern for using untrusted GitHub event fields in shell steps (via
env:indirection). - Adds “shell injection” to the Common Risk Areas list in workflow constraints.
Show a summary per file
| File | Description |
|---|---|
| .github/aw/workflow-patterns.md | Adds step authoring guidance, including examples and shell-injection mitigation advice. |
| .github/aw/workflow-constraints.md | Calls out shell injection as a common risk area and recommends env-var indirection. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 4
|
|
||
| ### 1. Preferred: `actions/github-script` | ||
|
|
||
| Use `actions/github-script` for GitHub API interactions and general scripting. The workflow compiler handles action pinning automatically; specify a recent major version tag (`@v7`) without a SHA. |
| - name: Fetch issue data | ||
| uses: actions/github-script@v7 | ||
| with: |
| - name: Unsafe comment | ||
| run: gh issue comment ${{ github.event.issue.number }} --body "${{ github.event.issue.title }}" | ||
|
|
||
| # ✅ Safe: pass untrusted values through env vars and reference them as $VAR_NAME |
| - auto-merge or bypassing review | ||
| - overly broad network access | ||
| - unbounded bash allowlists for untrusted input | ||
| - shell injection: interpolating `${{ github.event.* }}` or other untrusted expressions directly into `run:` scripts; pass untrusted values through environment variables instead |
Instruction files lacked guidance on how to implement
steps:,pre-steps:, andpost-steps:— leaving step type selection and shell injection prevention undocumented.Changes
.github/aw/workflow-patterns.md— new "Step Authoring Guidance" section with explicit preference order:actions/github-script@v7(preferred) — compiler handles SHA pinning; no injection risk; typed GitHub API access viagithub.rest.*run:steps — user-controlled fields (issue.title,issue.body,comment.body,pull_request.title/body,head_ref) must be passed through env vars, not interpolated directly:pandas,numpy,matplotlib) are genuinely required.github/aw/workflow-constraints.md— shell injection added to Common Risk Areas, calling out direct${{ github.event.* }}interpolation intorun:scripts.