-
Notifications
You must be signed in to change notification settings - Fork 0
fix(rulesets): retire the ineffective signing rule #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,34 @@ | ||
| # Existing org ruleset, adopted Observe-first (read-only). Identity-only | ||
| # forProvider — don't promote past Observe without backfilling from | ||
| # status.atProvider (lossy round-trip). See ./README.md for the convention. | ||
| # Retained disabled record: this rule's empty ref selector protects no branches. | ||
| # Backfilled from the observed ruleset before allowing Update; keep all fields | ||
| # and the existing identity. Never create or delete it. See ./README.md and #132. | ||
| apiVersion: enterprise.github.m.upbound.io/v1alpha1 | ||
| kind: OrganizationRuleset | ||
| metadata: | ||
| name: require-signed-commits | ||
| annotations: | ||
| crossplane.io/external-name: "5397812" # numeric ruleset id | ||
| spec: | ||
| managementPolicies: ["Observe"] | ||
| managementPolicies: ["Observe", "Update"] | ||
| forProvider: | ||
| name: Require signed commits | ||
| target: branch | ||
| enforcement: active | ||
| enforcement: disabled | ||
| bypassActors: [] | ||
| conditions: | ||
| - refName: | ||
| - include: [] | ||
| exclude: [] | ||
| repositoryName: | ||
| - include: ["~ALL"] | ||
| exclude: [] | ||
| protected: false | ||
| rules: | ||
| - creation: false | ||
| deletion: false | ||
| nonFastForward: false | ||
| requiredLinearHistory: false | ||
| requiredSignatures: true | ||
| update: false | ||
| providerConfigRef: | ||
| kind: ProviderConfig | ||
| name: default |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/usr/bin/env bash | ||
| # Retain the approved disabled record without broadening its scope or lifecycle. | ||
| set -euo pipefail | ||
|
|
||
| root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| render="$(mktemp)" | ||
| trap 'rm -f "$render"' EXIT | ||
| fail() { echo "signing-rule-retirement test: $*" >&2; exit 1; } | ||
|
|
||
| kubectl kustomize "$root/deploy" >"$render" | ||
| selector='select(.apiVersion == "enterprise.github.m.upbound.io/v1alpha1" and .kind == "OrganizationRuleset" and .metadata.name == "require-signed-commits")' | ||
| count="$(yq -N "$selector | .metadata.name" "$render" | grep -c . || true)" | ||
| [[ "$count" == 1 ]] || fail "the existing signing ruleset must remain in the render" | ||
|
|
||
| assert_json() { | ||
| local expected="$1" expression="$2" actual | ||
| actual="$(yq -o=json -I=0 "$selector | $expression" "$render")" | ||
| [[ "$actual" == "$expected" ]] || fail "$expression: expected $expected, got $actual" | ||
| } | ||
|
|
||
| # Only this existing object may be updated. Prune or external disappearance must | ||
| # never authorize deletion or recreation, and late initialization stays disabled. | ||
| assert_json '"5397812"' '.metadata.annotations."crossplane.io/external-name"' | ||
| assert_json '["Observe","Update"]' '.spec.managementPolicies' | ||
| assert_json '{"kind":"ProviderConfig","name":"default"}' '.spec.providerConfigRef' | ||
| assert_json '{}' '(.spec.initProvider // {})' | ||
| assert_json '"disabled"' '.spec.forProvider.enforcement' | ||
| assert_json '"Require signed commits"' '.spec.forProvider.name' | ||
| assert_json '"branch"' '.spec.forProvider.target' | ||
|
|
||
| # Update sends the full ruleset: preserve the observed selectors, empty bypass | ||
| # list and all rule booleans explicitly. Empty ref coverage must stay empty. | ||
| assert_json '[]' '.spec.forProvider.bypassActors' | ||
| assert_json '[{"refName":[{"exclude":[],"include":[]}],"repositoryName":[{"exclude":[],"include":["~ALL"],"protected":false}]}]' '.spec.forProvider.conditions | sort_keys(..)' | ||
| assert_json '[{"creation":false,"deletion":false,"nonFastForward":false,"requiredLinearHistory":false,"requiredSignatures":true,"update":false}]' '.spec.forProvider.rules | sort_keys(..)' | ||
| assert_json '["bypassActors","conditions","enforcement","name","rules","target"]' '.spec.forProvider | keys | sort' | ||
|
|
||
| echo "signing-rule-retirement: OK" |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.