Skip to content

feat(control): tag patterns must be protected (tagMustBeProtected, ISSUE-510) - #581

Merged
thomasboni merged 1 commit into
mainfrom
feature/398-tag-protection-check
Nov 26, 2026
Merged

thomasboni merged 1 commit into
mainfrom
feature/398-tag-protection-check

Conversation

@Exypte

@Exypte Exypte commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

feat

What this PR does / why we need it:

Plumber checks branch protection but not tags. Anyone with push access can create, move or delete a release tag, and tags drive release workflows and action pins (the tj-actions attack moved existing tags). This adds a cross-provider control, tagMustBeProtected (CTRL-510 / ISSUE-510, gate role).

  • What it checks. The tag patterns in namePatterns (default v*), plus the patterns GitHub workflows trigger on (on.push.tags, read with GitHub's filter syntax, where + and ? are quantifiers). A pattern is only checked while it is in use: an existing tag matches it, or a workflow triggers on it. So a repository that never tags stays quiet.
  • What counts as protected. Tag updates and deletions are blocked, and tag creation is restricted (set requireCreationRestricted: false to drop the creation requirement).
    • On GitHub: active tag rulesets with the update, deletion and creation rules. Each protection is judged across all rulesets, because GitHub layers them.
    • On GitLab: a protected tag covering the pattern. It always blocks update and delete, and creation counts as restricted unless a create level lets in Developers or below.
    • A rule covers a pattern when it matches the pattern itself and every existing tag the pattern matches.
  • Severity. One finding per pattern. It is critical when a workflow releases from tags (a push-tags trigger, on: release, GitLab only: tags or a positive $CI_COMMIT_TAG rule), and high otherwise.
  • Tokens.
    • GitHub: reading tag rulesets and tags needs only Metadata: read, which permissions: {} grants (checked in a real workflow run). Rulesets need a public repo or GitHub Pro+, and GHES 3.11+.
    • GitLab: read_api.
    • Without access, the control reports "not evaluated", never a finding.
    • A network failure marks the run degraded.
  • Config keys, schema docs, plumber init, both default configs, the legacy JSON block, the catalog, the issue docs, and the action.yml / README token text are updated.

Which issue(s) this PR is related to:

Fixes #398

Special notes for your reviewer:

  • GitLab platform mode: the snapshot has no tag lane yet, so the control reports lane_not_served (through controlsWithNoPlatformLane), which keeps the no-extended-rights contract. A platform follow-up issue will serve the lane.
  • Bypass actors: ruleset bypass actors are not read. The API returns them only with admin rights, and the control is built to run on Metadata read. A ruleset that every pusher can bypass therefore counts as protection.
  • Listing caps: ruleset and protected-tag listings past their page cap (10 × 100) report "not evaluated", because a rule beyond the cap could be the one protecting a pattern. The tag listing past its cap only sets tagsTruncated, which can hide a finding but never invent one.
  • Bracket patterns: GitHub tag rulesets reject […] patterns ("Invalid target patterns"), while workflow filters accept them.
  • Pre-existing lint warnings: make lint reports 7 govet reflect.Ptr warnings in files this PR does not touch (configuration/schema.go, control/catalog.go).
  • Website: the ISSUE-510 page is docs(issues): document ISSUE-510, tag must be protected (CTRL-510) getplumber.io#523. The code is 510 because 507 and 508 are retired on the website and 509 still redirects to ISSUE-803.

Does this PR introduce a user-facing change?

New control tagMustBeProtected (ISSUE-510), enabled by default on GitLab and GitHub. It flags release tag patterns in use (default `v*`, plus GitHub on.push.tags patterns) whose tags can be moved, deleted or created by anyone with push access. New config block:

tagMustBeProtected:
  enabled: true
  namePatterns: [v*]
  requireCreationRestricted: true

GitHub needs Metadata: read (any token); GitLab needs read_api. Without access the control reports "not evaluated". In GitLab platform mode it reports lane_not_served for now.

How was this tested?

  • Unit tests:

    • the Rego rule: coverage, layering, excludes, creation toggle, GitHub filter syntax, messages, severity cases;
    • both collectors (httptest fakes, including 403/404, 500, and listing caps);
    • control status, lanes, gap marking, platform call ledger;
    • config defaults, identity fingerprint, init starter.
  • make build, go test ./... and gofmt are clean; lint as noted above.

  • plumber analyze with the local binary:

    • GitHub, Exypte/tag-protection-lab (public lab repo):

      Setup Result
      No tags passed
      Tag v1.0.0, no ruleset high
      Workflow on release-* critical, ! entries ignored
      on: release v* critical
      Full rulesets passed
      Disabled ruleset flagged
      No creation rule partial message
      No creation rule, requireCreationRestricted: false passed
      Layered ~ALL creation ruleset passed
      Workflow on v[0-9]+.[0-9]+.[0-9]+, v* ruleset passed
      Same, v* ruleset disabled 2 critical findings
    • GitHub, Exypte/garbage (private, Free plan): not evaluated (rulesets API 403).

    • GitLab, thibaultcondemine/garbage:

      Setup Result
      No tags passed
      Tag v1.0.0 high
      $CI_COMMIT_TAG release job critical
      Rule on $CI_COMMIT_TAG_MESSAGE only high
      v* protected for Maintainers passed
      v* protected for Developers creation missing
      Nested tag v2/hotfix covered
  • A real GitHub Actions run confirmed that GITHUB_TOKEN lists tag rulesets and tags both with contents: read and with permissions: {}.

AI usage disclosure:

YES. Implemented with Claude Code (design, code, tests and e2e runs), reviewed by the author, who is responsible for the submitted changes (CONTRIBUTING.md, AI_POLICY.md).

🤖 Generated with Claude Code

Comment thread cmd/legacy_json.go Resolved
Comment thread cmd/init.go Resolved
Comment thread policies/tag_unprotected.rego Resolved
Comment thread github/github_tag_protection.go Resolved
Comment thread gitlab/collect_tag_protection.go Resolved
Comment thread policies/tag_unprotected.rego Resolved
Comment thread control/task_github.go Resolved
Comment thread control/task.go Resolved
@Exypte Exypte changed the title feat(control): tag patterns must be protected (tagMustBeProtected, ISSUE-507) feat(control): tag patterns must be protected (tagMustBeProtected, ISSUE-510) Oct 30, 2026
Comment thread control/task.go Resolved
Comment thread control/task_github.go Resolved
Comment thread control/bestfix.go Resolved
Comment thread control/tag_collection_test.go Resolved
thomasboni pushed a commit to getplumber/getplumber.io that referenced this pull request Nov 9, 2026
New cross-provider control from getplumber/plumber#581: issue page with
GitLab and GitHub fixes, control id, and its controls configuration
section.
@thomasboni

Copy link
Copy Markdown
Contributor

@Exypte there are several comments to resolve before review

@thomasboni

Copy link
Copy Markdown
Contributor

@Exypte lgtm but squash your commit in one signed commit

…SUE-510)

