Skip to content

fix: add permissions for reusable publish-preview workflow - #8235

Merged
cryptodev-2s merged 1 commit into
mainfrom
fix/preview-workflow-permissions
Mar 18, 2026
Merged

cryptodev-2s merged 1 commit into
mainfrom
fix/preview-workflow-permissions

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

The reusable publish-preview workflow from github-tools requires contents: read (checkout) and pull-requests: write (PR comment). MetaMask's org restricts default token permissions to read-only, so these must be explicitly declared by the caller.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Low risk: only updates workflow permissions, with no product code or runtime logic changes.

Overview
Ensures the reusable publish-preview GitHub Actions workflow can run under restricted org defaults by explicitly granting contents: read (checkout) and pull-requests: write (PR commenting) permissions.

Written by Cursor Bugbot for commit cd67686. This will update automatically on new commits. Configure here.

@cryptodev-2s
cryptodev-2s requested a review from a team as a code owner March 18, 2026 17:08
@cryptodev-2s cryptodev-2s self-assigned this Mar 18, 2026
@cryptodev-2s
cryptodev-2s enabled auto-merge March 18, 2026 17:09
@cryptodev-2s
cryptodev-2s added this pull request to the merge queue Mar 18, 2026
Merged via the queue into main with commit 865b292 Mar 18, 2026
322 checks passed
@cryptodev-2s
cryptodev-2s deleted the fix/preview-workflow-permissions branch March 18, 2026 17:19
gaohan1994 pushed a commit to gaohan1994/core that referenced this pull request Oct 27, 2026
…ask#11091)

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Explanation

`@metamaskbot publish-preview` calls the shared `MetaMask/github-tools`
preview workflow. That workflow checks out the repository and comments
on the pull request, so the caller has to grant `contents: read` and
`pull-requests: write`. The org token is read-only by default, which is
why [MetaMask#8235](MetaMask#8235) added both
permissions on this workflow.

zizmor reports workflow-level `pull-requests: write` as overly broad
([code scanning alert
206](https://github.com/MetaMask/core/security/code-scanning/206)). A
job-level `permissions` block replaces the workflow set rather than
adding to it, so this keeps `contents: read` on the workflow and on the
`publish-preview` job, and moves `pull-requests: write` onto that job
only. The shared workflow is unchanged.

The same finding showed up on
[MetaMask/metamask-design-system#1620](MetaMask/metamask-design-system#1620).
That change adopted this shared caller to fix a preview-token code
scanning alert, and zizmor then flagged `pull-requests: write` on the
workflow. This applies that permissions fix to the core caller.

## References

* https://github.com/MetaMask/core/security/code-scanning/206
* MetaMask/metamask-design-system#1620
* MetaMask#8235

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-b46f099e-f000-4c02-a647-6cd765c63abf?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-b46f099e-f000-4c02-a647-6cd765c63abf&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> CI permission scoping only; no application or secrets logic changes,
with the same effective permissions on the job that runs the preview
workflow.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7c4a5b1. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
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.

2 participants