Skip to content

Commit 566dadc

Browse files
authored
ci: avoid interpolating inputs into run: scripts (#740) (#1914)
Github Actions makes it easy to inject arbitrary shell code into Github Actions scripts thanks to the way its templating language works. This change mediates that issue by passing action inputs to the `run:` scripts as env vars instead of using `${{ }}` expansions directly in the script bodies. The pr_labeler job is the only one that both runs on pull requests and has access to secrets, but we don't interpolate anything other than `github.event.number`, so that wouldn't allow any malicious person to steal credentials. reusable-pip-compile has access to secrets and accepts user input, but only from trusted sources (i.e., developers who already have write access to this repository) and can manually trigger workflows. Still, it's a good to tighten this up. (cherry picked from commit 5ebf9f1) (cherry picked from commit 7d810c6)
1 parent 729b5c0 commit 566dadc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

.github/workflows/labeler.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ jobs:
5353
env:
5454
event_json: "${{ toJSON(github.event) }}"
5555
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}
56-
run:
57-
./venv/bin/python hacking/pr_labeler/label.py issue ${{ github.event.issue.number || inputs.number }}
56+
number: "${{ github.event.issue.number || inputs.number }}"
57+
run: |
58+
./venv/bin/python hacking/pr_labeler/label.py issue "${number}"
5859
- name: "Run the PR labeler"
5960
if: "github.event.pull_request || inputs.type == 'pr'"
6061
env:
6162
event_json: "${{ toJSON(github.event) }}"
6263
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}
63-
run:
64-
./venv/bin/python hacking/pr_labeler/label.py pr ${{ github.event.number || inputs.number }}
64+
number: "${{ github.event.number || inputs.number }}"
65+
run: |
66+
./venv/bin/python hacking/pr_labeler/label.py pr "${number}"

0 commit comments

Comments
 (0)