FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add `permissions: {}` to all reusable workflows by ezio-melotti · Pull Request #148114 · python/cpython · GitHub

Repository navigation

Add permissions: {} to all reusable workflows - #148114

Merged
ezio-melotti merged 1 commit into
python:mainfrom
ezio-melotti:3.15-reusable-permissions
Apr 4, 2026
Merged

ezio-melotti merged 1 commit into
python:mainfrom
ezio-melotti:3.15-reusable-permissions

Conversation

Copy link
Copy Markdown
Member

This PR explicitly adds permissions: {} to all reusable workflows, solving a number of CodeQL issues.

Technically, this is not strictly needed, since the reusable workflows inherits the permissions of the caller, however doing so has 3 advantages:

  1. it solves the CodeQL issues;
  2. it explicitly defines the permissions in each reusable workflow;
  3. if the caller redefines its permissions to be more permissive, the reusable workflows are unaffected;

I also tightened the permissions of a few workflows that had permissions: contents: read, and tested on my fork that everything still works fine.

ezio-melotti requested a review from sethmlarson April 4, 2026 22:02
ezio-melotti self-assigned this Apr 4, 2026
ezio-melotti requested a review from a team as a code owner April 4, 2026 22:02
ezio-melotti added 3.13 only security fixes 3.14 bugs and security fixes needs backport to 3.13 only security fixes infra CI, GitHub Actions, buildbots, Dependabot, etc. needs backport to 3.14 bugs and security fixes 3.15 bugs and security fixes labels Apr 4, 2026
ezio-melotti merged commit 1f36a51 into python:main Apr 4, 2026
81 checks passed

Copy link
Copy Markdown

Thanks @ezio-melotti for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

Copy link
Copy Markdown

Sorry, @ezio-melotti, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1f36a510a2a16e8ff15572f44090c7db43bb7935 3.14

Copy link
Copy Markdown

Sorry, @ezio-melotti, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1f36a510a2a16e8ff15572f44090c7db43bb7935 3.13

bedevere-app Bot commented Apr 4, 2026

Copy link
Copy Markdown

GH-148115 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Apr 4, 2026

bedevere-app Bot commented Apr 4, 2026

Copy link
Copy Markdown

GH-148116 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 only security fixes label Apr 4, 2026

Copy link
Copy Markdown

Thanks @ezio-melotti for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

Copy link
Copy Markdown

Sorry, @ezio-melotti, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1f36a510a2a16e8ff15572f44090c7db43bb7935 3.10

Copy link
Copy Markdown

Sorry, @ezio-melotti, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1f36a510a2a16e8ff15572f44090c7db43bb7935 3.11

Copy link
Copy Markdown

Sorry, @ezio-melotti, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1f36a510a2a16e8ff15572f44090c7db43bb7935 3.12

bedevere-app Bot commented Apr 5, 2026

Copy link
Copy Markdown

GH-148122 is a backport of this pull request to the 3.12 branch.

bedevere-app Bot removed the needs backport to 3.12 only security fixes label Apr 5, 2026

bedevere-app Bot commented Apr 5, 2026

Copy link
Copy Markdown

GH-148123 is a backport of this pull request to the 3.11 branch.

bedevere-app Bot removed the needs backport to 3.11 only security fixes label Apr 5, 2026
ezio-melotti added a commit to ezio-melotti/cpython that referenced this pull request Apr 5, 2026
Add permissions: {} to all reusable workflows

(cherry picked from commit 1f36a51)
ezio-melotti added a commit that referenced this pull request Apr 5, 2026
…8122)

Add `permissions: {}` to all reusable workflows (#148114)

Add permissions: {} to all reusable workflows

(cherry picked from commit 1f36a51)

brandtbucher commented Apr 8, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

Just a head-up that this breaks CI on private forks, I think (since now they can't read the repo anymore).

webknjaz commented Apr 8, 2026

Copy link
Copy Markdown
Member

Yep, the content privilege is implicit in public repos. It may make sense to have it everywhere with actions/checkout. But perhaps on the job level instead of workflow..

hugovk commented Apr 8, 2026

Copy link
Copy Markdown
Member

The motivation for this PR was to satisfy the CodeQL scanner, and make sure we have some at least ~minimal default at the top level.

I think we're fine with using this everywhere:

permissions:
  contents: read

It does this:

contents: Work with the contents of the repository. For example, contents: read permits an action to list the commits [...]

https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#permissions

Copy link
Copy Markdown
Member

Yep, that works! Do you want to fix it, or should I?

brandtbucher commented Apr 8, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

I also wonder if that's a worthwhile CodeQL lint, or we should just disable it. contents: read is already the default (and a reasonable one that's unlikely to change). "Fixing" the lint by repeating the default just seems to add more noise to some already noisy files.

hugovk commented Apr 8, 2026

Copy link
Copy Markdown
Member

Yep, that works! Do you want to fix it, or should I?

I can probably do it tomorrow, but feel free to do it yourself before that :)

contents: read is already the default (and a reasonable one that's unlikely to change).

If only it was this simple :)

It's something like this: for older orgs/repos, the default is permissive, with read/write for all scopes. Newer ones have a restricted default, read-only for contents and packages. There's also repo and org settings to adjust this.

And then there's forks...

So explicit is good here.

hugovk commented Apr 10, 2026

Copy link
Copy Markdown
Member

Follow up: #148346

This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.13 only security fixes 3.14 bugs and security fixes 3.15 bugs and security fixes infra CI, GitHub Actions, buildbots, Dependabot, etc. skip issue skip news type-security A security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL