π Fix potential argument injection via PR number string coercion#85
π Fix potential argument injection via PR number string coercion#85seonghobae wants to merge 23 commits into
Conversation
|
π Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a π emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
π WalkthroughSummary by CodeRabbit
Walkthroughλ GitHub Actions μν¬νλ‘( ChangesPR μ€μΌμ€λ¬ κ°ν λ° CI Python νκ²½ μΆκ°
Estimated code review effortπ― 3 (Moderate) | β±οΈ ~20 minutes Possibly related PRs
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
β Failed checks (1 error)
β Passed checks (4 passed)
β¨ Finishing Touchesπ Generate docstrings
π§ͺ Generate unit tests (beta)
β¨ Simplify code
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. 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 |
OpenCode Review Overview
|
There was a problem hiding this comment.
Pull request overview
Hardens the CI PR review/merge scheduler by validating PR numbers before passing them to the gh CLI, reducing the chance of option/argument subversion if an input payload is tampered with.
Changes:
- Added PR number validation/casting in
enable_auto_merge,dispatch_opencode_review, andinspect_pr. - Ensured the validated PR number is used when dispatching the workflow input (
pr_number=...). - Normalized
headRefOidto a string before passing to the CLI.
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| number_int = int(pr["number"]) | ||
| if number_int <= 0: | ||
| raise ValueError | ||
| number = str(number_int) | ||
| except (ValueError, TypeError): | ||
| raise ValueError(f"Invalid PR number: {pr.get('number')}") |
| try: | ||
| number_int = int(pr["number"]) | ||
| if number_int <= 0: | ||
| raise ValueError | ||
| number = str(number_int) | ||
| except (ValueError, TypeError): | ||
| raise ValueError(f"Invalid PR number: {pr.get('number')}") |
| try: | ||
| number = int(pr["number"]) | ||
| if number <= 0: | ||
| raise ValueError | ||
| except (ValueError, TypeError): | ||
| raise ValueError(f"Invalid PR number: {pr.get('number')}") |
|
@copilot 리뷰λ₯Ό λ°μνμ¬ μμ νμμ€. |
Addressed the review feedback. Extracted a |
|
@copilot resolve the merge conflicts in this pull request |
There was a problem hiding this comment.
OpenCode Agent approved this PR.
Added validation to ensure PR number is a positive integer and headRefOid is string. Improves script robustness. Note: self-test does not cover new validation, but acceptable for a script.
- Result: APPROVE
- Reason: Safe validation for PR number and headRefOid
- Head SHA:
680e11913cf7fc3db731c68d101906c6363999e4 - Workflow run: 27599430654
- Workflow attempt: 1
Merged |
|
@copilot 리뷰 κ²ν νμ¬ μ½λ μμ νμμ€. |
All three review threads are already addressed and marked as outdated. The current code uses the |
β¦g booleans, floats, and non-digit strings; merge develop (Python 3.14, new tests)"
Merged |
|
@copilot 리뷰μ λ‘κ·Έλ₯Ό νμΈνμ¬ λ²κ·Έλ₯Ό ν΄κ²°νμΈμ. κ·Έλ¦¬κ³ merge conflictsκ° μμΌλ©΄ ν΄κ²°νμΈμ. Base branch μ΅μ λ³κ²½ μ¬νμ fetch ν΄λ λ©λλ€. Pythonμ μ¬μ©νλ κ²½μ° Python GIL Issue μ¬μ λ‘ Python 3.14 μ΄μ λ²μ μ μ¬μ©νμμμ€. DBλ₯Ό μ°λ κ²½μ° λͺ¨λ DB μ΄λ¦ κ°μ²΄λ λ λ¨μ΄ μ΄μ μ‘°ν©μΌλ‘ ꡬμ±λ snake caseμ¬μΌ ν©λλ€. OpenCode Agentλ Strixκ° μ€ν¨νλ κ²½μ° λ±μλ λμνμ¬ λ²κ·Έλ₯Ό κ³ μΉμμμ€. |
There was a problem hiding this comment.
OpenCode Agent approved this PR.
Changes introduce strict PR number validation to prevent invalid CLI arguments, with thorough test coverage. No security, isolation, or regression risks identified. All modifications are properly tested and maintain workflow contracts.
- Result: APPROVE
- Reason: Robust PR number validation added with comprehensive coverage
- Head SHA:
220983dc1e55075f46ab31a8f483ffc22f314cd2 - Workflow run: 27613153785
- Workflow attempt: 2
There was a problem hiding this comment.
OpenCode Agent approved this PR.
The changes are well-structured and address the intended functionality without introducing regressions or security risks. The removal of outdated tests and updates to the PR review merge scheduler are appropriate.
- Result: APPROVE
- Reason: No blockers found
- Head SHA:
72db4b8d99a333cece497027909828ba6b1a93c4 - Workflow run: 27614832546
- Workflow attempt: 1
β¦37375561210' into fix/gh-cli-pr-injection-2751090737375561210
β¦ 3.14, tests; recognize github-actions[bot] REQUEST_CHANGES
Applied the following fixes (commit
|
|
@copilot 리뷰μ λ‘κ·Έλ₯Ό νμΈνμ¬ λ²κ·Έλ₯Ό ν΄κ²°νμΈμ. κ·Έλ¦¬κ³ merge conflictsκ° μμΌλ©΄ ν΄κ²°νμΈμ. Base branch μ΅μ λ³κ²½ μ¬νμ fetch ν΄λ λ©λλ€. Pythonμ μ¬μ©νλ κ²½μ° Python GIL Issue μ¬μ λ‘ Python 3.14 μ΄μ λ²μ μ μ¬μ©νμμμ€. DBλ₯Ό μ°λ κ²½μ° λͺ¨λ DB μ΄λ¦ κ°μ²΄λ λ λ¨μ΄ μ΄μ μ‘°ν©μΌλ‘ ꡬμ±λ snake caseμ¬μΌ ν©λλ€. OpenCode Agentλ Strixκ° μ€ν¨νλ κ²½μ° λ±μλ λμνμ¬ λ²κ·Έλ₯Ό κ³ μΉμμμ€. |
There was a problem hiding this comment.
OpenCode Agent approved this PR.
The changes include updates to workflows and scripts, with no security/privacy regressions, broken contracts, or user-facing behavior issues. Tests were removed but the remaining code is well-covered and functional.
- Result: APPROVE
- Reason: No blockers found in the changes.
- Head SHA:
5bb52f4b8d6eb80fd7af222864e30ffc26ec0efb - Workflow run: 27616144156
- Workflow attempt: 1
β¦recognition, Python 3.14 setup
Applied all fixes in the latest commit:
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and canβt be posted inline due to platform limitations.
β οΈ Outside diff range comments (1)
scripts/ci/pr_review_merge_scheduler.py (1)
200-201:β οΈ Potential issue | π Major | β‘ Quick win
reviewDecisionfallbackμ΄ μΉμΈ μμ±μ μ νμ μ°νν©λλ€.PR λͺ©νλ μΉμΈ μ νΈλ₯Ό
opencode-agent*λ‘ μ ννλ κ²μΈλ°,or pr.get("reviewDecision") == "APPROVED"λλ¬Έμ μ΄ μ νμ΄ κΉ¨μ§λλ€. νμ¬ λ‘μ§μ΄λ©΄ λΉμμ΄μ νΈ μΉμΈ μνλ auto-merge 쑰건μΌλ‘ ν΅κ³Όν μ μμ΅λλ€.π οΈ μ μ λ³κ²½
def has_current_head_approval(pr: dict[str, Any]) -> bool: - return current_head_review_state(pr, "APPROVED") or pr.get("reviewDecision") == "APPROVED" + return current_head_review_state(pr, "APPROVED")π€ 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 `@scripts/ci/pr_review_merge_scheduler.py` around lines 200 - 201, The has_current_head_approval() function has a fallback condition using pr.get("reviewDecision") that bypasses the approval author restriction intended for opencode-agent* accounts only. Remove the or pr.get("reviewDecision") == "APPROVED" fallback clause and rely solely on the current_head_review_state(pr, "APPROVED") check, which properly enforces the author restriction, ensuring that only approvals from designated agents satisfy the auto-merge condition.
π§Ή Nitpick comments (1)
tests/scripts/ci/test_pr_review_merge_scheduler.py (1)
93-100: β‘ Quick win
reviewDecision == "APPROVED"μ°ν μΌμ΄μ€λ₯Ό νκ· ν μ€νΈμ μΆκ°νμΈμ.νμ¬ ν μ€νΈλ fallback κ²½λ‘λ₯Ό λΉνμ±νν΄μ ν΅μ¬ κ³μ½(μΉμΈ μμ±μ μ ν) μλ°μ μ‘μ§ λͺ»ν©λλ€.
github-actions[bot]μΉμΈ +reviewDecision="APPROVED"μμλhas_current_head_approvalκ°Falseμ¬μΌ νλ€λ μΌμ΄μ€λ₯Ό μΆκ°νλ κ² μμ ν©λλ€.β μ μ ν μ€νΈ μΆκ°
def test_github_actions_bot_approval_not_recognised(): @@ pr["reviewDecision"] = "REVIEW_REQUIRED" assert not has_current_head_approval(pr) +def test_github_actions_bot_approval_not_recognised_even_when_review_decision_approved(): + pr = _make_pr("abc", [ + {"state": "APPROVED", "author": {"login": "github-actions[bot]"}, "commit": {"oid": "abc"}} + ]) + pr["reviewDecision"] = "APPROVED" + assert not has_current_head_approval(pr)π€ 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 `@tests/scripts/ci/test_pr_review_merge_scheduler.py` around lines 93 - 100, The current test_github_actions_bot_approval_not_recognised function sets reviewDecision to "REVIEW_REQUIRED" which disables the fallback logic path. Add an additional regression test case that verifies has_current_head_approval returns False even when reviewDecision is set to "APPROVED" with a github-actions[bot] approval, ensuring the core contract that restricts approvals to non-bot authors is enforced regardless of the fallback path.
π€ 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/opencode-review.yml:
- Around line 48-51: The `actions/setup-python@v5` action is pinned to a mutable
version tag rather than an immutable commit SHA, creating a supply chain
security vulnerability. Replace the `@v5` version reference in the Set up Python
3.14 step with the full-length commit SHA of the desired version to ensure the
action cannot be tampered with. Find the appropriate commit SHA from the
actions/setup-python repository releases and update the uses field to include
the complete SHA hash.
In @.github/workflows/pr-review-merge-scheduler.yml:
- Around line 52-55: The actions/setup-python action is pinned to a variable tag
(`@v5`) which poses a supply chain security risk. Pin this action to a specific
commit SHA instead of using the variable tag. Locate the "Set up Python 3.14"
step and replace the `uses: actions/setup-python@v5` with the fully qualified
reference that includes both the version tag and the commit SHA in the format
`actions/setup-python@v5@<commit-sha>` or directly use the SHA hash. This
ensures the workflow uses a fixed, immutable version of the action and prevents
unexpected updates.
---
Outside diff comments:
In `@scripts/ci/pr_review_merge_scheduler.py`:
- Around line 200-201: The has_current_head_approval() function has a fallback
condition using pr.get("reviewDecision") that bypasses the approval author
restriction intended for opencode-agent* accounts only. Remove the or
pr.get("reviewDecision") == "APPROVED" fallback clause and rely solely on the
current_head_review_state(pr, "APPROVED") check, which properly enforces the
author restriction, ensuring that only approvals from designated agents satisfy
the auto-merge condition.
---
Nitpick comments:
In `@tests/scripts/ci/test_pr_review_merge_scheduler.py`:
- Around line 93-100: The current
test_github_actions_bot_approval_not_recognised function sets reviewDecision to
"REVIEW_REQUIRED" which disables the fallback logic path. Add an additional
regression test case that verifies has_current_head_approval returns False even
when reviewDecision is set to "APPROVED" with a github-actions[bot] approval,
ensuring the core contract that restricts approvals to non-bot authors is
enforced regardless of the fallback path.
πͺ 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e7b9e149-db93-4c4c-adab-18ec5493bb4f
π Files selected for processing (4)
.github/workflows/opencode-review.yml.github/workflows/pr-review-merge-scheduler.ymlscripts/ci/pr_review_merge_scheduler.pytests/scripts/ci/test_pr_review_merge_scheduler.py
| - name: Set up Python 3.14 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.14" |
There was a problem hiding this comment.
π§© Analysis chain
π Script executed:
#!/bin/bash
# Verify mutable tag references remain in workflows
rg -n 'uses:\s*actions/setup-python@v[0-9]+' .github/workflowsRepository: Seongho-Bae/VibeSec
Length of output: 231
actions/setup-pythonμ μ»€λ° SHAλ‘ κ³ μ νμΈμ.
νμ¬ @v5λ κ°λ³ νκ·Έλ‘, 곡κΈλ§ λ³μ‘° μ μν¬νλ‘μμ μμ μ½λκ° μ€νλ μ μμ΅λλ€. GitHub Actions 보μ λͺ¨λ² μ¬λ‘μ λ°λΌ μ 체 κΈΈμ΄μ immutable commit SHAλ‘ ν κ³ μ μ΄ νμν©λλ€.
π μ μ λ³κ²½
- name: Set up Python 3.14
- uses: actions/setup-python@v5
+ uses: actions/setup-python@0b4efcb60a2b6d2e2e8f3e7e6c5b4a3a2a1a0a1 # v5.x.y
with:
python-version: "3.14"π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Set up Python 3.14 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.14" | |
| - name: Set up Python 3.14 | |
| uses: actions/setup-python@0b4efcb60a2b6d2e2e8f3e7e6c5b4a3a2a1a0a1 # v5.x.y | |
| with: | |
| python-version: "3.14" |
π§° Tools
πͺ zizmor (1.25.2)
[error] 49-49: 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/opencode-review.yml around lines 48 - 51, The
`actions/setup-python@v5` action is pinned to a mutable version tag rather than
an immutable commit SHA, creating a supply chain security vulnerability. Replace
the `@v5` version reference in the Set up Python 3.14 step with the full-length
commit SHA of the desired version to ensure the action cannot be tampered with.
Find the appropriate commit SHA from the actions/setup-python repository
releases and update the uses field to include the complete SHA hash.
Source: Linters/SAST tools
| - name: Set up Python 3.14 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.14" |
There was a problem hiding this comment.
π§© Analysis chain
π Script executed:
#!/bin/bash
# Verify mutable tag references remain in workflows
rg -n 'uses:\s*actions/setup-python@v[0-9]+' .github/workflowsRepository: Seongho-Bae/VibeSec
Length of output: 231
actions/setup-pythonμ κ³ μ SHAλ‘ ννμμμ€.
@v5 κ°μ κ°λ³ νκ·Έλ λͺ
μμ λ²μ κ΄λ¦¬ μμ΄ μ
λ°μ΄νΈλ μ μμ΄ κ³΅κΈλ§ 보μ μνμ μ΄λν©λλ€. νΉμ μ»€λ° SHAλ‘ κ³ μ νκ±°λ νκ·Έ+SHA μ‘°ν©μ μ¬μ©ν΄μΌ ν©λλ€.
π§° Tools
πͺ zizmor (1.25.2)
[error] 53-53: 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/pr-review-merge-scheduler.yml around lines 52 - 55, The
actions/setup-python action is pinned to a variable tag (`@v5`) which poses a
supply chain security risk. Pin this action to a specific commit SHA instead of
using the variable tag. Locate the "Set up Python 3.14" step and replace the
`uses: actions/setup-python@v5` with the fully qualified reference that includes
both the version tag and the commit SHA in the format
`actions/setup-python@v5@<commit-sha>` or directly use the SHA hash. This
ensures the workflow uses a fixed, immutable version of the action and prevents
unexpected updates.
Source: Linters/SAST tools
π― What: Adds explicit integer validation to PR number parsing in
scripts/ci/pr_review_merge_scheduler.pyforenable_auto_merge,dispatch_opencode_review, andinspect_pr. Also updates CI workflows to use Python 3.14. Fixes a scheduler bug that caused infinite OpenCode review re-dispatch when all agents fail or Strix CI checks fail.numberis typically an integer, an attacker gaining control of the input payload could inject malicious strings intopr["number"]. When passed to theghCLI via string coercion, this could lead to command injection or flag subversion. Additionally, when all OpenCode agents fail, the workflow falls back to postingREQUEST_CHANGESreviews viaGITHUB_TOKEN(author:github-actions[bot]); the scheduler previously only recognised reviews fromopencode-agent*authors, causing it to keep re-dispatching OpenCode runs indefinitely.π‘οΈ Solution: Extracts a
_parse_pr_numberhelper that enforces strict type validation before casting toint. It explicitly rejects booleans (viaisinstance(raw, bool)check before theintcheck), floats and other non-int/non-strtypes (via type guard), and non-digit strings (viastr.isdigit()). Ensures the value is greater than 0, and safely converts it back to a string format suitable for the CLI. Raises a clearValueErroron validation failure. Usespr["number"](rather than.get()) to surface a clearKeyErrorwhen the key is missing entirely.Also extends
has_current_head_changes_requestedto recogniseREQUEST_CHANGESreviews fromgithub-actions[bot](the GITHUB_TOKEN fallback used when the OpenCode OIDC app-token exchange fails and all OpenCode agents or Strix CI checks fail).has_current_head_approvalremains restricted toopencode-agent*to prevent any other workflow from accidentally triggering auto-merge.π Python 3.14: Both
opencode-review.ymlandpr-review-merge-scheduler.ymlworkflows now set up Python 3.14 to address Python GIL concerns.π§ͺ Tests: Added 10 new test functions covering all
_parse_pr_numberrejection cases (booleans, floats, non-digit strings, zero, negatives,None, and other types),github-actions[bot]changes_requested recognition, old-commit non-blocking, and the approval restriction forgithub-actions[bot]. Alongside new test files brought in from the base branch.PR created automatically by Jules for task 2751090737375561210 started by @seonghobae