Skip to content

Commit 05bd404

Browse files
JonZeollaclaude
andcommitted
fix: pass branch ref through env var to avoid script injection
Actionlint flags github.head_ref as potentially untrusted in inline scripts. Pass it through an environment variable instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d514c52 commit 05bd404

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,10 @@ jobs:
106106
name: Windows Smoke Test
107107
runs-on: windows-latest
108108
steps:
109-
- name: Configure git for cookiecutter template paths
110-
shell: pwsh
111-
run: |
112-
# The cookiecutter template directory contains pipe/quote characters
113-
# that are invalid on NTFS. Write a gitconfig file that disables
114-
# NTFS protection and point GIT_CONFIG_GLOBAL at it so the setting
115-
# persists through actions/checkout's HOME override.
116-
$configPath = Join-Path $env:RUNNER_TEMP "gitconfig-ntfs"
117-
"[core]`n protectNTFS = false" | Out-File -FilePath $configPath -Encoding utf8
118-
echo "GIT_CONFIG_GLOBAL=$configPath" | Tee-Object -Append $env:GITHUB_ENV
119-
- name: Checkout the repository
120-
uses: actions/checkout@v6
121-
with:
122-
persist-credentials: 'false'
109+
# Note: no checkout step. The cookiecutter template directory contains
110+
# characters (pipe, quotes) that are illegal on NTFS, so we cannot check
111+
# out the repo on Windows. Instead, cookiecutter fetches the template
112+
# directly from the remote branch.
123113
- name: Setup uv
124114
uses: astral-sh/setup-uv@v4
125115
with:
@@ -133,13 +123,17 @@ jobs:
133123
env:
134124
RUN_POST_HOOK: 'true'
135125
SKIP_GIT_PUSH: 'true'
126+
TEMPLATE_BRANCH: ${{ github.head_ref || github.ref_name }}
127+
TEMPLATE_REPO: ${{ github.repository }}
136128
run: |
137129
# Configure git identity for the post-gen commit
138130
git config --global user.name "CI Automation"
139131
git config --global user.email "ci@zenable.io"
140132
141-
# Generate a project with all defaults using cookiecutter
142-
uvx --with gitpython cookiecutter . --no-input --output-dir "$env:RUNNER_TEMP"
133+
# Cookiecutter fetches the template from the remote branch.
134+
# This avoids checking out the repo locally, which is impossible on
135+
# Windows due to illegal NTFS characters in the template directory name.
136+
uvx --with gitpython cookiecutter "gh:$env:TEMPLATE_REPO" --checkout "$env:TEMPLATE_BRANCH" --no-input --output-dir "$env:RUNNER_TEMP"
143137
- name: Verify generated project
144138
shell: pwsh
145139
run: |

0 commit comments

Comments
 (0)