Add a cross-provider control (CTRL-510 / ISSUE-510) that flags release tag
patterns anyone with push access can move, delete or create.

It checks the patterns in namePatterns (default v*) plus the tag patterns
GitHub workflows trigger on (on.push.tags). A pattern is checked only when an
existing tag matches it or a workflow triggers on it.

On GitHub, protection comes from active tag rulesets with the update, deletion
and creation rules, judged across all rulesets. On GitLab it comes from a
protected tag covering the pattern; creation counts as restricted unless a
create level lets in Developers or below. requireCreationRestricted: false
drops the creation requirement.

A finding is critical when a workflow releases from tags, high otherwise.
GitHub needs Metadata: read, GitLab read_api. Without access the control
reports "not evaluated". GitLab platform mode reports lane_not_served until the
snapshot serves tags.

Fixes #398

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exypte
Exypte force-pushed the feature/398-tag-protection-check branch from 5a3ca28 to 63f5036 Compare November 24, 2026 09:36
@Exypte

Exypte commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

squash your commit in one signed commit

@thomasboni Done. The branch is now one signed commit, 63f5036 (Verified). The diff is the same as before.

@thomasboni
thomasboni merged commit e2b13ab into main Nov 26, 2026
19 of 20 checks passed
@thomasboni
thomasboni deleted the feature/398-tag-protection-check branch November 26, 2026 14:40
plumber-release Bot pushed a commit that referenced this pull request Nov 30, 2026
## [0.7.24](v0.7.23...v0.7.24) (2026-11-30)

### ✨ Features

* **control:** tag patterns must be protected (tagMustBeProtected, ISSUE-510) ([#581](#581)) ([e2b13ab](e2b13ab)), closes [#398](#398)
* **github:** send fewer GitHub requests and read GitHub through GraphQL ([#649](#649)) ([53c5406](53c5406)), closes [#618](#618) [#637](#637) [#618](#618)

### 🐛 Bug Fixes

* **github:** match trusted owner lists without regard to case ([#629](#629)) ([4160592](4160592)), closes [#623](#623)

### 🔧 Chores

* code owners only on the action lockfile, owned by the cli team ([#656](#656)) ([80c4d31](80c4d31))

### 📚 Documentation

* explain the release process ([#601](#601)) ([67557b9](67557b9))
* **readme:** add InvokeAI and Clash Nyanpasu to the adopters row ([#613](#613)) ([798fd9f](798fd9f)), closes [invoke-ai/InvokeAI#9944](invoke-ai/InvokeAI#9944) [#10109](https://github.com/getplumber/plumber/issues/10109) [libnyanpasu/clash-nyanpasu#6286](libnyanpasu/clash-nyanpasu#6286) [#6323](https://github.com/getplumber/plumber/issues/6323) [#6324](https://github.com/getplumber/plumber/issues/6324)

### 👷 CI/CD

* keep the corpus under -race, lint through golangci-lint-action, harden the scan gate ([f7960e6](f7960e6))
* run the corpus without the race detector, cache golangci-lint, scan the image only when it changed ([d69f9ac](d69f9ac))
* trust golangci-lint-action in the Plumber action allowlist ([3d71094](3d71094))
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.

Tag protection check

2 participants