Repository navigation
Add explicit least-privilege permissions to CD workflow - #1548
Merged
Li Jiang (thinkall) merged 2 commits intoMay 14, 2026
Merged
Li Jiang (thinkall) merged 2 commits into
Li Jiang (thinkall) merged 2 commits into
Conversation
The CD workflow runs on release publish and: - checks out the repo (read) - builds a Python wheel/sdist via setuptools - uploads to PyPI via twine using PYPI_USERNAME / PYPI_PASSWORD secrets It does not push commits, create GitHub releases, or call the GitHub API for writes; the PyPI upload uses PyPI credentials, not GITHUB_TOKEN. Declaring contents: read at the workflow level documents the minimum scope needed and removes reliance on the repository default token permissions. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Li Jiang (thinkall)
approved these changes
May 14, 2026
Li Jiang (thinkall)
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, thank you very much for the PR, Arpit Jain (@arpitjain099) .
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the GitHub Actions security posture for FLAML’s release publishing pipeline by explicitly setting least-privilege GITHUB_TOKEN permissions in the CD workflow. This aligns CD.yml with other workflows in the repo that already declare explicit permissions and avoids relying on repository-default token scopes.
Changes:
- Add a workflow-level
permissions:block toCD.yml. - Restrict
GITHUB_TOKENtocontents: read, which is sufficient foractions/checkoutin this workflow.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a workflow-level
permissions: contents: readblock to.github/workflows/CD.yml.Why
CD.ymlruns onrelease: publishedand:setuptoolstwineusingPYPI_USERNAME/PYPI_PASSWORDsecretsIt does not push commits, create GitHub releases, or call the GitHub API for any write. The PyPI upload uses PyPI credentials, not
GITHUB_TOKEN. The token only needs read access for the checkout step.Declaring
contents: readat the workflow level documents the minimum scope needed and removes reliance on the repository default token permissions, which is recommended by GitHub for defense in depth.Sibling FLAML workflows (
pre-commit.yml,python-package.yml,openai.yml,deploy-website.yml) already declare permissions; this bringsCD.ymlin line with that pattern.Verification
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/CD.yml'))"passes.permissions:block is added.Reference
GitHub docs — Modifying the permissions for the GITHUB_TOKEN.