Skip to content

ci: restrict privileged workflow triggers - #24677

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
lilin90:codex/harden-privileged-workflow-auth
Nov 11, 2026
Merged

ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
lilin90:codex/harden-privileged-workflow-auth

Conversation

@lilin90

@lilin90 lilin90 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

What is changed, added, or deleted? (Required)

  • require an explicit three-maintainer allowlist for manually dispatched AI review, translation, and TOC synchronization jobs
  • validate both the original actor and the rerun initiator for manual workflow runs
  • allow scheduled translations without an actor check only on their first attempt; require an allowlisted initiator for reruns
  • remove inactive accounts from the existing ZH-to-EN synchronization allowlist
  • retain the repository guard for privileged jobs
  • pass the workflow token to GitHub CLI through GH_TOKEN instead of placing it in a curl authorization argument

This prevents repository writers outside the current maintainer set from manually running or rerunning jobs that use provider secrets or write repository content, and keeps the workflow token out of process arguments.

Validation:

  • parsed all five modified workflow files as YAML
  • ran git diff --check
  • verified the manual-dispatch, scheduled-event, rerun, and token-handling paths

Which TiDB version(s) do your changes apply to? (Required)

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

  • Related code change PR links (if applicable): N/A
  • This PR is translated from: N/A
  • Other reference link(s): N/A

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@ti-chi-bot ti-chi-bot Bot added missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 11, 2026
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: pingcap/docs
  • Branch: master
  • File: .coderabbit.yaml
  • Commit: 16b9550
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: b1009de2-ab35-4e23-a723-151f053f5990
Commits

Reviewing files that changed from the base of the PR and between 2af75a9 and 416fbf8.

Files selected for processing: 5

  • .github/workflows/doc_review.yml
  • .github/workflows/sync-cloud-zh-toc.yml
  • .github/workflows/sync-doc-pr-zh-to-en.yml
  • .github/workflows/translation-cron.yml
  • .github/workflows/translation-zh.yaml

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Five GitHub Actions jobs now use updated repository, event, or actor conditions. The changes restrict job execution based on configured actors and, for translation jobs, distinguish scheduled runs from manual dispatches.

Changes: Workflow execution conditions

Layer / File(s) Summary
Job trigger and actor conditions
.github/workflows/doc_review.yml, .github/workflows/sync-cloud-zh-toc.yml, .github/workflows/translation-cron.yml, .github/workflows/translation-zh.yaml, .github/workflows/sync-doc-pr-zh-to-en.yml
The review job checks the repository and restricts dispatch and matching comment events to listed actors. The TOC sync job adds actor checks. Translation jobs distinguish scheduled runs from manual dispatches and apply actor checks. The document sync job updates its actor allowlist and checks both the actor and triggering actor.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: qiancai, alastori

Merge Risk: Low · previous review 2af75

This change restricts manual dispatch and rerun of the privileged documentation workflows to three maintainers, and it closes the rerun bypass. A remaining limit is that a writer could still dispatch an older or custom branch version of a workflow that lacks these checks. Closing that needs repository settings such as protected environments, so it is a bounded follow-up rather than a reason to hold this PR.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: restricting privileged workflow triggers.
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.
Description check Passed The pull request description is complete. It explains the changes, affected TiDB version, validation performed, AI agent involvement, and applicable change categories. Optional reference links and fir…
Full details: Description check

Explanation

The pull request description is complete. It explains the changes, affected TiDB version, validation performed, AI agent involvement, and applicable change categories. Optional reference links and first-time contributor details are addressed or not applicable.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: pingcap/docs
  • Branch: master
  • File: .coderabbit.yaml
  • Commit: 16b9550
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9da334fe-334c-4f78-92d9-48d8c7f6b433
Commits

Reviewing files that changed from the base of the PR and between f13a0e6 and 2af75a9.

