Repository navigation
Description
Problem
ADR 0041 (proposed in #7497) gates each apply of the GitHub settings with environment github-settings of dan-petty/infra, whose required reviewer is the owner. Agents use the gh login of the owner. CONST_GH_API_PROTECTED_ROUTES (src/devops_cli/config/constants.py) refuses the settings routes to an agent caller, but not POST repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments, the review of a pending deployment. So devops gh api lets an agent approve an apply in place of the owner.
Change
Add the review routes of a deployment to CONST_GH_API_PROTECTED_ROUTES: POST repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments and POST repos/{owner}/{repo}/actions/runs/{run_id}/deployment_protection_rule.
Existing tool considered
The existing guard require_gh_api_access of src/devops_cli/github/api_guard.py. This item adds two routes to its table.
Done when
- A test of
tests/github/test_gh_api_agent_guard.pyshows that an agent caller gets a refusal and sends no request for each route, and that a person caller passes.
Dependencies
- ADR 0041 and refactor(repos): replace the onboard settings rows with OpenTofu #7497. The first apply of feat(tf): add the root tf/github/dan-petty and its apply workflow infra#241 waits for this item.
Source
Source: #7497
Proposed design
Problem statement
ADR 0041 (proposed in #7497) has the owner review each apply of the GitHub settings through environment github-settings of dan-petty/infra. Agents use the gh login of the owner, so they could send the review of that deployment themselves. CONST_GH_API_PROTECTED_ROUTES refuses the settings routes to an agent caller, but it holds neither route that records a deployment review. This item adds the two review routes to the table under their own route class, names that class in the help text and the documentation, and tests the refusal and the pass of a person.
Acceptance criteria
Requirement: Pending deployment review refused to an agent
The guard SHALL refuse POST repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments to an agent caller.
Scenario: Agent reviews a pending deployment
- WHEN an agent caller calls
require_gh_api_accesswith the methodPOSTand the pathrepos/dan-petty/infra/actions/runs/241/pending_deployments - THEN the call raises
GitHubApiAccessRefusedError, itsroute_classisdeployment review, itsdetails["pattern"]isrepos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments, and no request is sent
Requirement: Custom protection rule review refused to an agent
The guard SHALL refuse POST repos/{owner}/{repo}/actions/runs/{run_id}/deployment_protection_rule to an agent caller.
Scenario: Agent reviews a custom deployment protection rule
- WHEN an agent caller calls
require_gh_api_accesswith the methodPOSTand the pathrepos/dan-petty/infra/actions/runs/241/deployment_protection_rule - THEN the call raises
GitHubApiAccessRefusedError, itsroute_classisdeployment review, itsdetails["pattern"]isrepos/{owner}/{repo}/actions/runs/{run_id}/deployment_protection_rule, and no request is sent
Requirement: The run id does not change the refusal
The guard SHALL match each review route by its path template for any run id.
Scenario: Another run id
- WHEN an agent caller calls
require_gh_api_accesswith the methodPOSTand the pathrepos/dan-petty/infra/actions/runs/999999/pending_deployments - THEN the call raises
GitHubApiAccessRefusedErrorwith the patternrepos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments
Requirement: Person caller passes both review routes
The guard SHALL let a person caller send either review route.
Scenario: Owner approves a pending deployment
- WHEN a person caller calls
require_gh_api_accesswith the methodPOSTand the path of either review route - THEN each call returns
Noneand raises no refusal
Requirement: The command sends no request for a review route
The devops gh api command SHALL send no request when an agent caller targets either review route.
Scenario: Agent command refuses before dispatch
- WHEN a test runs
devops gh api -X POST repos/dan-petty/infra/actions/runs/241/pending_deploymentsas an agent caller against the fakeghedge - THEN the command exits non-zero with the refusal naming
deployment review, and the fake edge records no call
Requirement: Documentation names the deployment review class
The help text, the generated docs/commands/gh.md and docs/CLI_REFERENCE.md, and SECURITY.md SHALL name the deployment review class and its two routes.
Scenario: Documentation names the class
- WHEN a documentation test reads
docs/commands/gh.md,docs/CLI_REFERENCE.mdandSECURITY.md - THEN each file names
deployment reviewand both thepending_deploymentsanddeployment_protection_ruleroutes
Existing Tool Considered
No alternatives check has run. No open tool covers this need: the route-level refusal of an agent's devops gh api call lives in the project's own guard require_gh_api_access (src/devops_cli/github/api_guard.py:84), which reads CONST_GH_API_PROTECTED_ROUTES (src/devops_cli/config/constants.py:3184). The change adds two entries to that table, the class name in the help text and the docs, and tests: about 10 lines of data and 6 test cases, an estimated 20k tokens and under one hour of elapsed time to build, with no upkeep beyond the table. A replacement guard would cost more tokens and time than two table entries.
Key questions
- Which GitHub REST routes record the review of a deployment of a workflow run?: The two POST routes that the Actions REST reference documents for a workflow run:
repos/{owner}/{repo}/actions/runs/{run_id}/pending_deploymentsreviews the pending deployments of a run, andrepos/{owner}/{repo}/actions/runs/{run_id}/deployment_protection_rulereviews its custom deployment protection rules. The guard protects exactly these two, with the classdeployment review. (best practice) [sources: src/devops_cli/config/constants.py:3180, src/devops_cli/github/api_guard.py:63]- Chosen: The two POST review routes. They are the endpoints that record a review of a pending deployment or a custom protection rule, and the table names the narrowest protected area (
src/devops_cli/config/constants.py:3182). - Rejected: Every POST under
repos/{owner}/{repo}/actions/runs/{run_id}/**. It would also refusererun,rerun-failed-jobs,cancelandapproverequests that an agent may legitimately send, and the table's rule is the narrowest protected area (src/devops_cli/config/constants.py:3180). - Rejected: No change; rely on the environment gate. Agents use the owner's gh login, so an agent could approve the very deployment that the gate holds for the owner; the guard is the code that refuses it (
src/devops_cli/github/api_guard.py:84).
- Chosen: The two POST review routes. They are the endpoints that record a review of a pending deployment or a custom protection rule, and the table names the narrowest protected area (
- Which code refuses a protected route to an agent caller, and where does the table of routes live?:
require_gh_api_accessinsrc/devops_cli/github/api_guard.py:84refuses a protected route to an agent caller, throughclassify_protected_routeatsrc/devops_cli/github/api_guard.py:63.CONST_GH_API_PROTECTED_ROUTESinsrc/devops_cli/config/constants.py:3184holds the routes.tests/github/test_gh_api_agent_guard.pytests the guard. [sources: src/devops_cli/github/api_guard.py:84, src/devops_cli/github/api_guard.py:63, src/devops_cli/config/constants.py:3184, tests/github/test_gh_api_agent_guard.py:47] - Which route class does the refusal name, and what else changes with it?: A new class
deployment review. The help text ofdevops gh api(src/devops_cli/lang/en/help.py:1473) andSECURITY.md:58list the protected classes, so the change names the new class there, regeneratesdocs/commands/gh.mdanddocs/CLI_REFERENCE.mdwithuv run devops docs generate, and keepstests/commands/test_gh_cmd.pyon the no-request guarantee. (best practice) [sources: src/devops_cli/config/constants.py:3182, src/devops_cli/lang/en/help.py:1473, SECURITY.md:58, docs/commands/gh.md:9]- Chosen: A new
deployment reviewclass, with the help and the documentation. The refusal names the narrowest protected area (src/devops_cli/config/constants.py:3182), and the help text, the generated docs andSECURITY.md:58enumerate the classes, so they would be stale otherwise. - Rejected: Reuse the
repository settingsclass. A deployment review is not a write of a repository setting, and the refusal would send the owner to the wrong route class. - Rejected: A new class with no documentation change. The help text,
docs/commands/gh.md,docs/CLI_REFERENCE.mdandSECURITY.md:58would omit the class that the refusal names.
- Chosen: A new
- Which callers do the two review routes refuse?: The two routes refuse an agent caller only. A person caller passes, because the owner must review the deployment. (best practice) [sources: src/devops_cli/github/api_guard.py:87, tests/github/test_gh_api_agent_guard.py:157]
- Chosen: An agent caller only. The guard returns for every caller that
is_agent_caller()does not report (src/devops_cli/github/api_guard.py:87), and the environment gate needs the review of the owner. - Rejected: Every caller. It stops the owner from approving the deployment, which the gate requires.
- Chosen: An agent caller only. The guard returns for every caller that
- Where do the tests of the two routes go?: The classification and refusal tests go in
tests/github/test_gh_api_agent_guard.py, beside the tests of the settings routes. The no-request test of the command goes intests/commands/test_gh_cmd.py, whichSECURITY.md:58names for that guarantee and which holds the fakeghedge. (best practice) [sources: tests/github/test_gh_api_agent_guard.py:16, tests/commands/test_gh_cmd.py, SECURITY.md:58]- Chosen: Extend both test modules. The guard module holds the route table cases and the caller fixtures, and the command module holds the fake
ghedge that shows no request is sent. - Rejected: A new test module. It copies the fake edge, the route table cases and the caller fixtures of the two existing modules.
- Chosen: Extend both test modules. The guard module holds the route table cases and the caller fixtures, and the command module holds the fake
- Does this change wait on ADR 0041 and refactor(repos): replace the onboard settings rows with OpenTofu #7497?: No. ADR 0041 is still proposed (
docs/adr/0041-opentofu-holds-the-repository-settings.md:2), and the change adds two entries to a table and a test that no file of refactor(repos): replace the onboard settings rows with OpenTofu #7497 touches (openspec/changes/7497-onboard-settings-opentofu/tasks.md). The body names ADR 0041 and refactor(repos): replace the onboard settings rows with OpenTofu #7497 as the reason of the gate, and the first apply ofdan-petty/infra#241waits on this item, not the reverse. (best practice) [sources: src/devops_cli/config/constants.py:3184, src/devops_cli/github/api_guard.py:84, docs/adr/0041-opentofu-holds-the-repository-settings.md:2, openspec/changes/7497-onboard-settings-opentofu/tasks.md]- Chosen: No dependency; either item lands first. The change adds two table entries and a test that no code of refactor(repos): replace the onboard settings rows with OpenTofu #7497 touches, and it hardens a route before the first apply.
- Rejected: Wait for refactor(repos): replace the onboard settings rows with OpenTofu #7497. It adds a gate with no code reason and holds a security guard back behind an unaccepted ADR.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-28: none.
Tool: none found.
Reason: Searches found no maintained tool that refuses specific GitHub REST routes to an agent caller; the route table is the project's own guard in devops-cli, so the change is two entries plus tests.
Lacks:
- No external tool holds a table of refused GitHub API routes
- No generic policy proxy knows the deployment review routes
- No tool distinguishes an agent caller from a person caller here
- No tool raises the refusal before the request is sent
Activity
dan-petty commentedon Nov 28, 2026
A live security gap lets an agent bypass the required owner reviewer on infrastructure applies.Both add routes to CONST_GH_API_PROTECTED_ROUTES for agent refusal, but #5316 covers settings and transfer routes while the candidate adds deployment review routes.devops-cli-service commentedon Nov 28, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 28, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (6)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 28, 2026
Released in v0.233.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.233.0
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 17:56 UTC
docs(spec): plan #7497 apply settings in CI after the owner approves (#…