Skip to content

ci: add minimum GitHub token permissions for workflow #7430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 0 commits into from
Closed

ci: add minimum GitHub token permissions for workflow #7430

wants to merge 0 commits into from

Conversation

ashishkurmi
Copy link

@ashishkurmi ashishkurmi commented Sep 8, 2022

Description

This PR adds minimum token permissions for the GITHUB_TOKEN in GitHub Actions workflows using https://github.com/step-security/secure-workflows.

The GitHub Actions workflow has a GITHUB_TOKEN with write access to multiple scopes.
Here is an example of the permissions in one of the workflow runs:
https://github.com/kubernetes/dashboard/runs/7993046968?check_suite_focus=true#step:1:19

After this change, the scopes will be reduced to the minimum needed for the following workflow:

  • cd-helm-workflow.yml

The following workflow files already have the least privileged token permission set:

  • cd-workflow.yml
  • ci-helm-workflow.yml
  • ci-workflow.yml
  • codeql-analysis.yml
  • depsreview.yaml

Motivation and Context

Signed-off-by: Ashish Kurmi [email protected]

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 8, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: boahc077 / name: Ashish Kurmi (1aacb2d)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Sep 8, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @boahc077!

It looks like this is your first PR to kubernetes/dashboard 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/dashboard has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 8, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 8, 2022
@ashishkurmi
Copy link
Author

/easycla

@ashishkurmi ashishkurmi changed the title ci: add minimum GitHub token permissions for workflows ci: add minimum GitHub token permissions for workflow Sep 8, 2022
@@ -22,8 +22,14 @@ on:
- 'aio/scripts/helm-release-chart.sh'
- '.github/workflows/cd-helm-workflow.yml'

permissions:
contents: read
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary since we have only one job and you change the permissions below?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, the contents: read is not strictly needed here. Setting that at the workflow level helps if a new job is added to the workflow. In that case, the new job will have contents: read, which is a secure-by-default setting.

@ashishkurmi ashishkurmi requested review from maciaszczykm and removed request for floreks and shu-mutou September 9, 2022 02:51
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 16, 2022
@k8s-ci-robot
Copy link
Contributor

@boahc077: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: boahc077

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants