ci: isolate and harden organization label credentials#3
Merged
Conversation
Member
Author
验证结果更新最新提交
Preview Job 的运行时权限仅为 合并前仍需在仓库 Settings 中完成 |
lzm0x219
marked this pull request as ready for review
July 11, 2026 00:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更摘要
将组织标签的只读预览与真实写入拆分为两个独立权限边界,避免自动 Push 和定时任务读取跨仓库写令牌,并固定所有第三方 GitHub Actions 到完整 Commit SHA。
主要修改
preview-labels.yml:github.token;sync-labels.yml:workflow_dispatch;main执行;confirm_apply;label-governance-productionEnvironment;LABEL_SYNC_WRITE_TOKEN;actions/checkout、markdownlint-cli2-action和lychee-action固定到最近成功工作流实际解析的完整 SHA。根因
此前虽然自动事件强制使用 Dry Run,但 Push、Schedule 和手动执行都会读取同一个具有跨仓库写权限的
LABEL_SYNC_TOKEN。Dry Run 只是程序内部逻辑,无法构成凭证权限隔离;进入默认分支的错误或恶意代码仍可能直接使用该令牌写入组织仓库。安全影响
合并后,自动运行不再接触写令牌。真实标签修改只能经过以下门槛:
main运行;confirm_apply;label-governance-productionEnvironment 保护规则;LABEL_SYNC_WRITE_TOKEN。合并前必须完成的仓库设置
本 PR 无法通过仓库文件自动配置 Environment 保护规则。合并前应在 GitHub Settings 中:
label-governance-productionEnvironment;LABEL_SYNC_WRITE_TOKEN;LABEL_SYNC_TOKEN。在上述配置完成前,不应运行 Apply 工作流。
验证
main无冲突,仅涉及工作流、Dependabot 配置和对应说明文档。审查重点
github.token是否满足当前公开仓库的只读预览范围;