Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions deploy/organization-rulesets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<semver>`; 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 |
Expand Down Expand Up @@ -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.

Expand Down
1 change: 0 additions & 1 deletion deploy/organization-rulesets/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/organization-rulesets/protect-release-tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# - tagNamePattern: require `v<semver>` (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
Expand Down

This file was deleted.

12 changes: 7 additions & 5 deletions deploy/organization-rulesets/restrict-release-tag-creation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -56,7 +58,7 @@ spec:
exclude: []
repositoryName:
- include: ["~ALL"]
exclude: ["agent-plugins"]
exclude: []
rules:
- creation: true
providerConfigRef:
Expand Down
38 changes: 8 additions & 30 deletions tests/release-tag-creation-ruleset.sh
Original file line number Diff line number Diff line change
@@ -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)"
Expand All @@ -20,39 +20,25 @@ 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
}')"
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
and .[0].apiVersion == "enterprise.github.m.upbound.io/v1alpha1"
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)))))
Expand All @@ -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)"
Expand All @@ -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"
Expand Down
Loading