Files selected for processing: 5

  • .github/workflows/doc_review.yml
  • .github/workflows/sync-cloud-zh-toc.yml
  • .github/workflows/sync-doc-pr-zh-to-en.yml
  • .github/workflows/translation-cron.yml
  • .github/workflows/translation-zh.yaml

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@lilin90 lilin90 self-assigned this Nov 11, 2026
@lilin90 lilin90 added the translation/no-need No need to translate this PR. label Nov 11, 2026
@ti-chi-bot ti-chi-bot Bot removed the missing-translation-status This PR does not have translation status info. label Nov 11, 2026
@lilin90 lilin90 added the ONCALL Relates to documentation oncall. label Nov 11, 2026

@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: 3

Review info

Run configuration

  • Source mode: Auto
  • Repository: pingcap/docs
  • Branch: master
  • File: .coderabbit.yaml
  • Commit: 16b9550
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ccf4cefc-258a-4212-8c1e-90659bcc625f
Commits

Reviewing files that changed from the base of the PR and between 16b9550 and f3b82c6.

Files selected for processing: 4

  • .github/workflows/doc_review.yml
  • .github/workflows/sync-cloud-zh-toc.yml
  • .github/workflows/translation-cron.yml
  • .github/workflows/translation-zh.yaml

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread .github/workflows/doc_review.yml Resolved
Comment thread .github/workflows/sync-cloud-zh-toc.yml Outdated
if: github.repository == 'pingcap/docs'
if: >
github.repository == 'pingcap/docs' &&
contains(fromJson('["hfxsd","likidu","lilin90","Oreoxmt","qiancai"]'), github.actor)

@coderabbitai coderabbitai Bot Nov 11, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Major · Security & Privacy · Heavy lift

Supported by static analysis

Script executed:

git diff 16b9550da30e6feba95243d0e6b5ddbd859ab3c4 f3b82c62a6510ed6eb30f0f00ba0bf275332c11a -- .github/workflows
printf '\n--- target workflow ---\n'
cat -n .github/workflows/sync-cloud-zh-toc.yml
printf '\n--- relevant workflow names ---\n'
rg -n -F -e 'workflow_dispatch:' -e 'github.actor' -e 'secrets.' -- .github/workflows/sync-cloud-zh-toc.yml .github/workflows/*translat* || test "$?" -eq 1
printf '\n--- repository rules or environment declarations ---\n'
rg -n -F -e 'environment:' -e 'ruleset' -- .github/workflows/sync-cloud-zh-toc.yml .github/workflows/*translat* .github || test "$?" -eq 1

Repository: pingcap/docs

Length of output: 9125


Web query:

GitHub Actions workflow_dispatch select branch workflow version run branch ref write access workflow_dispatch secrets default branch workflow exists

Result:

Sources consulted:
- Manually running a workflow — https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow
- Triggering a workflow — https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow
- Events that trigger workflows — https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows
- Workflow syntax for GitHub Actions — https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
- GitHub workflow | Port — https://docs.port.io/workflows/actions-and-automations/setup-backend/github-workflow/

Script executed:

printf '%s\n' '--- available refs containing old workflow ---'
git for-each-ref --format='%(refname)' refs/heads refs/remotes refs/tags | while IFS= read -r ref; do
  oid=$(git rev-parse "$ref:.github/workflows/sync-cloud-zh-toc.yml" 2>/dev/null) || continue
  old=$(git rev-parse '16b9550da30e6feba95243d0e6b5ddbd859ab3c4:.github/workflows/sync-cloud-zh-toc.yml') || exit 1
  if [ "$oid" = "$old" ]; then printf '%s\n' "$ref"; fi
done
printf '%s\n' '--- base workflow ---'
git show 16b9550da30e6feba95243d0e6b5ddbd859ab3c4:.github/workflows/sync-cloud-zh-toc.yml | cat -n | sed -n '1,60p'
printf '%s\n' '--- current translation entrypoints ---'
cat -n .github/workflows/translation-cron.yml | sed -n '1,85p'
cat -n .github/workflows/translation-zh.yaml | sed -n '1,75p'

Repository: pingcap/docs

Length of output: 10147


Web query:

GitHub Actions workflow_dispatch uses workflow file version branch ref workflow file selected branch version documentation

Result:

Sources consulted:
- Events that trigger workflows — https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows
- Workflow syntax for GitHub Actions — https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
- Manually running a workflow — https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow
- Triggering a workflow — https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow
- Workflows — https://docs.github.com/en/actions/concepts/workflows-and-actions/workflows

Script executed:

printf '%s\n' '--- repository and ref metadata ---'
git status --short --branch
git remote -v
printf '%s\n' '--- public branch and ruleset metadata ---'
if command -v gh >/dev/null 2>&1; then
  gh api 'repos/pingcap/docs/branches?per_page=100' --jq '.[] | [.name, .protected, .commit.sha] | @tsv'
  gh api 'repos/pingcap/docs/rulesets?includes_parents=true&per_page=100' --jq '.[] | [.name, .target, .enforcement] | @tsv'
else
  printf '%s\n' 'gh unavailable'
fi

Repository: pingcap/docs

Length of output: 7882


Script executed:

for ref in cloud-webhook-payload-reference docs/clarify-backup-delay-scaling Benjamin2037-patch-1; do
  printf '\n--- %s ---\n' "$ref"
  gh api -X GET 'repos/pingcap/docs/contents/.github/workflows/sync-cloud-zh-toc.yml' -f "ref=$ref" --jq '.content | @base64d' | cat -n | sed -n '1,60p'
done

Repository: pingcap/docs

Length of output: 741


Script executed:

for ref in agent-memory-guide-2026-10 cloud/add-release-note-20261027 fix-filesystem-quick-start automation/keyword-sync-docs-master-b254c43931d9; do
  printf '\n--- %s ---\n' "$ref"
  gh api -X GET 'repos/pingcap/docs/contents/.github/workflows/sync-cloud-zh-toc.yml' -f "ref=$ref" --jq '.content | @base64d' | cat -n | sed -n '1,20p'
done

Repository: pingcap/docs

Length of output: 1249


Script executed:

gh api -X GET 'repos/pingcap/docs/contents/.github/workflows/sync-cloud-zh-toc.yml' -f 'ref=automation/keyword-sync-docs-master-b254c43931d9' --jq '.content | @base64d' | cat -n | sed -n '1,90p'

Repository: pingcap/docs

Length of output: 3463


Script executed:

for file in translation-cron.yml translation-zh.yaml; do
  printf '\n--- %s ---\n' "$file"
  gh api -X GET "repos/pingcap/docs/contents/.github/workflows/$file" -f 'ref=automation/keyword-sync-docs-master-b254c43931d9' --jq '.content | @base64d' | cat -n | sed -n '1,75p'
done

Repository: pingcap/docs

Length of output: 5782


Enforce the allowlist outside dispatchable workflow versions.

A writer outside the allowlist can dispatch the existing automation/keyword-sync-docs-master-b254c43931d9 branch. Its TOC workflow lacks the check and requests write permissions and GEMINI_API_TOKEN. The same branch also has translation workflows without the actor checks.

Enforce the privileged boundary outside the selectable workflow version.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Valid architectural limitation. A condition inside a workflow cannot protect against a writer selecting or creating another branch whose workflow omits that condition. Closing that boundary requires a repository-admin control outside the selectable workflow version, such as moving provider secrets to a protected GitHub Environment with deployment-branch restrictions and required reviewers, together with tighter write access. Adding environment: in this PR without configuring and migrating the repository secrets would not enforce the boundary, so this PR keeps the scoped default-branch authorization fix and does not claim to solve hostile workflow versions.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@lilin90 Understood. This PR limits dispatches of the updated workflow, but it does not protect secrets or write access from other selectable workflow versions.

Would you like me to open a follow-up issue for the repository-admin controls?


Learnings added

Learnt from: lilin90
Repo: pingcap/docs PR: 24677
File: .github/workflows/sync-cloud-zh-toc.yml:0-0
Timestamp: 2026-11-11T08:50:08.529Z
Learning: Within repository "pingcap/docs", only for files matching one of [".github/workflows/sync-cloud-zh-toc.yml"]: When a change to `.github/workflows/sync-cloud-zh-toc.yml` claims to restrict privileged manual dispatch, check whether other selectable workflow versions can access the same secrets or write permissions without the actor check. Verify controls outside those workflow versions rather than treating a job condition or an `environment:` declaration alone as a complete boundary.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

Comment thread .github/workflows/translation-cron.yml Resolved
@lilin90
lilin90 force-pushed the codex/harden-privileged-workflow-auth branch from f3b82c6 to f13a0e6 Compare November 11, 2026 08:28
@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 11, 2026
@lilin90

lilin90 commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

/bot-review

@github-actions

Copy link
Copy Markdown
Contributor

✅ AI review completed, no issues found.

@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

Review info

Run configuration

  • Source mode: Auto
  • Repository: pingcap/docs
  • Branch: master
  • File: .coderabbit.yaml
  • Commit: 16b9550
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 149304bf-2523-4e32-8f6c-04cb0a75cafa
Commits

Reviewing files that changed from the base of the PR and between f3b82c6 and f13a0e6.

Files selected for processing: 4

  • .github/workflows/sync-cloud-zh-toc.yml
  • .github/workflows/sync-doc-pr-zh-to-en.yml
  • .github/workflows/translation-cron.yml
  • .github/workflows/translation-zh.yaml

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Comment thread .github/workflows/sync-cloud-zh-toc.yml Resolved
@lilin90
lilin90 force-pushed the codex/harden-privileged-workflow-auth branch from f13a0e6 to 2af75a9 Compare November 11, 2026 08:45
@lilin90
lilin90 requested a lite review from Copilot November 11, 2026 08:55

Copilot AI 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.

🟡 Changes recommended

The privileged workflow lacks the required canonical-repository guard, allowing an allowlisted fork execution to access write tokens or secrets.

1 open issue
What changed in this PR

This pull request hardens privileged documentation workflows by restricting manual runs and reruns to an explicit three-maintainer allowlist while preserving first-attempt scheduled translation runs.

Changes:

  • Adds actor and rerun-initiator authorization checks to translation, AI review, and TOC synchronization workflows.
  • Removes inactive accounts from the ZH-to-EN synchronization allowlist.
  • The ZH-to-EN synchronization workflow still lacks the canonical repository guard.
File Description
.github/​workflows/​translation-zh.yaml Restricts scheduled and manually dispatched Chinese translation jobs using maintainer and rerun authorization checks.
.github/​workflows/​translation-cron.yml Restricts scheduled and manually dispatched Japanese translation jobs using maintainer and rerun authorization checks.
.github/​workflows/​sync-doc-pr-zh-to-en.yml Updates the ZH-to-EN synchronization allowlist and rerun authorization checks.
.github/​workflows/​sync-cloud-zh-toc.yml Restricts Cloud TOC synchronization to the canonical repository and approved maintainers.
.github/​workflows/​doc_review.yml Restricts manual and comment-triggered AI documentation reviews to approved maintainers.

Review effort: Lite

@lilin90
lilin90 force-pushed the codex/harden-privileged-workflow-auth branch from 2af75a9 to 6478b00 Compare November 11, 2026 09:02
@lilin90

lilin90 commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI 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.

🔵 Needs a closer look

Static review found no actionable defect, but approval should wait for GitHub-side validation of actor, triggering_actor, and run_attempt behavior across privileged workflow dispatches and reruns.

No open issues 🎉

1 resolved since last review

Review effort: Lite

@lilin90
lilin90 requested a review from shhdgit November 11, 2026 09:20
@ti-chi-bot

ti-chi-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

@shhdgit: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@lilin90 lilin90 added the lgtm label Nov 11, 2026

@lilin90 lilin90 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

/approve

@ti-chi-bot

ti-chi-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lilin90

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the approved label Nov 11, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit 557f0c9 into pingcap:master Nov 11, 2026
12 checks passed
@lilin90
lilin90 deleted the codex/harden-privileged-workflow-auth branch November 11, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm ONCALL Relates to documentation oncall. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. translation/no-need No need to translate this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants