chore: restrict npm release workflow#193
Conversation
📝 WalkthroughWalkthroughThe release workflow adds a default empty permissions block, introduces repository gating conditions on both ChangesGitHub Actions Release Workflow Security Hardening
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/release.yml (2)
23-23: 💤 Low valueConsider adding
persist-credentials: falseto checkout.Static analysis (zizmor) flags that credentials may persist through artifacts. Since this workflow has scoped permissions and repo gating, the risk is low, but setting
persist-credentials: falseis defense in depth.Suggested fix
steps: - uses: actions/checkout@v4 + with: + persist-credentials: false🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/release.yml at line 23, The checkout step using actions/checkout@v4 should explicitly disable credential persistence to avoid leaking tokens to subsequent steps; update the checkout step (the action reference "actions/checkout@v4") to include the input persist-credentials: false (i.e., add a persist-credentials: false key under that step) so credentials are not persisted to the workspace or artifacts.
58-58: 💤 Low valueConsider adding
persist-credentials: falseto checkout.Same as the quality-gates job. In the publish job this is slightly more relevant since
id-token: writeis granted, though the tight permission scope already limits exposure.Suggested fix
steps: - uses: actions/checkout@v4 + with: + persist-credentials: false🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/release.yml at line 58, Update the checkout step in the release job to add persist-credentials: false to the actions/checkout@v4 invocation; locate the checkout step (uses: actions/checkout@v4) in the release workflow and set persist-credentials: false under that step to prevent the action from persisting GITHUB_TOKEN credentials to the workspace while keeping id-token: write behavior as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/release.yml:
- Line 23: Update the workflow steps that reference actions/checkout@v4 and
actions/setup-node@v4 to use the specific commit SHAs instead of tag names:
replace actions/checkout@v4 with
actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 and
actions/setup-node@v4 with
actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 so the release
workflow pins those actions to immutable SHAs.
---
Nitpick comments:
In @.github/workflows/release.yml:
- Line 23: The checkout step using actions/checkout@v4 should explicitly disable
credential persistence to avoid leaking tokens to subsequent steps; update the
checkout step (the action reference "actions/checkout@v4") to include the input
persist-credentials: false (i.e., add a persist-credentials: false key under
that step) so credentials are not persisted to the workspace or artifacts.
- Line 58: Update the checkout step in the release job to add
persist-credentials: false to the actions/checkout@v4 invocation; locate the
checkout step (uses: actions/checkout@v4) in the release workflow and set
persist-credentials: false under that step to prevent the action from persisting
GITHUB_TOKEN credentials to the workspace while keeping id-token: write behavior
as-is.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 300f2a73-94fa-4ebc-841e-cac65748ec5f
📒 Files selected for processing (1)
.github/workflows/release.yml
| contents: read | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Get the latest commit SHA for the v4 tags of the actions used
echo "=== actions/checkout@v4 ==="
gh api repos/actions/checkout/git/refs/tags/v4 --jq '.object.sha' 2>/dev/null || echo "Could not fetch SHA"
echo ""
echo "=== actions/setup-node@v4 ==="
gh api repos/actions/setup-node/git/refs/tags/v4 --jq '.object.sha' 2>/dev/null || echo "Could not fetch SHA"Repository: ton-org/ton
Length of output: 196
Pin actions/checkout@v4 and actions/setup-node@v4 to SHAs
In .github/workflows/release.yml, both actions/checkout@v4 and actions/setup-node@v4 are used and are currently tag-based. Pinning them to commit SHAs hardens the workflow against tag movement/hijacking (current v4 tag SHAs: actions/checkout@v4 → 34e114876b0b11c390a56381ad16ebd13914f8d5, actions/setup-node@v4 → 49933ea5288caeca8642d1e84afbd3f7d6820020).
🧰 Tools
🪛 zizmor (1.25.2)
[warning] 23-23: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[error] 23-23: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/release.yml at line 23, Update the workflow steps that
reference actions/checkout@v4 and actions/setup-node@v4 to use the specific
commit SHAs instead of tag names: replace actions/checkout@v4 with
actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 and
actions/setup-node@v4 with
actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 so the release
workflow pins those actions to immutable SHAs.
novusnota
left a comment
There was a problem hiding this comment.
We might also need to eventually pin all action versions as suggested by CodeRabbitAI in https://github.com/ton-org/ton/pull/193/changes#r3337493863
Summary by CodeRabbit