Merged
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideConfigure the PR validation workflow to upload coverage to Codecov using GitHub OIDC instead of a static token, by granting the workflow minimal required permissions and enabling OIDC on the Codecov action step. Sequence diagram for GitHub Actions OIDC authentication with CodecovsequenceDiagram
actor Developer
participant GitHubActions as GitHub_Actions_Workflow
participant GitHubOIDC as GitHub_OIDC_Provider
participant Codecov as Codecov_Service
Developer->>GitHubActions: Push or open pull_request
GitHubActions->>GitHubActions: Start validate_pr workflow (permissions: contents read, id-token write)
GitHubActions->>GitHubOIDC: Request ID token for Codecov audience
GitHubOIDC-->>GitHubActions: Signed OIDC ID token
GitHubActions->>Codecov: Run codecov_action with use_oidc true and coverage.xml
Codecov->>GitHubOIDC: Verify ID token with GitHub OIDC
Codecov-->>GitHubActions: Accept coverage upload (authenticated via OIDC)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Consider scoping the
id-token: writepermission to only the job that performs the Codecov upload instead of setting it at the workflow level, so other jobs keep the most minimal permissions possible.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider scoping the `id-token: write` permission to only the job that performs the Codecov upload instead of setting it at the workflow level, so other jobs keep the most minimal permissions possible.
## Individual Comments
### Comment 1
<location path=".github/workflows/validate_pr.yml" line_range="9-11" />
<code_context>
pull_request:
branches: [main]
+permissions:
+ contents: read
+ id-token: write
+
jobs:
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Consider scoping `id-token: write` to the specific job that needs it instead of at the workflow level.
Defining `id-token: write` at the workflow level gives that permission to every job, including future ones that don’t need OIDC. To limit exposure, move this permission to only the job that runs the Codecov upload (or other OIDC steps) and keep the workflow defaults as restrictive as possible.
Suggested implementation:
```
permissions:
contents: read
```
```
jobs:
lint:
name: Lint
permissions:
id-token: write
with:
files: coverage.xml
fail_ci_if_error: true
use_oidc: true
```
1. Ensure the indentation under the `lint` job is correct YAML (the `with:` block should likely be nested under a specific step, not directly under the job). My change only adds the `permissions` block to the `lint` job; adjust indentation of the surrounding keys to match your existing steps structure.
2. If more jobs in this workflow also require OIDC, add a similar `permissions: id-token: write` block under those specific jobs rather than reintroducing it at the workflow level.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.