镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Add explicit least-privilege permissions to CD workflow - #1548

Merged
Li Jiang (thinkall) merged 2 commits into
microsoft:mainfrom
arpitjain099:security/workflow-permissions-cd
May 14, 2026
Merged

Li Jiang (thinkall) merged 2 commits into
microsoft:mainfrom
arpitjain099:security/workflow-permissions-cd

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

What

Adds a workflow-level permissions: contents: read block to .github/workflows/CD.yml.

Why

CD.yml runs on release: published and:

  • checks out the repository
  • installs the package
  • builds 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 any write. The PyPI upload uses PyPI credentials, not GITHUB_TOKEN. The token only needs read access for the checkout step.

Declaring contents: read at 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 brings CD.yml in line with that pattern.

Verification

  • python3 -c "import yaml; yaml.safe_load(open('.github/workflows/CD.yml'))" passes.
  • No change to job steps or matrix; only the workflow-level permissions: block is added.

Reference

GitHub docs — Modifying the permissions for the GITHUB_TOKEN.

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>

@thinkall Li Jiang (thinkall) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you very much for the PR, Arpit Jain (@arpitjain099) .

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to CD.yml.
  • Restrict GITHUB_TOKEN to contents: read, which is sufficient for actions/checkout in this workflow.

@thinkall
Li Jiang (thinkall) merged commit 66ae31f into microsoft:main May 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants