Skip to content

fix(claude-ops): report a directory marketplace's checkout staleness in plugins sync - #4457

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/plugins-directory-source-staleness
Sep 24, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/plugins-directory-source-staleness

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Fixes #4456

Summary

/claude-ops:plugins sync reported Marketplace: melodic-software: current with zero updates while the directory source's checkout was 28 commits behind origin/main. After a fast-forward, the same sync updated 22 plugins. claude plugin marketplace update on a directory source validates the directory as it is and fetches nothing, so the catalog is only as fresh as the checkout, and nothing in the report said so.

Fix

  • sync-run.sh: new source_checkout digest field, computed once per marketplace block and only for a directory source (parsed from the directory:<path> catalog_source the digest already carried, backslashes folded the way fleet-state.sh folds installLocation). It records state (tracking, no_upstream, detached, not_a_repo), branch, upstream, ahead/behind from git rev-list --left-right --count HEAD...@{u} as of the checkout's last fetch, and whether tracked files are modified. Every git call is read-only and runs with --no-optional-locks, so status does not refresh the index. The script never fetches or pulls the checkout. Other source kinds get null, so every existing golden is unchanged.
  • The probe lives in sync-run.sh, not fleet-state.sh, because fleet-state.sh runs four or more times per sync and the probe includes a git status on the checkout.
  • render-report.jq: a source: row under the Marketplace: line for a directory source; the status reads source checkout behind <upstream> instead of current when behind > 0; an Action needed bullet names git -C '<path>' pull --ff-only (path quoted with @sh), then /claude-ops:plugins sync <marketplace>, noting when local commits or modified files would make the pull refuse. needs update still means only this run's own failures and gaps.
  • SKILL.md: update is an alias for sync in the Action Router (the description already lists "update my plugins" as a trigger).
  • Docs: SKILL.md Report section and context/sync.md digest enumeration. claude-ops 0.59.4 → 0.60.0 with CHANGELOG entry.

Verification

  • New golden fixtures/render/directory-source-behind.txt, driven by a real clone two commits behind its origin with a modified tracked file. On Git Bash the source path is recorded in native backslash form via cygpath -w, which is how Claude Code records it on Windows.
  • The same case asserts HEAD, origin/main, and the .git/index checksum are unchanged after the run.
  • no_upstream, detached, and not_a_repo are asserted on the digest state and the rendered row, and each keeps the current status. A github source asserts source_checkout: null.
  • Local (Git Bash, Windows): all new assertions pass. shellcheck is clean, markdownlint is clean, and check-changelog-parity.sh --check-bump against origin/main passes. One unrelated case, --only-install: and only INSPECTED the project-scope map, fails locally on Windows; it fails the same way when the origin/main copy of these scripts runs alone, so this change did not cause it. It passes on CI Linux.
  • CI: test-linux runs sync-run.test.sh and passes the new cases. test-windows does not run this suite, so Windows coverage of the native-path case comes from the local run only.
  • Review: both Codex findings are fixed in 48eb8d5. The path is shell-quoted with @sh, and the rerun names the marketplace.

Related

🤖 Generated with Claude Code

…in plugins sync

claude plugin marketplace update validates a directory source as it is and
fetches nothing, so sync reported "current" while the checkout sat 28
commits behind origin/main. sync-run.sh now reads a directory source's
checkout (branch, upstream, ahead/behind as of the last fetch, modified
tracked files) into the digest's source_checkout field without fetching,
pulling, or writing. The render adds a source row, swaps "current" for
"source checkout behind <upstream>" when behind, and names the
git pull --ff-only to run. Also accept update as an alias for sync.

Fixes #4456

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review September 24, 2026 16:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 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-09-24T16:34:49.229109Z 37c2b1a Draft marked ready
ℹ️ 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 Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 5m 30s —— View job


/review:code-review — code-review lane

Task list

  • Gather context (diff via gh pr diff 4457, read changed files)
  • Invoke /review:code-review and follow its instructions
  • Trace source_checkout() (sync-run.sh) and the render-report.jq changes against the new golden fixture and digest schema
  • Post summary comment

Result: no high-signal findings

I traced the new source_checkout() probe in sync-run.sh and the corresponding render-report.jq logic line-by-line against the digest schema and the new golden fixture:

  • git rev-list --left-right --count HEAD...@{u} ordering (ahead behind) matches how render-report.jq consumes $c[0]/$c[1] and matches the "2 behind and 0 ahead" fixture.
  • The state short-circuit (no_upstream/detached/not_a_repo) correctly avoids referencing ahead/behind/upstream when they're null, and $behind (($src.behind // 0) > 0) is safe against a null $src.
  • The Action needed bullet for a behind checkout is correctly gated only on $behind, independent of $needs, so it still surfaces even when other gaps also trigger needs update (matching the documented "needs update still means only this run's own failures and gaps").
  • The path-folding (${path//\\//}) and directory: prefix stripping look correct, including for Windows drive-letter paths (C:\... retains its colon after stripping only the directory: prefix via #, not ##).
  • --no-optional-locks usage and the read-only-only git calls (no fetch/pull) match the test's own before/after HEAD, origin/main, and .git/index checksum assertions.
  • The not_a_repo render branch intentionally omits the "(this run does not fetch or pull it)" suffix and dirty check — consistent with there being no checkout to speak of.

I did not find a correctness bug a careful reviewer would block on. Nothing here rises to the high-signal bar (no logic errors, no untested edge case that renders wrong, no security issue).

Caveat on verification: this lane's tool grant doesn't extend to running arbitrary shell (bash sync-run.test.sh, shellcheck) — only gh pr diff/view/comment/review, Read, Glob, Grep. I could not independently execute the test suite, shellcheck, or check-changelog-parity.sh, so the PR author's "Local (Git Bash, Windows): all new assertions pass / shellcheck clean" claims are author-reported and unverified by me, not independently confirmed. If test/lint execution should be part of this lane's review, --allowedTools would need Bash(bash *) or similar added.

@claude

claude Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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


Security review: no issues found

Reviewed the full diff (gh pr diff 4457) against the /review:security-review criteria: logic
flaws, authorization/access-control gaps, injection surfaces (command, SQL, path, template), and
unsafe handling of tokens/secrets/credentials. No CI workflow files are touched, so the Actions
hardening lane (zizmor) doesn't apply here.

The new attack-surface-relevant code is the source_checkout() function added in
sync-run.sh,
which parses the directory:<path> form of catalog_source and runs several read-only git
probes against it, plus the corresponding render logic in
render-report.jq.

Checked specifically for:

  • Command injection. Every git invocation builds an argv array (g=(git --no-optional-locks -C "$path")) and calls it as "${g[@]}" <subcommand> — the path is never interpolated into a string that's passed to sh -c/eval/bash -c, so shell metacharacters in $path can't break out. Even a path beginning with - is safe because it's consumed as the value of the preceding -C flag, not re-parsed as an option.
  • jq injection. All dynamic values (path, state, branch, upstream, counts, dirty) cross into jq via --arg/--argjson on trusted, script-produced JSON, never string-concatenated into the jq program text.
  • Mutation guarantees. The function is read-only as documented: --no-optional-locks keeps status from touching .git/index, and there's no fetch/pull/write call anywhere in the new code. The new golden test (directory-source-behind.txt) explicitly asserts HEAD, origin/main, and the index checksum are unchanged after a run, which backs this up.
  • Trust boundary of path. It comes from catalog_source, sourced from the local known_marketplaces.json, which the user themselves populates via claude plugin marketplace add <path> — not from remote/catalog content, so it isn't attacker-influenced through the marketplace being synced.
  • The suggested git -C "<path>" pull --ff-only line in the Action needed output (render-report.jq#L211) is advisory text only — the script never executes it — and path isn't attacker-controlled per the point above, so there's no concrete exploit path here worth flagging.

No CRITICAL, IMPORTANT, or SUGGESTION-level security findings.

@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: 37c2b1a970

ℹ️ 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".

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Last security-reviewed head: 48eb8d52bd5c3e6099fccff8f99ff9ed8d3954cf. On the next push, the relevance gate compares only the commits since this SHA; delete this comment to force a full re-review.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Skill evidence: a gap at 48eb8d52bd5c3e6099fccff8f99ff9ed8d3954cf

The skill-evidence block under ## Verification does not cover every mandatory
skill for the files this pull request changes, read against the map in
.claude/source-control.md:

class=code
class=markdown
class=skills
class=security
missing=verification:confirm
missing=review:quality-gate,review:fanout
missing=simplify
missing=ai-slop:audit
missing=docs-hygiene:audit-noise
missing=skill-quality:check
missing=review:security-review

Run /source-control:pull-request ready to re-render the block at the current head.
This is advisory: no check turns red on it.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude has reviewed this PR 2 times. Deleting this comment resets the count.

…ce in the rerun

The Action needed bullet interpolated the raw path between double quotes,
which a path carrying $, backticks or a quote would break; it now renders
through jq's @sh. The rerun also names the marketplace, since a bare sync
targets only the default marketplace. Both from the Codex review on #4457.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@claude

claude Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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


/review:code-review — code-review lane

Task list

  • Gather context (PR diff, changed files, HEAD 48eb8d5)
  • Invoke /review:code-review and follow its instructions exactly
  • Post inline findings (if any) via mcp__github_inline_comment__create_inline_comment
  • Post summary comment

Result: no high-signal findings

This lane's last review covered 37c2b1a. Since then, 48eb8d5 landed to address the two Codex
P2 findings from that review — shell-quoting the checkout path and preserving the marketplace name
in the rerun command — so I focused this pass on that incremental diff (render-report.jq,
SKILL.md, CHANGELOG.md, and the golden fixture; sync-run.sh is unchanged since the prior
review).

Verified in
render-report.jq#L196-L201:

  • \($src.path | @sh) replaces the raw double-quoted interpolation. @sh wraps the value in
    single quotes with embedded single quotes escaped, so a path containing $, backticks, or "
    no longer breaks the suggested command — this fixes the shell-quoting finding.
  • \(.name) in then rerun /claude-ops:plugins sync \(.name)\`` — inside def block($d), .is the current marketplace object from$d.marketplaces[](same scope.nameis already used in at line 68's"Marketplace: (.name): ..."), so this correctly names the marketplace whose checkout is stale rather than defaulting to a bare sync` that only targets the default
    marketplace — this fixes the marketplace-preservation finding.

Cross-checked against the updated golden
(fixtures/render/directory-source-behind.txt)
and the corresponding test case in
sync-run.test.sh#L1114-L1159,
which drives a marketplace literally named market1 and asserts the rendered line reads
rerun `/claude-ops:plugins sync market1` with the single-quoted path — both fixture and
no_upstream/detached/not_a_repo cases (which never reach this bullet) stayed consistent with
the code change. CHANGELOG.md and SKILL.md prose were updated to match. No linter/typechecker
class issue and no new correctness gap introduced by this commit.

I did not re-run shellcheck, the .test.sh suite, or check-changelog-parity.sh myself — this
lane's tool grant is Bash(gh pr diff/view/comment/review), Read, Glob, Grep only, no general
shell execution — so the author's "shellcheck clean / all new assertions pass" claims remain
author-reported, not independently confirmed by me.

@claude

claude Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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


Security review: no issues found

Task list

  • Gather context (PR diff via gh pr diff 4457, custom instructions)
  • Invoke /review:security-review and follow its instructions exactly
  • Re-review the head that changed since the last security pass (37c2b1a → 48eb8d5)
  • Post findings

Scope

This PR's last review ran at 37c2b1a. Head SHA 48eb8d5 adds one more commit on top of that,
48eb8d5,
which resolves the two Codex P2 review comments on this PR (shell-quote the checkout path;
preserve the selected marketplace in the rerun command). Neither of those was a security finding
in Codex's own review (labeled P2/correctness, not a CVE-class report), but since they touch the
same command-construction logic this lane cares about, I re-checked them under the security
criteria rather than assuming they're out of scope.

What changed and what I checked

render-report.jq#L197-L200:

  • The suggested remediation command now reads git -C \($src.path | @sh) pull --ff-only —
    @sh is jq's shell-quoting filter (wraps in single quotes, escapes embedded ' as '\''), so a
    directory-source path containing spaces, $, backticks, or quotes now renders as a single
    correctly-quoted shell token instead of an unescaped literal. This is advisory text only (the
    script never executes it), but it's now safe to copy-paste even for a path an attacker could
    influence, which closes the gap Codex flagged.
  • The rerun command now reads /claude-ops:plugins sync \(.name) instead of a bare sync,
    so a non-default marketplace's rerun suggestion targets the marketplace that was actually found
    behind, rather than silently falling back to the plugin's default marketplace.

Both match the new golden fixture
(directory-source-behind.txt):
git -C '<case>/mkt' pull --ff-only, sync market1.

I re-verified the rest of the attack surface this PR introduces, source_checkout() in
sync-run.sh#L1275-L1306,
against the same criteria as the prior pass on this PR:

  • Command injection. Every git call is built as an argv array
    (g=(git --no-optional-locks -C "$path"), invoked as "${g[@]}" <subcommand>); $path is never
    interpolated into a string handed to a shell. A path beginning with - is still safe, it's
    consumed as the -C flag's value, not re-parsed as an option.
  • jq injection. All dynamic values (path, state, branch, upstream, counts, dirty)
    cross into jq via --arg on script-produced strings, never concatenated into the jq program
    text.
  • Mutation guarantees preserved. Still read-only: --no-optional-locks on every call, no
    fetch/pull/write anywhere in the new code. Unchanged from the prior pass, and still backed
    by the golden test's before/after HEAD, origin/main, and .git/index-checksum assertions.
  • Trust boundary. path still originates from catalog_source in the user's own local
    known_marketplaces.json (populated via claude plugin marketplace add <path>), not from
    remote/catalog content, so it isn't attacker-influenced through the marketplace being synced.

The remaining changed files (CHANGELOG.md, plugin.json version bump, SKILL.md, context/sync.md,
sync-run.test.sh) are docs/version/test-only and carry no new runtime attack surface. No CI
workflow files are touched, so Actions-hardening (zizmor's lane) doesn't apply.

No CRITICAL, IMPORTANT, or SUGGESTION-level security findings.

@kyle-sexton
kyle-sexton merged commit 49dac96 into main Sep 24, 2026
3 checks passed
@kyle-sexton
kyle-sexton deleted the fix/plugins-directory-source-staleness branch September 24, 2026 17:49
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.

claude-ops:plugins: sync reports a directory-source marketplace as current while its local checkout is behind upstream

1 participant