Add restrict_update convenience key to prevent tags from being moved - #120
Open
ppkarwasz wants to merge 1 commit into
Open
Add restrict_update convenience key to prevent tags from being moved#120ppkarwasz wants to merge 1 commit into
ppkarwasz wants to merge 1 commit into
Conversation
Tag rulesets written in convenience syntax now emit GitHub's "update" rule by default, preventing existing tags from being moved to a different commit by anyone without bypass permission. This matches the semantics of the deprecated protected_tags setting and removes the need to fall back to the raw payload syntax for tag protection. Branch rulesets keep their previous defaults (restrict_deletion and restrict_force_push only), since an update rule on branches would block all pushes for non-bypass actors. Branches can still opt in with "restrict_update: true" and tags can opt out with "restrict_update: false". Assisted-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Tag rulesets written in the convenience syntax now emit GitHub's
updaterule by default, via a newrestrict_updateconvenience key. This prevents existing tags from being moved to a different commit by anyone without bypass permission, matching the semantics of the deprecatedprotected_tagssetting.Defaults differ by target:
type: branch:restrict_deletionandrestrict_force_pushremain enabled by default (unchanged);restrict_updatedefaults tofalse, since anupdaterule on branches would block all pushes for non-bypass actors.type: tag: additionally enablesrestrict_updateby default.Both targets can override the defaults explicitly (
restrict_update: trueon branches,restrict_update: falseon tags).Motivation
As part of apache/logging-parent#477, the Logging Services project is migrating its branch and tag protection to rulesets. Without an
updaterule, a convenience-syntax tag ruleset protects tags from deletion and force-pushes, but not from being moved, so tag rules had to be written in the raw payload syntax. With this change, tag rules can be expressed entirely in the convenience format.Changes
restrict_updateadded to the convenience key set (recognized in convenience entries, rejected when mixed into raw payloads)._is_safety_rule_enabled()gained a target-aware default, used to emit{"type": "update"}.["deletion", "non_fast_forward", "update"], plus coverage for explicit true/false on both targets, invalid types, and mixed raw/convenience rejection.protected_tagssemantics out of the box.Raw payload entries are unaffected.
Fixes #96