Skip to content

CI: require maintainer approval for Docker image pushes - #471

Merged
irvingpop merged 3 commits into
masterfrom
ci/maintainer-gated-push
Nov 23, 2026
Merged

irvingpop merged 3 commits into
masterfrom
ci/maintainer-gated-push

Conversation

@irvingpop

Copy link
Copy Markdown
Member

Why

Any same-repo PR can assume the shared AWS role GitHubActions-ECR-Push and push pybot:staging. The role also has push rights to the back-end ECR repo. Dependabot PRs fail the Docker job because they get no AWS secrets. This is the same fix as OperationCode/back-end#423.

What changes

PR (any author, incl. Dependabot) -> build image only, no AWS login, no push
push to master                    -> push job in environment "ecr-main" (master only)
manual run / re-run               -> push job in environment "ecr-approval" (maintainer approves)
AWS role                          -> new GitHubActions-ECR-Push-pybot, trusts only those 2 environments, pushes only to repository/pybot
  • .github/workflows/ci.yml: PRs build only, and the push job runs in a GitHub Environment.
  • .github/SETUP.md: the environments, the new role, the switch-over order, and how a maintainer pushes to staging.

Behavior change: branch and PR pushes no longer publish :staging automatically. A maintainer approves a manual run instead.

Before merge

The environments and the new role (managed in operationcode_infra Terraform) must exist, and AWS_ROLE_ARN must point to the new role. See .github/SETUP.md. The old shared role is deleted after both repos have moved.

Review

  • An adversarial security review, plus a scoped re-review against the shared-role plan. No Critical or Important issues are open.
  • actionlint is clean.

🤖 Generated with Claude Code

irvingpop and others added 2 commits November 23, 2026 10:08
PRs (same-repo, fork, Dependabot) now build the image only, with no
AWS credentials. The push job runs only on push to master (environment
ecr-main, master branch only) and on dispatch or re-run (environment
ecr-approval, maintainer reviewers). github.ref no longer goes straight
into shell code.

Branch and PR pushes no longer publish :staging automatically. A
maintainer dispatches and approves instead.

.github/SETUP.md gives the new role GitHubActions-ECR-Push-pybot, its
trust (two exact immutable environment subjects) and ECR policy, the
environment rules, and the safe switch-over order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pybot no longer changes the old shared role GitHubActions-ECR-Push: no
trust edit, no permission edit, no session revoke. The guide says the
old role is not gated and stays open to branch workflows of both repos
until it is deleted. Back-end SETUP.md owns that deletion and the
CloudTrail check of both ECR repos; this guide only points to it.

The move now ends with a check of one master push through the new role
(CloudTrail AssumeRoleWithWebIdentity or the run log). The new role
uses an inline policy and create commands, as in back-end.

ecr-approval reviewers are irvingpop and kylemh, the owner's choice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude of Duty review, run 45237481468: 1 inline finding(s). Model output from untrusted input. Check it before you act on it. The gate result is in the summary comment.

Comment thread .github/workflows/ci.yml
needs: [ci-success]
# First attempt of a push to master: reviewed by a code owner before merge, so no wait.
# Dispatch and re-runs (any ref, any writer): a maintainer must approve.
environment: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master' && github.run_attempt == '1') && 'ecr-main' || 'ecr-approval' }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium security, confidence medium, pass security

Approval-free ecr-main depends on external branch-policy config

The no-approval path depends on the ecr-main environment being restricted to the master branch and on the AWS trust policy. The workflow file cannot enforce this, because a writer can edit it on a branch. If the environment is missing or lacks the master-only branch rule, GitHub auto-creates it with no protection. A branch workflow could then claim ecr-main and obtain AWS credentials without approval. The SETUP.md documents the requirement, but the PR does not verify it.

Model output from untrusted input. Check it before you act on it.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🟡 Clear to proceed: Claude of Duty logged 1 item to consider

Mission: Review the code. Protect the branch. Deploy the future.

Note

1 finding to consider. It does not block this PR.
Next step for the author: read the finding and fix what you agree with.

Severity Effect Where Finding Found by
🟠 Medium Does not block .github/workflows/ci.yml:182 Environment expression compares run_attempt to string; may fall to ecr-approval See the inline comment. Review (medium), Security (medium)
File checks Review Security Supply chain Dependency review Coverage
✅ ok, 1 signal ✅ ran, 1 finding ✅ ran, 1 finding ✅ ran, 0 findings ✅ ok ✅ complete

Run 45238057754, attempt 1 for head becbb36 into master. The required workflow in the merge box is the result that counts.

Claude of Duty never approves a PR. A human reviewer gives the final approval.

📋 Full review record: reasons, checks, signals, finding details, model summaries, token usage

Reviewed snapshot

Head SHA Merge base SHA Base branch Run
becbb368ba7b33fc6cf6ac61380c7f7efd82041a 67ab1055666861e53753e679602ed0719986a1d5 master 45238057754, attempt 1

Reasons the gate failed

None. No reason applies.

Checks (code, no model)

Check Result Detail
Hard blocks ✅ none
Coverage ✅ complete files in comparison 2, files collected 2, trees complete
Model view full estimate 32,183 tokens, limit 200,000 tokens, multiplier 1x
Dependency changes ✅ none
Dependency review job ✅ success

Signals (context only, never block)

  • ⚠️ Sensitive path changed: change to workflow, in .github/workflows/ci.yml

Dependency changes

None.

Finding details

Model output from untrusted input. Check it before you act on it. Verified means only that the quoted text is at that place. It does not mean the claim is true.

Blocking is decided by code from category and severity, never by the model. A finding in a blocking category blocks only at high or critical severity.

Each row above merges findings of several passes at the same file, line and gate effect.

Pass Severity Category Confidence Citation Posted Model title
Review medium bug medium ✅ checked inline Environment expression compares run_attempt to string; may fall to ecr-approval
Security medium security medium ✅ checked inline ecr-main push path has no approval and depends on external settings

The Supply chain pass completed and reported no findings.

Model summaries

Model output from untrusted input. Check it before you act on it. Verified means only that the quoted text is at that place. It does not mean the claim is true.

Pass Status Model Summary
Review ✅ ok claude-sonnet-5-5 The PR splits CI into a build-only job for PRs and an environment-gated push job for master pushes and manual dispatch, and adds a setup guide. I found one workflow bug that would cause real misbehavior.
Security ✅ ok claude-sonnet-5-5 The PR removes AWS credentials from pull_request builds and gates pushes behind GitHub Environments (ecr-main for master pushes, ecr-approval for dispatch and re-runs). The design is sound, with one gap: the master-push path has no approval, and its protection depends on out-of-band environment settings and on the old shared role being deleted.
Supply chain ✅ ok claude-sonnet-5-5 This PR splits the Docker CI job. Pull requests (including forks and Dependabot) now run a build-only job with read-only contents permission and no AWS credentials or OIDC token. The push job now runs only on push or workflow_dispatch and uses a GitHub Environment: ecr-main for the first attempt of a push to master, and ecr-approval (reviewer approval) for dispatches and re-runs. A new SETUP.md documents the environments, a dedicated AWS role with a StringEquals trust on those two environment subjects, and a switch-over procedure. I found no obfuscation, encoded payloads, unexpected network hosts, secret exfiltration or reviewer-directed text in the title, body or files. The workflow change narrows credential access: the can-push step is removed, the build-only job has no id-token permission, and the new job adds no permissions beyond the existing ones. The new build-only job uses the same tag-pinned actions as the existing jobs but has no credentials. The documented residual risk, that the old shared role stays assumable from branch workflows until it is deleted, is described in the PR and is not a code defect here.

Token usage

Pass Input Output Cache write Cache read Attempts
Review 719 346 0 25254 1
Security 1045 433 0 25254 1
Supply chain 1237 1671 25254 0 1
Total 3001 2450 25254 50508 3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude of Duty review, run 45238057754: 2 inline finding(s). Model output from untrusted input. Check it before you act on it. The gate result is in the summary comment.

Comment thread .github/workflows/ci.yml
needs: [ci-success]
# First attempt of a push to master: reviewed by a code owner before merge, so no wait.
# Dispatch and re-runs (any ref, any writer): a maintainer must approve.
environment: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master' && github.run_attempt == '1') && 'ecr-main' || 'ecr-approval' }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium bug, confidence medium, pass review

Environment expression compares run_attempt to string; may fall to ecr-approval

github.run_attempt is a number in expression contexts. GitHub's loose equality coerces '1' to a number so it likely works. However, the `ecr-main` environment is restricted to the master branch, and this expression is the only selector. If the comparison ever fails, every master push would silently require approval and hang. This is a low-likelihood fragility.

Model output from untrusted input. Check it before you act on it.

Comment thread .github/workflows/ci.yml
needs: [ci-success]
# First attempt of a push to master: reviewed by a code owner before merge, so no wait.
# Dispatch and re-runs (any ref, any writer): a maintainer must approve.
environment: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master' && github.run_attempt == '1') && 'ecr-main' || 'ecr-approval' }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium security, confidence medium, pass security

ecr-main push path has no approval and depends on external settings

Any push to master gets AWS credentials with no reviewer wait. Safety rests on the branch-only rule for master in the ecr-main environment and on the org ruleset requiring code-owner review. None of this is verifiable in the PR. If the environment is misconfigured, or a writer or admin bypasses the ruleset, a push to master can push :prod. The old shared role also remains assumable from any branch workflow until it is deleted, which the docs acknowledge, so the gate is not effective until then.

Model output from untrusted input. Check it before you act on it.

@irvingpop
irvingpop merged commit cfc44a7 into master Nov 23, 2026
10 checks passed
@irvingpop
irvingpop deleted the ci/maintainer-gated-push branch November 23, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant