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.
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.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: hyperpolymath/aggregate-library
Length of output: 2016
🤖 get_repo_knowledge executed:
get_repo_knowledge hyperpolymath/aggregate-library /tmp/coderabbit-repo-knowledge/hyperpolymath-aggregate-library-aa0f174eLength of output: 2007
🏁 Script executed:
Repository: hyperpolymath/aggregate-library
Length of output: 2365
🏁 Script executed:
Repository: hyperpolymath/aggregate-library
Length of output: 50387
🌐 Web query:
GitHub Actions reusable workflow secrets inherit secrets.GITHUB_TOKEN called workflow💡 Result:
In GitHub Actions, reusable workflows do not automatically inherit secrets, including the
GITHUB_TOKEN, from the calling workflow [1][2]. You must explicitly pass them using one of two methods [3][4]: 1. Explicit Mapping: You can pass specific secrets individually using thesecretskey in the calling workflow [3][2].yaml jobs: call-workflow: uses: octo-org/example-repo/.github/workflows/reusable-workflow.yml@main secrets: token: ${{ secrets.GITHUB_TOKEN }}Note that while you can pass a custom secret containing a token, the standardGITHUB_TOKENis automatically provided by GitHub Actions to each workflow execution context and is generally not passed as a manually mapped secret in this manner [5]. 2. Inheritance (secrets: inherit): Within the same organization or enterprise, you can use thesecrets: inheritkeyword to pass all secrets available to the calling workflow (including repository, organization, and environment secrets) to the called workflow [3][6][4].yaml jobs: call-workflow: uses: octo-org/example-repo/.github/workflows/reusable-workflow.yml@main secrets: inheritKey Considerations: - Chain Limitations: Secrets are only passed to the directly called workflow [3][4]. In a workflow chain (A > B > C), secrets must be explicitly passed or inherited at each hop; they do not automatically propagate through multiple levels [3][2]. - Security: Usingsecrets: inheritis a convenience mechanism but can violate the principle of least privilege by exposing all available secrets to the called workflow [7][8]. Explicitly mapping only the required secrets is recommended for improved security [7][8]. -GITHUB_TOKENBehavior: TheGITHUB_TOKENis auto-generated for each workflow job based on its defined permissions [5]. If a reusable workflow needs elevated permissions, those must be defined in the reusable workflow itself (within theon.workflow_call.permissionsblock) or limited by the caller's permissions; it cannot "inherit" a token from the caller in the sense of forwarding the caller's specific token instance [2].Citations:
🏁 Script executed:
Repository: hyperpolymath/aggregate-library
Length of output: 6335
🌐 Web query:
site:docs.github.com actions reusable workflow secrets.GITHUB_TOKEN secrets inherit workflow_call💡 Result:
In GitHub Actions, you do not need to explicitly pass the GITHUB_TOKEN to a reusable workflow, nor do you need to use the secrets: inherit keyword for it [1][2]. A called (reusable) workflow is automatically granted access to the GITHUB_TOKEN, which remains available via the secrets.GITHUB_TOKEN or github.token context [1][2][3]. Regarding the broader handling of secrets with reusable workflows: 1. Automatic GITHUB_TOKEN Access: You do not need to map the GITHUB_TOKEN in the on.workflow_call.secrets section of your reusable workflow, nor do you need to pass it in the jobs.<job_id>.secrets block of your caller workflow [1][2]. 2. Passing Custom Secrets: If you need to pass custom (non-GITHUB_TOKEN) secrets to a reusable workflow, you have two primary options: - Explicit Mapping: Define the secrets in the reusable workflow using on.workflow_call.secrets and pass them individually in the caller workflow using jobs.<job_id>.secrets [4][5]. - Inherit All: Use secrets: inherit in the caller workflow to pass all secrets available to the caller to the reusable workflow [6][7]. Note that this keyword is only supported for workflows within the same organization or enterprise [6][8]. 3. Security and Permissions: While the reusable workflow has automatic access to the GITHUB_TOKEN, its permissions are governed by the jobs.<job_id>.permissions block in the caller workflow [1][2]. You can downgrade these permissions in the caller, but they cannot be elevated in the called workflow [1][2]. If no permissions are specified in the caller job, the called workflow uses the default GITHUB_TOKEN permissions [1][2].
Citations:
Remove
secrets: inheritfrom the reusable-workflow call.The pinned workflow declares no secrets and does not use
secrets.*; GitHub providesGITHUB_TOKENautomatically. Inheriting secrets grants it every secret available to this caller without need.🤖 Prompt for AI Agents
Source: Linters/SAST tools