Skip to content

fix(security): isolate privileged review dispatch - #635

Merged
seonghobae merged 3 commits into
mainfrom
codex/fix-opencode-untrusted-checkout
Jul 29, 2026
Merged

fix(security): isolate privileged review dispatch#635
seonghobae merged 3 commits into
mainfrom
codex/fix-opencode-untrusted-checkout

Conversation

@seonghobae

@seonghobae seonghobae commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep the organization-required opencode-review.yml as a metadata-only pull_request_target bootstrap
  • move PR-head materialization, bounded coverage, model execution, and review publication to a default-branch-only repository_dispatch workflow
  • update Strix source discovery, review contracts, and governance documentation for the split

This structurally addresses default-branch CodeQL Critical alerts #182-#185 (actions/untrusted-checkout/critical) without dismissing them.

Verification

  • python3 -m pytest -q (641 passed)
  • bash scripts/ci/test_opencode_fact_gate_contract.sh
  • bash scripts/ci/test_strix_quick_gate.sh
  • actionlint
  • python3 -m ruff check ...
  • bash -n ...
  • git diff --check

Summary by CodeRabbit

  • 새로운 기능

    • 풀 리퀘스트 리뷰 자동화가 보호된 기준 브랜치에서 안전하게 실행되도록 개선되었습니다.
    • 커버리지와 코드 분석 결과를 바탕으로 리뷰 의견과 승인 여부를 자동 게시합니다.
    • 오래되거나 대상이 변경된 요청에는 부작용이 발생하지 않도록 검증합니다.
  • 보안 및 안정성

    • 풀 리퀘스트 이벤트에서는 메타데이터만 처리하며, 코드 실행과 민감 정보 사용을 제한합니다.
    • 중복 실행을 방지하고, 격리된 환경에서 분석을 수행합니다.
  • 문서 및 테스트

    • 새로운 리뷰 처리 흐름과 보안 경계를 문서화하고 관련 검증을 강화했습니다.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 28 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6fd55a43-9a77-40d4-84e6-c60525737c5c

📥 Commits

Reviewing files that changed from the base of the PR and between f509b29 and 037162b.

📒 Files selected for processing (8)
  • .github/workflows/opencode-review-dispatch.yml
  • .github/workflows/opencode-review.yml
  • docs/org-required-workflow-rollout.md
  • scripts/ci/opencode_review_comment_helpers.sh
  • scripts/ci/strix_quick_gate.sh
  • scripts/ci/test_strix_quick_gate.sh
  • tests/test_opencode_agent_contract.py
  • tests/test_opencode_workflow_shell_syntax.py
📝 Walkthrough

Walkthrough

Changes

OpenCode 리뷰 디스패치 분리

Layer / File(s) Summary
Bootstrap 및 dispatch 메타데이터 검증
.github/workflows/opencode-review.yml, .github/workflows/opencode-review-dispatch.yml, scripts/ci/*, tests/test_required_workflow_queue_contract.py, PR_GOVERNANCE_AUDIT.md, docs/org-required-workflow-rollout.md
opencode-review.yml은 metadata-only pull_request_target bootstrap으로 제한되고, dispatch 워크플로우가 actor·sender·repository·PR base/head 메타데이터를 검증하도록 변경된다.
PR merge tree 및 커버리지 증거
.github/workflows/opencode-review-dispatch.yml, tests/test_opencode_agent_contract.py, tests/test_opencode_docker_evidence_contract.py, tests/test_opencode_workflow_shell_syntax.py
base/head merge tree를 생성하고, 안전한 아카이브 추출·replay guard·변경 파일 문법 게이트와 제한된 샌드박스에서 다중 언어 커버리지 및 문서 증거를 수집한다.
CodeGraph 증거 및 모델 풀 실행
.github/workflows/opencode-review-dispatch.yml, scripts/ci/test_strix_quick_gate.sh, tests/test_opencode_agent_contract.py
검증된 PR head worktree에서 CodeGraph와 bounded evidence를 생성하고, 격리된 작업 공간에서 OpenCode 모델 풀과 adversarial contract 검증을 수행한다.
승인 게이트와 결과 게시
.github/workflows/opencode-review-dispatch.yml, scripts/ci/test_strix_quick_gate.sh, tests/test_opencode_agent_contract.py
peer checks, code-scanning, 리뷰 스레드, coverage 및 stale head 상태에 따라 APPROVE, REQUEST_CHANGES, COMMENT 또는 미게시로 분기하고 status와 merge scheduler 후속을 처리한다.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PullRequest
  participant BootstrapWorkflow
  participant DispatchWorkflow
  participant CoverageEvidence
  participant OpenCodeModelPool
  participant GitHubReviewAPI
  PullRequest->>BootstrapWorkflow: pull_request_target metadata 전달
  BootstrapWorkflow->>DispatchWorkflow: 인증된 repository_dispatch 전송
  DispatchWorkflow->>CoverageEvidence: PR merge tree 및 coverage evidence 생성
  CoverageEvidence-->>DispatchWorkflow: coverage_summary 반환
  DispatchWorkflow->>OpenCodeModelPool: bounded review evidence 전달
  OpenCodeModelPool-->>DispatchWorkflow: structured control block 반환
  DispatchWorkflow->>GitHubReviewAPI: review outcome 및 status 게시
Loading

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 권한 있는 리뷰 디스패치를 분리해 bootstrap과 PR-head 실행을 나눈 변경을 잘 요약합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-opencode-untrusted-checkout

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae enabled auto-merge July 29, 2026 01:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
tests/test_opencode_workflow_shell_syntax.py (1)

42-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

대형 셸 블록인 "Publish bounded OpenCode review comment" 스텝이 bash -n 검사 대상에서 빠져 있습니다.

해당 스텝(dispatch 워크플로우 3687라인 이하)은 mermaid/충돌 안내 헬퍼를 포함한 200줄 이상의 인라인 셸이며, 이번 PR에서 새로 이동해 온 코드입니다. 목록에 추가하면 YAML은 유효하지만 bash 파싱이 깨지는 회귀를 즉시 잡을 수 있습니다.

♻️ 검사 대상 스텝 추가
     for step_name in (
         "Materialize pull request merge tree for coverage measurement",
         "Prepare bounded OpenCode review evidence",
         "Enforce changed-file syntax gate",
+        "Publish bounded OpenCode review comment",
         "Publish OpenCode review outcome",
         "Run merge scheduler after approval",
     ):
🤖 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/test_opencode_workflow_shell_syntax.py` around lines 42 - 48, Update
the step-name collection in the test to include “Publish bounded OpenCode review
comment” so its inline shell block is included in the existing bash -n syntax
validation; preserve all current step entries and validation behavior.
.github/workflows/opencode-review-dispatch.yml (2)

4595-4648: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

도달 불가능한 legacy 브리지이며, 호출 인자도 하나 부족합니다.

LEGACY_GITHUB_ACTIONS_REVIEW_TOKEN은 라인 4305에서 github.event_name == 'pull_request_target' && github.token || ''로 정의되는데, 이 워크플로우는 repository_dispatch 전용이라 값이 항상 빈 문자열입니다. 따라서 publish_legacy_github_actions_approval_bridge는 항상 조기 return하는 데드코드입니다. 게다가 라인 4642의 호출은 post_pull_review_with_retry가 요구하는 5번째 인자(response_file)를 넘기지 않아, 만약 도달한다면 set -u 하에서 $5: unbound variable로 죽습니다.

이 dispatch 경로에서는 브리지 전체(및 관련 env)를 제거하는 편이 안전합니다.

🤖 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-dispatch.yml around lines 4595 - 4648,
Remove the unreachable publish_legacy_github_actions_approval_bridge function
and its related LEGACY_GITHUB_ACTIONS_REVIEW_TOKEN environment/configuration and
invocation from the repository_dispatch workflow. Do not retain the dead legacy
bridge path or its post_pull_review_with_retry call, including the missing
response_file argument issue.

3746-3859: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Mermaid/충돌 안내 헬퍼 4종이 두 스텝에 그대로 복제되어 있고 들여쓰기도 어긋나 있습니다.

emit_change_flow_mermaid_graph, append_mermaid_review_graph, ensure_review_body_has_change_graph, append_merge_conflict_guidance가 "Publish bounded OpenCode review comment"와 "Publish OpenCode review outcome" 두 스텝에 동일 내용으로 중복 정의되어 있습니다. 한쪽만 수정되는 드리프트가 생기기 쉽습니다. 또한 복제된 블록의 들여쓰기(20칸)가 주변 코드와 달라 가독성을 해칩니다.

scripts/ci/에 공용 셸 라이브러리로 추출하고 두 스텝에서 source 하는 방식을 권장합니다.

Also applies to: 4650-4763

🤖 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-dispatch.yml around lines 3746 - 3859,
Extract the duplicated Mermaid and merge-conflict
helpers—emit_change_flow_mermaid_graph, append_mermaid_review_graph,
ensure_review_body_has_change_graph, and append_merge_conflict_guidance—into a
shared shell library under scripts/ci/. Source that library from both “Publish
bounded OpenCode review comment” and “Publish OpenCode review outcome” steps,
remove their inline duplicate definitions, and align the remaining workflow
indentation with surrounding code.
🤖 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-dispatch.yml:
- Around line 329-333: Update the trusted_ref fallback prefix in the shown
workflow-ref handling to match opencode-review-dispatch.yml rather than
opencode-review.yml, so valid workflow_ref values extract their ref instead of
defaulting to main. Apply the same correction to the duplicate logic around the
second referenced location.

---

Nitpick comments:
In @.github/workflows/opencode-review-dispatch.yml:
- Around line 4595-4648: Remove the unreachable
publish_legacy_github_actions_approval_bridge function and its related
LEGACY_GITHUB_ACTIONS_REVIEW_TOKEN environment/configuration and invocation from
the repository_dispatch workflow. Do not retain the dead legacy bridge path or
its post_pull_review_with_retry call, including the missing response_file
argument issue.
- Around line 3746-3859: Extract the duplicated Mermaid and merge-conflict
helpers—emit_change_flow_mermaid_graph, append_mermaid_review_graph,
ensure_review_body_has_change_graph, and append_merge_conflict_guidance—into a
shared shell library under scripts/ci/. Source that library from both “Publish
bounded OpenCode review comment” and “Publish OpenCode review outcome” steps,
remove their inline duplicate definitions, and align the remaining workflow
indentation with surrounding code.

In `@tests/test_opencode_workflow_shell_syntax.py`:
- Around line 42-48: Update the step-name collection in the test to include
“Publish bounded OpenCode review comment” so its inline shell block is included
in the existing bash -n syntax validation; preserve all current step entries and
validation behavior.
🪄 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 Plus

Run ID: 4214d38d-5833-4409-9a58-6ba25f2d992a

📥 Commits

Reviewing files that changed from the base of the PR and between 34d7487 and f509b29.

📒 Files selected for processing (11)
  • .github/workflows/opencode-review-dispatch.yml
  • .github/workflows/opencode-review.yml
  • PR_GOVERNANCE_AUDIT.md
  • docs/org-required-workflow-rollout.md
  • scripts/ci/strix_quick_gate.sh
  • scripts/ci/test_opencode_fact_gate_contract.sh
  • scripts/ci/test_strix_quick_gate.sh
  • tests/test_opencode_agent_contract.py
  • tests/test_opencode_docker_evidence_contract.py
  • tests/test_opencode_workflow_shell_syntax.py
  • tests/test_required_workflow_queue_contract.py

Comment thread .github/workflows/opencode-review-dispatch.yml
@opencode-agent
opencode-agent Bot disabled auto-merge July 29, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant