Skip to content

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#27

Merged
dcramer merged 1 commit intomainfrom
alert-autofix-3
Jan 29, 2026
Merged

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#27
dcramer merged 1 commit intomainfrom
alert-autofix-3

Conversation

@dcramer
Copy link
Member

@dcramer dcramer commented Jan 29, 2026

Potential fix for https://github.com/getsentry/warden/security/code-scanning/3

In general, the fix is to explicitly declare least‑privilege permissions for the workflow or job so that GITHUB_TOKEN is restricted instead of inheriting broad defaults. For this workflow, we only need read access to repository contents (for checkout and reading metadata), because any write operations (comments, status updates, labels, etc.) should use the GitHub App token already being created.

The best minimal fix is to add a permissions block at the workflow root (top level, alongside name and on) with contents: read. This applies to all jobs, including review, and does not change functional behavior other than limiting the inherited GITHUB_TOKEN capabilities. No additional imports or methods are needed, only a YAML edit in .github/workflows/warden.yml near the top of the file. If later you discover that some step truly requires more scopes on GITHUB_TOKEN, you can selectively add them, but the safe default is contents: read.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
warden Ready Ready Preview, Comment Jan 29, 2026 11:33pm

Request Review

@sentry-warden
Copy link
Contributor

sentry-warden bot commented Jan 29, 2026

security-review

security-review: No issues found

No findings to report.

@dcramer dcramer marked this pull request as ready for review January 29, 2026 23:42
@dcramer dcramer merged commit b3e5218 into main Jan 29, 2026
12 checks passed
@dcramer dcramer deleted the alert-autofix-3 branch January 29, 2026 23:42
dcramer added a commit that referenced this pull request Jan 29, 2026
Add explicit `permissions: contents: read` to both workflow examples
in the setup docs to match PR #27's security fix. This ensures users
following the docs create workflows with least-privilege permissions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
dcramer added a commit that referenced this pull request Jan 30, 2026
Add explicit `permissions: contents: read` to both workflow examples in
the setup documentation.

PR #27 adds this security fix to the actual
`.github/workflows/warden.yml` file, but the docs templates that users
copy were missing it. This ensures users following the setup guide
create workflows with least-privilege permissions from the start.

Refs #27

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.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.

1 participant