Challenge workflow file writes for OAuth scope - #3092
Open
SamMorrowDrums wants to merge 2 commits into
Open
Conversation
Add per-call OAuth scope resolution for workflow paths and reject unsafe repository-relative paths before file writes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds per-call OAuth scope challenges for workflow-file writes while preserving repo-only authorization for other repository writes.
Changes:
- Adds traversal-safe path validation and conditional
workflowscope resolution. - Extends scope middleware and inventory metadata for argument-dependent scopes.
- Projects top-level paths into MCP headers and adds regression tests.
Show a summary per file
| File | Description |
|---|---|
pkg/scopes/scopes.go |
Removes unused Codespace scope metadata. |
pkg/scopes/scopes_test.go |
Updates scope catalog expectations. |
pkg/scopes/map.go |
Resolves conditional scopes per invocation. |
pkg/scopes/map_test.go |
Tests conditional scope resolution. |
pkg/inventory/server_tool.go |
Adds scope resolvers and path header projection. |
pkg/inventory/server_tool_test.go |
Tests path header annotations. |
pkg/http/oauth/oauth_test.go |
Updates advertised scope expectations. |
pkg/http/middleware/scope_challenge.go |
Challenges only for missing resolved scopes. |
pkg/http/middleware/scope_challenge_test.go |
Tests body- and context-derived challenges. |
pkg/github/repository_path.go |
Adds safe path validation and workflow detection. |
pkg/github/repository_path_test.go |
Covers traversal and workflow scope behavior. |
pkg/github/repositories.go |
Integrates validation and resolvers into write tools. |
pkg/github/header_params_test.go |
Verifies top-level versus nested path projection. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 13/13 changed files
- Comments generated: 0
- Review effort level: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Summary
Conditionally require the
workflowOAuth scope when file-write tools target.github/workflows/**, while preserving normalrepo-only writes elsewhere.Why
GitHub requires the additional
workflowscope for workflow-file updates, but statically requiring it would over-scope every file write. The remote server needs a per-call 403 challenge before handlers execute.Fixes # N/A
What changed
create_or_update_file,delete_file, and everypush_filesentry.paththrough SEP-2243 headers while keeping paths nested in arrays body-parsed.codespaceOAuth scope metadata and added regression coverage for traversal, arrays, headers, and challenges.MCP impact
workflowscope; input schemas are unchanged.Prompts tested (tool changes only)
.github/workflows/ci.ymlin owner/repo" — exercises the conditional workflow-scope challenge..github/workflows/ci.ymlin one commit" — exercises workflow detection inside thefilesarray..github/workflows/ci.yml" — exercises conditional scope resolution for deletion.Security / limits
workflow; existing token scopes are retained in the challenge.Tool renaming
deprecated_tool_aliases.goNote: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.
Lint & tests
./script/lint./script/testDocs
script/generate-docsproduced no changes.