Skip to content

fix(managed-files-guard): exempt sync PRs only when the sync App opened them - #690

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/managed-files-guard
Oct 5, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/managed-files-guard

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: Phase 7 defect D13 from the 2026-10-03 ci-workflows defect review.

Summary

The managed-files guard skipped any PR labelled standards-sync, and anyone who can label a PR could add that label to bypass the guard on standards-managed files. It also accepted the plain logins melodic-standards-sync and dependabot, which a user account could register.

Fix

  • A PR skips the guard only when its author is melodic-standards-sync[bot] and it carries the standards-sync label. The sync always applies that label (maintenance-sync-standards.yml:494), so real sync PRs still skip.
  • Only dependabot[bot] skips as a Dependabot author; the plain dependabot login no longer does.
  • standards-ref stays main, and its description now says why: the guard must read the manifest live for each target, and the synced standards callers pass main on purpose. A caller may still pin a SHA, as ci-workflows' own job does.

Verification

  • New .github/scripts/check-managed-files-skip.test.cjs extracts the skip step's script from action.yml and runs it on 7 cases: label alone, bot alone, bot plus label, plain logins, Dependabot. 7 pass; 4 fail against main's action.yml.
  • actionlint, shellcheck, composite-run-shellcheck.sh: exit 0. zizmor --offline: no findings.

Related

  • Phase 7 defect ledger row D13
  • Follow-up: the standards caller headers and README still describe the exemption as "label OR bot"; that wording is updated in standards after this merges.

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits October 4, 2026 21:19
The skip step exempted a PR carrying the standards-sync label from any
author, and a PR from the sync App (or a user named like it) without the
label. Exempt only a PR authored by melodic-standards-sync[bot] that also
carries the label. The dependabot author exemption is unchanged.

Document why standards-ref defaults to main: the guard must read the
manifest that is live for the target, and a fixed SHA stops tracking
roster and component changes as soon as standards moves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The skip step also accepted a plain `dependabot` login, which a user
account could hold. Accept only the App login `dependabot[bot]`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton enabled auto-merge (squash) October 5, 2026 01:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T01:24:13.236220Z 6b42970 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 3m 27s —— View job


Review: fix/managed-files-guard (6b42970)

  • Gather context (PR body, AGENTS.md/REVIEW.md lane split, gh pr diff, full action.yml)
  • Verify the sync-App/label assumption against maintenance-sync-standards.yml
  • Trace the new test file's parsing logic against action.yml's actual indentation
  • Confirm the new .test.cjs is wired into CI
  • Post review

Scope note: this repo runs a separate security lane (pr-review-security.yml), so per REVIEW.md this lane reports correctness/design/maintainability only — the bypass this PR fixes is a security concern and is left to that lane.

Findings: none that meet the blocking/important bar.

