Repository navigation
ci: declare contents:read on jit-format workflow - #128205
Conversation
|
Gentle ping - has been open for a couple weeks. When you have a moment, would you mind giving it a quick look? Happy to address any feedback. |
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
Signed-off-by: Arpit Jain <[email protected]>
|
Workflow state for the Holistic Review Orchestrator. {
"version": 5,
"last_dispatched_commit": "67b4f421a5563e86236bc25e100766e7788153c1",
"last_dispatched_base_ref": "main",
"last_dispatched_base_sha": "2c21b93b70abc47370477712689190e993a3706f",
"last_reviewed_commit": "67b4f421a5563e86236bc25e100766e7788153c1",
"last_reviewed_base_ref": "main",
"last_reviewed_base_sha": "2c21b93b70abc47370477712689190e993a3706f",
"last_recorded_worker_run_id": "29690681185",
"review_attempt_commit": "",
"review_attempt_base_ref": "",
"review_attempt_count": 0,
"max_review_attempts": 5,
"review_history_format": "holistic-review-disclosure-v1",
"review_history": [
{
"commit": "67b4f421a5563e86236bc25e100766e7788153c1",
"review_id": 4730924704
}
]
} |
|
@JulieLeeMSFT This PR hasn't been merged (it got approved earlier, thanks to you). Can you please follow-up to see and get it merged please. |
There was a problem hiding this comment.
Holistic Review
Motivation: Harden the jit-format.yml GitHub Actions workflow by adding an explicit top-level permissions block. Without an explicit block, the workflow inherits the repository/organization default GITHUB_TOKEN scopes, which can be broader than necessary. Constraining the token to least privilege is a recognized supply-chain security best practice.
Approach: A single permissions: mapping with contents: read is added at the top level of the workflow, immediately after the on: trigger and before jobs:. This makes read-only contents the default for every job and step. The workflow's actual work — actions/checkout, setup-dotnet, setup-python, running jitformat.py, and upload-artifact on failure — only requires read access to repository contents, so no additional permissions are needed.
Summary: The change is minimal, correct, and low-risk. contents: read is the appropriate least-privilege scope for this format-checking workflow, and no step needs write access. YAML placement and indentation are valid. This is a clean security improvement with no functional downside. LGTM.
Detailed Findings
No actionable issues. The added permissions: contents: read block is well-placed and matches the workflow's actual token needs.
Note
This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.
Generated by Holistic Review · 42.6 AIC · ⌖ 10.2 AIC · ⊞ 10K
There was a problem hiding this comment.
Holistic Review
Motivation: Justified. Adding an explicit workflow-level permissions: contents: read to jit-format.yml is a real, well-understood defense-in-depth hardening. Without an explicit block, the GITHUB_TOKEN inherits the repository/org default (potentially write), so pinning it bounds the blast radius if any consumed action is compromised, and provides drift protection against future default changes.
Approach: Correct and minimal. I independently traced every step: actions/setup-dotnet, actions/checkout (into runtime/), actions/setup-python, running jitformat.py, and actions/upload-artifact on failure. None of these calls a GitHub API that requires write scope — artifact upload uses the runtime's own artifact backend, not the contents API. A single top-level contents: read therefore grants exactly what the run needs, and since there is only one job, a job-level block would be equivalent; the workflow-level placement is fine and slightly more future-proof. This matches the pattern used across other hardened workflows in the repo.
Summary: ✅ LGTM. A 3-line, low-risk security hardening that follows the least-privilege convention. No correctness, performance, or behavioral concerns; the workflow's functional steps are unchanged and all remaining operations are read-only.
Note
This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.
Generated by Holistic Review · 38 AIC · ⌖ 9.92 AIC · ⊞ 10K
Pins
.github/workflows/jit-format.ymltopermissions: contents: readat the workflow level. The job sets up .NET and Python, runs the JIT format scripts on the changed code, and then uploads aformat.patchartifact viaactions/upload-artifact. Artifact upload is part of the run's own scope; none of the steps call a GitHub API that requires write access.This is a defense-in-depth measure rooted in CVE-2025-30066 (the March 2025
tj-actions/changed-filessupply-chain attack), where a tampered third-party action exfiltratedGITHUB_TOKENvia the workflow logs. The leaked token retained whatever scope was issued, so capping each workflow to the minimum it needs is the most reliable way to bound that blast radius if any of the dozens ofactions/*andactions/setup-*consumers ever get compromised. Declaring this in-file also gives drift protection against future repo or org default changes and is what OpenSSF Scorecard's Token-Permissions check credits.YAML validated with
yaml.safe_load.