-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also have zizmor check for low-severity security issues (#14893)
## Summary This PR changes our zizmor configuration to also flag low-severity security issues in our GitHub Actions workflows. It's a followup to #14844. The issues being fixed here were all flagged by [zizmor's `template-injection` rule](https://woodruffw.github.io/zizmor/audits/#template-injection): > Detects potential sources of code injection via template expansion. > > GitHub Actions allows workflows to define template expansions, which occur within special `${{ ... }}` delimiters. These expansions happen before workflow and job execution, meaning the expansion of a given expression appears verbatim in whatever context it was performed in. > > Template expansions aren't syntax-aware, meaning that they can result in unintended shell injection vectors. This is especially true when they're used with attacker-controllable expression contexts, such as `github.event.issue.title` (which the attacker can fully control by supplying a new issue title). [...] > To fully remediate the vulnerability, you should not use `${{ env.VARNAME }}`, since that is still a template expansion. Instead, you should use `${VARNAME}` to ensure that the shell itself performs the variable expansion. ## Test Plan I tested that this passes all zizmore warnings by running `pre-commit run -a zizmor` locally. The other test is obviously to check that the workflows all still run correctly in CI 😄
- Loading branch information
1 parent
5509a3d
commit 033ecf5
Showing
5 changed files
with
24 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,13 +49,11 @@ jobs: | |
- name: "Set branch name" | ||
run: | | ||
version="${{ env.version }}" | ||
display_name="${{ env.display_name }}" | ||
timestamp="$(date +%s)" | ||
# create branch_display_name from display_name by replacing all | ||
# characters disallowed in git branch names with hyphens | ||
branch_display_name="$(echo "$display_name" | tr -c '[:alnum:]._' '-' | tr -s '-')" | ||
branch_display_name="$(echo "${display_name}" | tr -c '[:alnum:]._' '-' | tr -s '-')" | ||
echo "branch_name=update-docs-$branch_display_name-$timestamp" >> $GITHUB_ENV | ||
echo "timestamp=$timestamp" >> $GITHUB_ENV | ||
|
@@ -93,22 +91,18 @@ jobs: | |
run: mkdocs build --strict -f mkdocs.public.yml | ||
|
||
- name: "Clone docs repo" | ||
run: | | ||
version="${{ env.version }}" | ||
git clone https://${{ secrets.ASTRAL_DOCS_PAT }}@github.com/astral-sh/docs.git astral-docs | ||
run: git clone https://${{ secrets.ASTRAL_DOCS_PAT }}@github.com/astral-sh/docs.git astral-docs | ||
|
||
- name: "Copy docs" | ||
run: rm -rf astral-docs/site/ruff && mkdir -p astral-docs/site && cp -r site/ruff astral-docs/site/ | ||
|
||
- name: "Commit docs" | ||
working-directory: astral-docs | ||
run: | | ||
branch_name="${{ env.branch_name }}" | ||
git config user.name "astral-docs-bot" | ||
git config user.email "[email protected]" | ||
git checkout -b $branch_name | ||
git checkout -b "${branch_name}" | ||
git add site/ruff | ||
git commit -m "Update ruff documentation for $version" | ||
|
@@ -117,12 +111,8 @@ jobs: | |
env: | ||
GITHUB_TOKEN: ${{ secrets.ASTRAL_DOCS_PAT }} | ||
run: | | ||
version="${{ env.version }}" | ||
display_name="${{ env.display_name }}" | ||
branch_name="${{ env.branch_name }}" | ||
# set the PR title | ||
pull_request_title="Update ruff documentation for $display_name" | ||
pull_request_title="Update ruff documentation for "${display_name}"" | ||
# Delete any existing pull requests that are open for this version | ||
# by checking against pull_request_title because the new PR will | ||
|
@@ -131,12 +121,12 @@ jobs: | |
xargs -I {} gh pr close {} | ||
# push the branch to GitHub | ||
git push origin $branch_name | ||
git push origin "${branch_name}" | ||
# create the PR | ||
gh pr create --base main --head $branch_name \ | ||
gh pr create --base main --head "${branch_name}" \ | ||
--title "$pull_request_title" \ | ||
--body "Automated documentation update for $display_name" \ | ||
--body "Automated documentation update for "${display_name}"" \ | ||
--label "documentation" | ||
- name: "Merge Pull Request" | ||
|
@@ -145,9 +135,7 @@ jobs: | |
env: | ||
GITHUB_TOKEN: ${{ secrets.ASTRAL_DOCS_PAT }} | ||
run: | | ||
branch_name="${{ env.branch_name }}" | ||
# auto-merge the PR if the build was triggered by a release. Manual builds should be reviewed by a human. | ||
# give the PR a few seconds to be created before trying to auto-merge it | ||
sleep 10 | ||
gh pr merge --squash $branch_name | ||
gh pr merge --squash "${branch_name}" |
This file contains 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
This file contains 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