-
Notifications
You must be signed in to change notification settings - Fork 5
Add explicit permissions to GitHub Actions workflows #16
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
There was a problem hiding this comment.
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 enhances security by adding explicit minimal permissions to GitHub Actions workflows that previously relied on overly permissive defaults. Following the principle of least privilege, both workflows now explicitly declare they only require read access to repository contents.
- Added
permissions: contents: readat the workflow level to both workflow files - Properly scoped permissions for checkout actions without granting unnecessary access
- NPM publishing continues to use
NODE_AUTH_TOKENsecret, requiring no additional GitHub permissions
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
.github/workflows/nodejs.yml |
Added explicit contents: read permission for the CI workflow that runs tests on push/PR events |
.github/workflows/publish.yml |
Added explicit contents: read permission for the release workflow that publishes to npm |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot There's some failures with the Node CI build can you look at them? |
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
Head branch was pushed to by a user without write access
Fixed in commit ad0bfb4. The CI was failing because Node.js 14 is EOL and not available on macOS ARM64 runners. Upgraded to Node.js 20.x (current LTS) which resolves the compatibility issue. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Adding explicit permissions to GitHub Actions workflow files
Plan:
Summary:
Successfully added explicit
permissions:blocks to both workflow files following the principle of least privilege:Changes Made:
.github/workflows/nodejs.yml:contents: readpermission at workflow level.github/workflows/publish.yml: Addedcontents: readpermission at workflow levelPermissions Analysis:
Both workflows only require:
contents: read- For theactions/checkoutaction to clone the repositoryThe publish workflow uses
NODE_AUTH_TOKENsecret for NPM publishing, which doesn't require any GitHub repository permissions.CI Fix:
The Node CI workflow was failing because Node.js 14 is not available on macOS ARM64 runners (End of Life since April 2023). Upgraded to Node.js 20.x (LTS) which has ARM64 support and active security maintenance.
Validation:
✅ YAML syntax validated successfully
✅ Security scan passed (0 alerts)
✅ Build and lint passed with Node.js 20.x
✅ Minimal changes - only added necessary permissions blocks and fixed Node version
✅ Follows principle of least privilege
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.