Skip to content

Conversation

@sashashura
Copy link
Contributor

What:
This PR adds explicit permissions section to workflows.

Why:
This is a security best practice because by default workflows run with extended set of permissions (except from on: pull_requestfrom external forks). By specifying any permission explicitly all others are set to none. By using the principle of least privilege the damage a compromised workflow can do (because of an injection or compromised third party tool or action) is restricted.

How:
It is recommended to have most strict permissions on the top level and grant write permissions on job level case by case.

Checklist:

  • Documentation added to the
    docs site N/A
  • Tests N/A
  • TypeScript definitions updated N/A
  • Ready to be merged

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 8e1855e:

SandboxSource
ReactConfiguration
react-testing-library-examplesConfiguration

@codecov
Copy link

codecovbot commented Dec 8, 2022

Codecov Report

Merging #1162 (8e1855e) into main (801ad37) will not change coverage.
The diff coverage is n/a.

@@ Coverage Diff @@## main #1162 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 4 4 Lines 181 181 Branches 36 36 ========================================= Hits 181 181 
FlagCoverage Δ
experimental100.00% <ø> (ø)
latest100.00% <ø> (ø)
next100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

- '!all-contributors/**'
pull_request: {}
permissions:
actions: write # to cancel/stop running workflows (styfle/cancel-workflow-action)
Copy link
Member

Choose a reason for hiding this comment

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

Could you include a summary of the permissions before and after for each change?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Before the change for all jobs (as seen here https://github.com/testing-library/react-testing-library/actions/runs/3633193928/jobs/6129924592):

GITHUB_TOKEN Permissions Actions: write Checks: write Contents: write Deployments: write Discussions: write Issues: write Metadata: read Packages: write Pages: write PullRequests: write RepositoryProjects: write SecurityEvents: write Statuses: write 

After the change
For the release job (not mention permissions are none):

GITHUB_TOKEN Permissions Actions: write Contents: write Metadata: read 

For all others:

GITHUB_TOKEN Permissions Actions: write Contents: read Metadata: read 

Copy link
Member

@eps1loneps1lon left a comment

Choose a reason for hiding this comment

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

Sweet, thanks!

@eps1loneps1lon merged commit c43512a into testing-library:mainDec 12, 2022
@eps1lon
Copy link
Member

This was missing issues: write for semantic-release. Fixing in #1176

Sign up for freeto 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.

2 participants

@sashashura@eps1lon