Conversation
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7 to 8. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@v7...v8) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: '8' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.1 → v0.15.6](astral-sh/ruff-pre-commit@v0.15.1...v0.15.6)
| run: | | ||
| if [ -f pr_number.txt ]; then | ||
| echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_ENV | ||
| else | ||
| echo "pr_number.txt not found, skipping comment." | ||
| exit 0 | ||
| fi |
Check failure
Code scanning / CodeQL
Environment variable built from user-controlled sources Critical
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 28 days ago
In general, to fix this class of issues you must ensure that data written to $GITHUB_ENV cannot contain untrusted newlines or here‑doc delimiters. For single-line variables, strip or reject newline characters from the source before writing; for multi-line variables, use a unique, hard‑to‑guess delimiter. Here, we only need a single-line numeric PR number, so the safest approach is to read pr_number.txt, strip any newlines, and optionally validate that it’s a simple integer, then write that sanitized value into $GITHUB_ENV.
Concretely, in .github/workflows/pr-test-summary.yml, modify the Read PR number step so that instead of echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_ENV, we (1) read the file into a shell variable, (2) delete all newline characters and non‑digits (or reject if invalid), and (3) append a single, sanitized PR_NUMBER=... line to $GITHUB_ENV. For example:
PR_NUMBER_RAW=$(cat pr_number.txt)
PR_NUMBER_SANITIZED=$(printf '%s' "$PR_NUMBER_RAW" | tr -d '\n\r' | tr -cd '0-9')
if [ -z "$PR_NUMBER_SANITIZED" ]; then
echo "Invalid PR number in pr_number.txt, skipping comment."
exit 0
fi
echo "PR_NUMBER=$PR_NUMBER_SANITIZED" >> "$GITHUB_ENV"This keeps functionality (using the PR number from the artifact) while preventing injection via newlines or unexpected characters. No new imports or external dependencies are required; only standard POSIX utilities (cat, printf, tr, basic test) are used.
| @@ -26,7 +26,13 @@ | ||
| - name: Read PR number | ||
| run: | | ||
| if [ -f pr_number.txt ]; then | ||
| echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_ENV | ||
| PR_NUMBER_RAW=$(cat pr_number.txt) | ||
| PR_NUMBER_SANITIZED=$(printf '%s' "$PR_NUMBER_RAW" | tr -d '\n\r' | tr -cd '0-9') | ||
| if [ -z "$PR_NUMBER_SANITIZED" ]; then | ||
| echo "Invalid PR number in pr_number.txt, skipping comment." | ||
| exit 0 | ||
| fi | ||
| echo "PR_NUMBER=$PR_NUMBER_SANITIZED" >> "$GITHUB_ENV" | ||
| else | ||
| echo "pr_number.txt not found, skipping comment." | ||
| exit 0 |
No description provided.