fix: prevent script injection in analysis workflow#327
Conversation
Move user-controllable workflow_run expressions (head_branch, head_sha, pull request number) to environment variables instead of interpolating them directly in run blocks. Fixes SonarCloud blocker S7630.
Move checks, pull-requests, and actions permissions from workflow level to the specific jobs that need them. Follows principle of least privilege. Fixes SonarCloud S8233 and S8264.
Code Coverage
Updated for commit 4bc0210 |
Unit Tests 62 files ±0 62 suites ±0 3m 11s ⏱️ +12s Results for commit 4bc0210. ± Comparison against base commit c62a51f. This pull request removes 39 and adds 39 tests. Note that renamed tests count towards both. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughGitHub Actions workflow refactored to move permissions from top-level to job-level scope. Environment variables introduced to reference GitHub event workflow data. Updated Sonar and coverage steps to use these variables for PR metadata and API calls instead of inline expressions. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|



Summary
workflow_runexpressions (head_branch,head_sha, PR number) to environment variables instead of interpolating them directly inrunblocksContext
The
analysis.ymlworkflow introduced in #324 interpolatedgithub.event.workflow_run.head_branchdirectly in a shell script. An attacker could craft a branch name with shell metacharacters to inject arbitrary commands. The fix passes all user-controllable values throughenv:instead of${{ }}inrun:blocks.Test plan
Summary by CodeRabbit