What I checked and why it held up:

  • The new gating in action.yml requires both PR_ACTOR == 'melodic-standards-sync[bot]' and the standards-sync label. I confirmed maintenance-sync-standards.yml's create-pull-request step unconditionally sets labels: standards-sync on every sync PR it opens, so real sync PRs still skip — the PR's own claim about that line holds.
  • PR_ACTOR is read from github.event.pull_request.user.login, the immutable PR opener for the lifetime of the pull request event — not attacker-settable the way the label was, so the original bypass (label alone) is actually closed.
  • The multi-line [[ ... && ... ]] condition is valid bash (the test command isn't closed until ]], so the bare newline before the continuation doesn't need a backslash) — not a syntax bug.
  • Walked the new check-managed-files-skip.test.cjs extraction logic (split on ^ - name: , locate the id: skip chunk, split on run: |\n, de-indent by 8) against the literal file content — it correctly isolates the embedded script for all 7 cases the file asserts. Confirmed node --test .github/scripts/*.test.cjs at pr-require-checks.yml:437 already globs .github/scripts/*.test.cjs, so this new file runs in CI with no additional wiring needed.
  • Could not execute node --test myself in this sandbox (command execution was denied), so the author's "7 pass / 4 fail against main" numbers are author-claimed and I did not independently reproduce them — I verified the logic by reading rather than running it.

Minor, not rising to a reported finding: the test's YAML-scraping approach (locate step by id: skip, then slice on exact 8-space indentation) is a little tightly coupled to today's formatting of action.yml, but a mismatch fails loudly via assert.ok(step, "skip step not found") rather than silently passing, so I didn't flag it.

PR body satisfies the pr-body-contract rule (no-related-issue line plus all four required sections).

@claude

claude Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 1m 44s —— View job


Security review complete ✅

  • Gather context (PR diff, changed files)
  • Review action.yml guard logic for logic/auth gaps
  • Review new test file
  • Check instruction-surface deletions (AGENTS.md / rules files)
  • Post findings

No security issues found.

Scope: .github/actions/check-managed-files/action.yml and the new .github/scripts/check-managed-files-skip.test.cjs.

Notes from the review:

  • The new skip condition (lines 38–42) requires PR_ACTOR == 'melodic-standards-sync[bot]' and the standards-sync label, replacing the old label-only OR-bot-only logic. pull_request.user.login is set by GitHub from the actual PR author and cannot be spoofed by a user account (the [bot] suffix is reserved for Apps), and labels on a pull_request-triggered run require write access to apply — so this tightens the exemption without introducing a new bypass.
  • The dependabot[bot] case now matches only the exact App login, dropping the plain dependabot string that a user account could have registered. This closes the bypass described in the PR body; I didn't find a residual way to trigger it.
  • Confirmed the caller workflow (pr-require-checks.yml) runs this action on pull_request (not pull_request_target) with repo-level permissions: contents: read, so there's no secret/privilege exposure to fork-authored input here regardless of the skip outcome.
  • The standards-ref default stays main; the caller job pins a full SHA (c4d865bb12...) as the updated input description says it should, consistent with the described intent — no SHA-pinning regression.
  • The new test file only reads the checked-in action.yml and executes the extracted trusted script locally via execFileSync; no external/PR-controlled input reaches it, so no injection surface there.
  • No AGENTS.md/rules-file/guardrail deletions in this diff to check against the instruction-exception register — the change only narrows (hardens) an exemption, it doesn't remove or soften a standing instruction.

Actions-hardening concerns (unpinned actions, pull_request_target, expression injection) are zizmor's lane; the PR description reports zizmor --offline: no findings, consistent with what I saw.

@kyle-sexton
kyle-sexton merged commit 8d984f9 into main Oct 5, 2026
28 checks passed
@kyle-sexton
kyle-sexton deleted the fix/managed-files-guard branch October 5, 2026 01:22
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

claude-security-review has reviewed this pull request through 6b42970; a later push is reviewed from there.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b42970884

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +40 to +41
if [[ "$PR_ACTOR" == 'melodic-standards-sync[bot]' &&
",${PR_LABELS}," == *",standards-sync,"* ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refetch labels applied after PR creation

On every newly created standards-sync PR, the pinned peter-evans/create-pull-request implementation creates the PR without labels and adds labels afterward. Consequently, the pull_request: opened payload has no standards-sync label, so this condition rejects a genuine App-authored sync PR; .github/workflows/pr-require-checks.yml:368-379 runs the guard on opened but explicitly skips it for the subsequent labeled event, leaving the advisory check red. Refetch the PR's current labels before evaluating the App-plus-label condition rather than relying on the frozen event payload.

Useful? React with 👍 / 👎.

Comment on lines +38 to 42
# Anyone who can label a PR can add `standards-sync`, so the label
# exempts only a PR the sync App itself opened.
if [[ "$PR_ACTOR" == 'melodic-standards-sync[bot]' &&
",${PR_LABELS}," == *",standards-sync,"* ]]; then
skip=true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Correct the now-impossible label remediation

For a contributor-authored PR that hits the guard, .github/actions/check-managed-files/run.sh:72-75 still instructs the user to add the standards-sync label, but this new actor check means that instruction can never clear the failure for that PR. Update the rejection message to explain that only App-authored sync PRs are exempt and that other changes must be made in the standards source.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

claude-review has reviewed this pull request through 6b42970; a later push is reviewed from there.

kyle-sexton added a commit to melodic-software/standards that referenced this pull request Oct 5, 2026
No related issue: wording follow-up to
melodic-software/ci-workflows#690.

## Summary

ci-workflows#690 changed the `check-managed-files` composite so that a
pull request skips the managed-files guard only when
`melodic-standards-sync[bot]` authored it **and** it carries the
`standards-sync` label. Before, either one was enough. The component's
caller headers and README still described the old rule.

## Fix

- The headers in `managed-files-guard.yml` and
`managed-files-guard-fleet.yml` and one README line now state the rule:
authored by `melodic-standards-sync[bot]` and labelled `standards-sync`.
- The change is comment and docs only; no YAML key, value or job
changed.
- The README's dated per-version history (around lines 144-151) is left
as written, since it describes past releases.

## Verification

- `components/managed-files-guard/managed-files-guard.test.sh`: 0 FAIL.
- markdownlint: 0 issues.

## Related

- melodic-software/ci-workflows#690

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant