From 0c8ef538493688e1d10bd02f3c13913bbd6c0539 Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Sat, 14 Nov 2026 23:02:08 +0100 Subject: [PATCH] fix(rulesets): restrict release tag creation in agent-plugins too GitHub refuses the built-in GitHub Actions integration as a bypass actor in an organization ruleset (HTTP 422), so the agent-plugins-only creation ruleset from #930 was never created and agent-plugins stayed outside the creation restriction. agent-plugins now creates its release tag with botantler-1 (devantler-tech/agent-plugins#711), which the organization-wide ruleset already allows. Drop the exclusion and the unused ruleset, so one ruleset covers every repository. Co-Authored-By: Claude Opus 5.5 --- deploy/organization-rulesets/README.md | 27 ++++++------ .../organization-rulesets/kustomization.yaml | 1 - .../protect-release-tags.yaml | 2 +- ...ct-agent-plugins-release-tag-creation.yaml | 44 ------------------- .../restrict-release-tag-creation.yaml | 12 ++--- tests/release-tag-creation-ruleset.sh | 38 ++++------------ 6 files changed, 29 insertions(+), 95 deletions(-) delete mode 100644 deploy/organization-rulesets/restrict-agent-plugins-release-tag-creation.yaml diff --git a/deploy/organization-rulesets/README.md b/deploy/organization-rulesets/README.md index 248dd2bf..7de69c15 100644 --- a/deploy/organization-rulesets/README.md +++ b/deploy/organization-rulesets/README.md @@ -44,8 +44,7 @@ verb — e.g. `require-pull-request.yaml`). Repo-scoped rulesets live next door | 3 `require-workflows-*.yaml` imports | **DependencyReview**, **EnableAutoMerge** and **ScanGitHubActions** | Observe + Update — preserve the observed policy and maintained source; never create or delete | | `require-workflows-dotnet.yaml` | language-selected **.NET** (retired) | Observe + Update — disabled with one inert rule (no required workflow; the provider requires a rules block) after a complete effective-policy census found no consumers; retain identity and selectors, never create or delete | | `protect-release-tags.yaml` | **Protect release tags** (net-new) | Managed (Create) — block tag delete + force-move + require `v`; no bypass actors | -| `restrict-release-tag-creation.yaml` | **Restrict release tag creation** (net-new) | Managed (Create) — only the release Apps and organization admins create `v*` tags; every repository except agent-plugins | -| `restrict-agent-plugins-release-tag-creation.yaml` | **Restrict release tag creation - agent-plugins** (net-new) | Managed (Create) — only the GitHub Actions App and organization admins create `v*` tags in agent-plugins, until its release uses an App | +| `restrict-release-tag-creation.yaml` | **Restrict release tag creation** (net-new) | Managed (Create) — only the release Apps and organization admins create `v*` tags, in every repository | | `require-world-at-ruin-trusted-regressions.yaml` | **Require workflow - World at Ruin trusted regressions** (retired) | Managed (Create), non-deleting — disabled with one inert rule and no workflow association after native shared-admission proof | | `require-monorepo-ci-aggregate-contract.yaml` | **Require workflow - Monorepo CI aggregate contract** (retired) | Managed (Create), non-deleting — disabled with one inert rule and no workflow association after native shared-admission proof | | `require-repository-pr-admission.yaml` | **Require workflow - Repository PR admission** | Managed (Create) — target monorepo, this catalogue and World at Ruin; trusted shared source runs each product-owned base-revision action, with a repository-bound executed result required for each | @@ -295,18 +294,18 @@ gates; a team audit cannot clear the latter two. Under ADR 0017 a product signs its releases from a release tag, so who may create a `v*` tag is part of the trust boundary ([#924](https://github.com/devantler-tech/.github/issues/924)). -Two rulesets restrict creation of tags matching `refs/tags/v*` (and `refs/tags/v*/**/*`, -because `*` stops at `/`). A bypass actor bypasses every rule in its ruleset, so these are -separate from `protect-release-tags.yaml`, which keeps no bypass actors. - -| Repositories | Who may create a `v*` tag | How each one creates it today | -|---|---|---| -| All except agent-plugins | botantler-1 (App `1025824`) | `create-release.yaml` with the organization's `APP_CLIENT_ID` | -| | ksail-bot (App `2880167`) | `create-release.yaml` in ksail, whose `APP_CLIENT_ID` variable names ksail-bot | -| | botantler-marketplace-releases (App `5498800`) | `create-release.yaml` with `protected-release: true`, its key only in a main-only `release` environment | -| | Organization admins | A release cut by hand | -| agent-plugins | GitHub Actions (App `15368`) | "Publish marketplace release" creates the tag with `github.token` | -| | Organization admins | A release cut by hand | +One ruleset restricts creation of tags matching `refs/tags/v*` (and `refs/tags/v*/**/*`, +because `*` stops at `/`), in every repository. A bypass actor bypasses every rule in its +ruleset, so it is separate from `protect-release-tags.yaml`, which keeps no bypass actors. +No release may create its tag with the workflow token: GitHub refuses the built-in GitHub +Actions integration as a bypass actor in an organization ruleset. + +| Who may create a `v*` tag | How each one creates it today | +|---|---| +| botantler-1 (App `1025824`) | `create-release.yaml` with the organization's `APP_CLIENT_ID`, and agent-plugins' `release-please.yaml` | +| ksail-bot (App `2880167`) | `create-release.yaml` in ksail, whose `APP_CLIENT_ID` variable names ksail-bot | +| botantler-marketplace-releases (App `5498800`) | `create-release.yaml` with `protected-release: true`, its key only in a main-only `release` environment | +| Organization admins | A release cut by hand | Other tag names that existing workflows create are not release tags and are not restricted. diff --git a/deploy/organization-rulesets/kustomization.yaml b/deploy/organization-rulesets/kustomization.yaml index 0f6a0b6c..c5e507ec 100644 --- a/deploy/organization-rulesets/kustomization.yaml +++ b/deploy/organization-rulesets/kustomization.yaml @@ -26,7 +26,6 @@ resources: # Net-new, managed (Create). - protect-release-tags.yaml - restrict-release-tag-creation.yaml - - restrict-agent-plugins-release-tag-creation.yaml - require-world-at-ruin-trusted-regressions.yaml - require-monorepo-ci-aggregate-contract.yaml - require-dotgithub-deploy-guards.yaml diff --git a/deploy/organization-rulesets/protect-release-tags.yaml b/deploy/organization-rulesets/protect-release-tags.yaml index 2eb4ae85..65ff73f4 100644 --- a/deploy/organization-rulesets/protect-release-tags.yaml +++ b/deploy/organization-rulesets/protect-release-tags.yaml @@ -9,7 +9,7 @@ # - tagNamePattern: require `v` (e.g. v1.2.3, v1.2.3-rc.1) # This ruleset does not restrict creating a tag (deletion/nonFastForward only restrict # delete/move). Who may create a `v*` tag is restricted separately by -# restrict-release-tag-creation.yaml and restrict-agent-plugins-release-tag-creation.yaml. +# restrict-release-tag-creation.yaml. # # Unlike everything else in this directory this is NOT an import — it has no # external-name and is managed (Observe + Create + Update + LateInitialize, never diff --git a/deploy/organization-rulesets/restrict-agent-plugins-release-tag-creation.yaml b/deploy/organization-rulesets/restrict-agent-plugins-release-tag-creation.yaml deleted file mode 100644 index 133b2dd3..00000000 --- a/deploy/organization-rulesets/restrict-agent-plugins-release-tag-creation.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# Restrict release tag creation - agent-plugins (#924). -# -# The same creation restriction as restrict-release-tag-creation.yaml, for the one repository -# that ruleset excludes. agent-plugins' "Publish marketplace release" workflow creates its `v*` -# tag with the workflow token (`github.token`), so its release identity is the GitHub Actions -# App (15368). Bypassing that App in the organization-wide ruleset would let any workflow job -# with `contents: write` in any repository create a release tag; this ruleset confines that -# bypass to agent-plugins. Once agent-plugins creates its tag with a dedicated release App, add -# that App to restrict-release-tag-creation.yaml, drop the exclusion there and retire this rule. -# -# A rename of agent-plugins fails closed: the organization-wide exclusion stops matching too, -# so the stricter ruleset applies. -apiVersion: enterprise.github.m.upbound.io/v1alpha1 -kind: OrganizationRuleset -metadata: - name: restrict-agent-plugins-release-tag-creation -spec: - managementPolicies: - - Observe - - Create - - Update - - LateInitialize - forProvider: - name: Restrict release tag creation - agent-plugins - target: tag - enforcement: active - bypassActors: - - actorType: Integration - actorId: 15368 # GitHub Actions (the workflow token) - bypassMode: always - - actorType: OrganizationAdmin - bypassMode: always - conditions: - - refName: - - include: ["refs/tags/v*", "refs/tags/v*/**/*"] - exclude: [] - repositoryName: - - include: ["agent-plugins"] - exclude: [] - rules: - - creation: true - providerConfigRef: - kind: ProviderConfig - name: default diff --git a/deploy/organization-rulesets/restrict-release-tag-creation.yaml b/deploy/organization-rulesets/restrict-release-tag-creation.yaml index 274f4c5c..b583d7ab 100644 --- a/deploy/organization-rulesets/restrict-release-tag-creation.yaml +++ b/deploy/organization-rulesets/restrict-release-tag-creation.yaml @@ -11,12 +11,14 @@ # # Scope: every tag whose name starts with `v` (`*` stops at `/`, so the second pattern covers # names that contain one). Other tag names that existing workflows create are not release -# tags and stay unaffected. agent-plugins is excluded here and covered by -# restrict-agent-plugins-release-tag-creation.yaml, because its release still creates the tag -# with the workflow token; that bypass must not apply to every repository. +# tags and stay unaffected. Every repository is in scope: a release creates its tag with a +# release App, never with the workflow token, because GitHub refuses the built-in GitHub +# Actions integration as a bypass actor in an organization ruleset (HTTP 422). agent-plugins +# creates its tag with botantler-1 since devantler-tech/agent-plugins#711. # # Bypass actors are the identities that create release tags today (census on #924): -# - 1025824 botantler-1: the organization's release App, used by create-release.yaml. +# - 1025824 botantler-1: the organization's release App, used by create-release.yaml and by +# agent-plugins' release-please.yaml. # - 2880167 ksail-bot: ksail's own release App (its APP_CLIENT_ID repository variable). # - 5498800 botantler-marketplace-releases: the protected-release App whose key lives only in # the main-only `release` environment of the three skill action repositories. @@ -56,7 +58,7 @@ spec: exclude: [] repositoryName: - include: ["~ALL"] - exclude: ["agent-plugins"] + exclude: [] rules: - creation: true providerConfigRef: diff --git a/tests/release-tag-creation-ruleset.sh b/tests/release-tag-creation-ruleset.sh index 4a5bdcbf..0a013654 100644 --- a/tests/release-tag-creation-ruleset.sh +++ b/tests/release-tag-creation-ruleset.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# Pins who may create a release tag (#924): the two creation rulesets carry exactly the -# release identities from the census, and "Protect release tags" keeps no bypass actor, -# because a bypass there would also bypass its delete and force-move rules. +# Pins who may create a release tag (#924): the one creation ruleset covers every repository +# and carries exactly the release identities from the census, and "Protect release tags" keeps +# no bypass actor, because a bypass there would also bypass its delete and force-move rules. set -euo pipefail root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" work="$(mktemp -d)" @@ -20,20 +20,7 @@ organization="$(jq -cn --argjson lifecycle "$lifecycle" --argjson refs "$refs" - {actorType: "Integration", actorId: 5498800, bypassMode: "always"}, {actorType: "OrganizationAdmin", bypassMode: "always"} ], - conditions: [{refName: $refs, repositoryName: [{include: ["~ALL"], exclude: ["agent-plugins"]}]}], - rules: [{creation: true}] - }, - providerConfigRef: $provider -}')" -agent_plugins="$(jq -cn --argjson lifecycle "$lifecycle" --argjson refs "$refs" --argjson provider "$provider" '{ - managementPolicies: $lifecycle, - forProvider: { - name: "Restrict release tag creation - agent-plugins", target: "tag", enforcement: "active", - bypassActors: [ - {actorType: "Integration", actorId: 15368, bypassMode: "always"}, - {actorType: "OrganizationAdmin", bypassMode: "always"} - ], - conditions: [{refName: $refs, repositoryName: [{include: ["agent-plugins"], exclude: []}]}], + conditions: [{refName: $refs, repositoryName: [{include: ["~ALL"], exclude: []}]}], rules: [{creation: true}] }, providerConfigRef: $provider @@ -41,7 +28,7 @@ agent_plugins="$(jq -cn --argjson lifecycle "$lifecycle" --argjson refs "$refs" check_rules() { local observed observed="$(yq -o=json -I=0 '.' "$1" | jq -s '[.[] | select(.kind == "OrganizationRuleset")]')" || { fail 'unreadable render'; return 1; } - jq -e --argjson organization "$organization" --argjson agent_plugins "$agent_plugins" ' + jq -e --argjson organization "$organization" ' def one($name): [.[] | select(.metadata.name == $name)]; def created($name; $spec): one($name) | length == 1 @@ -49,10 +36,9 @@ check_rules() { and .[0].spec == $spec and ((.[0].metadata.annotations // {}) | has("crossplane.io/external-name") | not); created("restrict-release-tag-creation"; $organization) - and created("restrict-agent-plugins-release-tag-creation"; $agent_plugins) - # Only these two rulesets may restrict tag creation, so no other bypass list applies to it. + # Only this ruleset may restrict tag creation, so no other bypass list applies to it. and ([.[] | select(.spec.forProvider.target == "tag" and any(.spec.forProvider.rules[]?; .creation == true)) - | .metadata.name] | sort == ["restrict-agent-plugins-release-tag-creation", "restrict-release-tag-creation"]) + | .metadata.name] == ["restrict-release-tag-creation"]) and (one("protect-release-tags") | length == 1 and (.[0].spec.forProvider | (.bypassActors // []) == [] and .target == "tag" and (.rules | length == 1 and (.[0] | .deletion == true and .nonFastForward == true and (has("creation") | not))))) @@ -70,7 +56,6 @@ check_rules "$work/render.yaml" check_ci "$root/.github/workflows/ci.yaml" # Exercise the rendered policies, not second synthetic resources. organization_selector='select(.kind == "OrganizationRuleset" and .metadata.name == "restrict-release-tag-creation")' -agent_plugins_selector='select(.kind == "OrganizationRuleset" and .metadata.name == "restrict-agent-plugins-release-tag-creation")' protect_selector='select(.kind == "OrganizationRuleset" and .metadata.name == "protect-release-tags")' mutations=( "${organization_selector}|del(.spec.managementPolicies)" @@ -92,18 +77,11 @@ mutations=( "${organization_selector}|.spec.forProvider.conditions[0].refName[0].include = [\"refs/tags/v1*\",\"refs/tags/v*/**/*\"]" "${organization_selector}|.spec.forProvider.conditions[0].refName[0].exclude = [\"refs/tags/v0*\"]" "${organization_selector}|.spec.forProvider.conditions[0].repositoryName[0].exclude += [\"platform\"]" - "${organization_selector}|.spec.forProvider.conditions[0].repositoryName[0].exclude = []" + "${organization_selector}|.spec.forProvider.conditions[0].repositoryName[0].exclude = [\"agent-plugins\"]" "${organization_selector}|.spec.forProvider.conditions[0].repositoryName[0].include = [\"ksail\"]" "${organization_selector}|.metadata.annotations.\"crossplane.io/external-name\" = \"18136026\"" "${organization_selector}|.apiVersion = \"repo.github.m.upbound.io/v1alpha1\"" "${organization_selector}|.spec.providerConfigRef.name = \"another-provider\"" - "${agent_plugins_selector}|.spec.managementPolicies += [\"Delete\"]" - "${agent_plugins_selector}|.spec.forProvider.enforcement = \"disabled\"" - "${agent_plugins_selector}|.spec.forProvider.rules[0].creation = false" - "${agent_plugins_selector}|.spec.forProvider.bypassActors += [{\"actorType\":\"Integration\",\"actorId\":1025824,\"bypassMode\":\"always\"}]" - "${agent_plugins_selector}|.spec.forProvider.conditions[0].repositoryName[0].include = [\"~ALL\"]" - "${agent_plugins_selector}|.spec.forProvider.conditions[0].repositoryName[0].include += [\"ksail\"]" - "${agent_plugins_selector}|.spec.forProvider.conditions[0].refName[0].include = [\"refs/tags/v*\"]" "${protect_selector}|.spec.forProvider.bypassActors = [{\"actorType\":\"Integration\",\"actorId\":1025824,\"bypassMode\":\"always\"}]" "${protect_selector}|.spec.forProvider.bypassActors = [{\"actorType\":\"OrganizationAdmin\",\"bypassMode\":\"always\"}]" "${protect_selector}|.spec.forProvider.rules[0].creation = true"