Skip to content

Commit de45078

Browse files
committed
fix: a few more typos
1 parent 54edc68 commit de45078

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

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

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ last_modified: 2024-12-13
1717
---
1818

1919

20-
21-
22-
2320
## Is your PyPI publication workflow secure?
2421

2522
The recent Python package breach [involving Ultralytics](https://blog.yossarian.net/2024/12/06/zizmor-ultralytics-injection) has spotlighted the importance of securing your Python package PyPI publishing workflows. The Ultralytics breach was a supply chain attack where malicious actors exploited a GitHub workflow to inject harmful code into a Python package, enabling them to hijack users’ machines for Bitcoin mining. What this means in English:
@@ -49,19 +46,19 @@ The Ultralytics breach is a wake-up call for all maintainers: secure your workfl
4946
### 🔐 Secure your workflows 🔐
5047
- 🚫 Avoid risky events like `pull_request_target` and adopt release-based workflows.
5148
- ♻️ Don’t cache dependencies in your publish workflows to prevent tampering.
52-
- If you reference branches that others may use in a pull request, clean or sanitize branch names in your workflow.
49+
- If you reference branches in a pull request, clean or sanitize branch names in your workflow.
5350

54-
### **Lock down GitHub repo access**
51+
### Lock down GitHub repo access
5552
- 🔒 Restrict repository access to essential maintainers only.
5653
- ✅ Add automated checks to ensure releases are authorized and secure.
5754

58-
### **Strengthen PyPI security**
55+
### Strengthen PyPI security
5956
- 🔑 Set up Trusted Publisher for tokenless authentication with PyPI.
6057
- 📱 Enable 2FA for your PyPI account and store recovery codes securely.
6158

62-
Taking these steps will significantly reduce risks to your packages, contributors, and the broader Python ecosystem. Don’t wait—start securing your workflows today.
59+
These steps will significantly reduce risks to your packages, contributors, and the broader Python ecosystem. Don’t wait—start securing your workflows today.
6360

64-
### **What Happened in the Ultralytics Breach?**
61+
### What happened in the Ultralytics breach?
6562

6663
The Ultralytics incident was a **supply chain attack**—a type of attack where sneaky coders compromise the tools or processes used to create or distribute software. In this case, the bad actors/hackers wanted to use the user's machines to mine Bitcoin. This was a hack with the goal of using other people's compute for illegal profit!
6764

@@ -93,7 +90,7 @@ For this post, we will use [this workflow that pyOpenSci has setup](https://gith
9390
Below, are actionable steps you can take to enhance security when publishing Python packages to PyPI using GitHub actions.
9491

9592

96-
## **1. Avoid `pull_request_target` and consider release-based workflows**
93+
## 1. Avoid `pull_request_target` and consider release-based workflows
9794

9895
The [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) event in GitHub Actions that Ultralytics used, allows workflows to run with elevated permissions on the base branch, even when triggered by changes from a fork. Thus, when used as a trigger to push a release to PyPI, your workflow becomes vulnerable.
9996

@@ -214,12 +211,12 @@ You can see how to set up GitHub Actions securely in our own [PyPI publishing Gi
214211
**Note:** Trusted Publisher workflows are currently only available for GitHub. Support for GitLab may be coming in the future—stay tuned!
215212
{: .notice }
216213

217-
## **5. Create a Dedicated Environment for Publish Actions**
214+
## 5. Create a dedicated environment for publish actions
218215

219216
Use isolated environments in combination with Trusted Publisher in your GitHub workflow to publish to PyPI.
220-
Isolated environments ensure that your publishing process remains secure even if other parts of your CI pipeline are compromised.
217+
Isolated environments ensure your publishing process remains secure even if other parts of your CI pipeline are compromised.
221218

222-
If you look at the pyometra workflow, notice that we have an [environment called `pypi`](https://github.com/pyOpenSci/pyosMeta/blob/main/.github/workflows/publish-pypi.yml#L57) that is used for trusted publishing. By setting this up, we have created a direct pipeline between this action and PyPI via the pypi environment and the trusted publisher setup which refers to the workflow file's name.
219+
If you look at the pyometra workflow, notice that we have an [environment called `pypi`](https://github.com/pyOpenSci/pyosMeta/blob/main/.github/workflows/publish-pypi.yml#L57) that is used for trusted publishing. By setting this up, we have created a direct pipeline between this action and PyPI via the PyPI environment and the trusted publisher setup, which refers to the workflow file's name.
223220

224221
```yaml
225222
publish:
@@ -307,7 +304,7 @@ The good news here is that if you use a release-based workflow as discussed earl
307304

308305
Restricting publish workflows to tagged releases significantly reduces the risk of such attacks.
309306

310-
### Delete Old Tokens
307+
### Delete old tokens
311308

312309
If you are using a trusted publisher workflow but have previously created PyPI API tokens for your package to use in GitHub Actions, it’s time to clean house:
313310

@@ -326,8 +323,22 @@ Important: Store recovery codes securely (e.g., a password manager).
326323
* Be careful about who can gain direct write access to your project's repository. Only a specific, trusted subset of maintainers should be able to trigger a publish-to-PyPI workflow. Most contributors and maintainers don’t need direct write access to your repository; limiting access reduces security risks.
327324

328325

329-
## **Learn More**
326+
## Learn More
330327

331328
pyOpenSci follows best practices for PyPI publishing using our custom GitHub Actions workflow. Check out our tutorial on Python packaging here:
332329
👉 [pyOpenSci Packaging Tutorial](https://www.pyopensci.org/python-package-guide/package-structure-code/python-package-structure.html)
333330
👉 Join our discourse here
331+
332+
## Get involved with pyOpenSci
333+
334+
* Keep an eye on our [events page](/events.html) for upcoming training events.
335+
336+
Follow us on social platforms:
337+
338+
* [<i class="fa-brands fa-discourse"></i> Discourse](https://pyopensci.discourse.group/)
339+
* [<i class="fa-brands fa-mastodon"></i> Mastodon](https://fosstodon.org/@pyopensci)
340+
* [<i class="fa-solid fa-cloud"></i> Bluesky](https://bsky.app/profile/pyopensci.bsky.social)
341+
* [<i class="fa-brands fa-linkedin"></i> LinkedIn](https://www.linkedin.com/company/pyopensci)
342+
* [<i class="fa-brands fa-github"></i> GitHub](https://github.com/pyOpenSci)
343+
344+
If you are on LinkedIn, you should [subscribe to our newsletter, too](https://www.linkedin.com/newsletters/7179551305344933888/?displayConfirmation=true).

0 commit comments

Comments
 (0)