Skip to content

ci: harden workflow permissions to least privilege#241

Merged
hedgar2017 merged 2 commits intomainfrom
ci/harden-workflow-level-permissions
Feb 26, 2026
Merged

ci: harden workflow permissions to least privilege#241
hedgar2017 merged 2 commits intomainfrom
ci/harden-workflow-level-permissions

Conversation

@nebasuke
Copy link
Member

@nebasuke nebasuke commented Feb 24, 2026

Summary

  • test.yaml: Remove pull-requests: write and checks: write from workflow level; add per-job checks: write only to build-and-test and sanitizer (needed for publish-unit-test-result-action)
  • integration-tests.yaml: Remove pull-requests: write from workflow level; add it only to the integration job (needed for mshick/add-pr-comment)
  • deploy-docs.yaml: Add missing permissions: contents: read at workflow level (was inheriting repo defaults)

No behavioral changes — every job retains the exact permissions it needs, just scoped at the job level instead of inherited broadly.

Test plan

  • test.yaml: Verify build-and-test still publishes check run results and sanitizer works with ci:sanitizer label
  • integration-tests.yaml: Verify integration job can still post PR comments with ci:integration label

Move pull-requests:write and checks:write from workflow level to only
the specific jobs that need them (build-and-test, sanitizer, integration).
Add missing workflow-level permissions: contents:read to deploy-docs.yaml.
@nebasuke nebasuke added ci:sanitizer Trigger sanitizer workflow on PR ci:integration Trigger integration tests workflow on PR labels Feb 24, 2026
@github-actions
Copy link

github-actions bot commented Feb 24, 2026

📊 solx Tester Report

➡️ Download

Copy link

Copilot AI left a 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 hardens GitHub Actions workflow permissions by removing broad workflow-level write access and scoping required write permissions down to the specific jobs that need them, aligning CI with least-privilege principles.

Changes:

  • .github/workflows/test.yaml: Removes workflow-level pull-requests: write / checks: write and grants checks: write only to jobs that publish check runs.
  • .github/workflows/integration-tests.yaml: Removes workflow-level pull-requests: write and grants it only to the job that posts PR comments.
  • .github/workflows/deploy-docs.yaml: Adds explicit workflow-level contents: read while retaining job-level contents: write for deployment.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/test.yaml Scopes checks: write down to build-and-test and sanitizer jobs instead of workflow-wide.
.github/workflows/integration-tests.yaml Scopes pull-requests: write down to the integration job that posts PR comments.
.github/workflows/deploy-docs.yaml Adds explicit workflow-level contents: read to avoid inheriting repo defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Feb 24, 2026

📊 Hardhat Projects Report

➡️ Download

The changes job declares job-level permissions (pull-requests: read),
which overrides the workflow-level permissions entirely. Add explicit
contents: read so actions/checkout retains repo read access.
@github-actions
Copy link

📊 Foundry Projects Report

➡️ Download

@nebasuke nebasuke requested a review from a team February 25, 2026 09:54
@hedgar2017 hedgar2017 merged commit 473e65c into main Feb 26, 2026
20 checks passed
@hedgar2017 hedgar2017 deleted the ci/harden-workflow-level-permissions branch February 26, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:integration Trigger integration tests workflow on PR ci:sanitizer Trigger sanitizer workflow on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants