microsoft / microsoft/python-environment-tools
Make quality snapshot comments safe for fork PRs
还没有人认领这个 Issue。
- 主要语言
- Rust
- 星标
- 207
- 派生
- 45
- PR 合并指标
- 30 天内没有已合并 PR
描述
Problem
Pull requests from forks receive a read-only GITHUB_TOKEN, even when a pull_request workflow declares pull-requests: write. The performance and coverage workflows currently invoke marocchino/sticky-pull-request-comment before running their substantive work.
PR #521 reproduced the failure across all performance and coverage jobs:
- the workflow token had
PullRequests: readandSecret source: None; - the initial sticky-comment step failed with
Resource not accessible by integration; - normal benchmark/coverage steps were then skipped because the preceding step failed;
always()upload/comparison steps ran withoutmetrics.jsonorlcov.info, producing cascading snapshot failures; and- the final sticky-comment step failed with the same permission error.
The regular build, test, lint, and environment jobs passed, confirming that this was a fork-permission failure rather than a problem with the action pins in PR #521.
Security constraint
Fork workflows must remain untrusted and read-only:
- do not grant fork pull requests write access or repository secrets;
- do not use
pull_request_targetto execute or otherwise consume untrusted pull-request code; and - do not weaken the fail-closed behavior of the actual performance and coverage gates.
Tasks
- Detect fork pull requests before invoking PR-comment-writing actions.
- Skip both in-progress and final sticky-comment steps when the token cannot write, while allowing the benchmark/coverage work and snapshot comparisons to continue.
- Ensure comment publishing itself is non-gating: a comment API failure must not suppress or replace the underlying quality-gate result.
- Preserve sticky performance and coverage comments for same-repository pull requests.
- Keep reports available to fork contributors through job summaries and uploaded artifacts.
- Audit other
pull_requestworkflows for write operations with the same fork-token assumption.
Acceptance criteria
- A fork PR runs the complete performance and coverage jobs using only a read-only token.
- Fork runs do not attempt to create or update PR comments and do not report
Resource not accessible by integration. - Performance or coverage regressions still fail their jobs for both fork and same-repository PRs.
- Missing or malformed benchmark/coverage output still fails closed.
- Same-repository PRs continue receiving sticky snapshot comments.
- Fork reports remain inspectable in the GitHub step summary and artifacts.
- The solution does not use
pull_request_target, expose secrets, or grant write permissions to untrusted fork code.
Reproduction
- PR: #521
- Performance run: https://github.com/microsoft/python-environment-tools/actions/runs/31991321814
- Coverage run: https://github.com/microsoft/python-environment-tools/actions/runs/31991321855
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 performance 和 coverage pull_request 工作流开始,尤其关注其中的 in-progress 和 final marocchino/sticky-pull-request-comment 步骤。使用 PR #521 以及链接的 performance 和 coverage 运行来复现 fork token 失败。完成标准是 fork 作业以只读访问权限完成,同时 gates 仍保持 fail-closed,同一存储库中的评论继续正常工作,并且报告仍可在摘要和 artifacts 中获取。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- github-actions
- 领域
- ci-cd, security
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 65/100