Skip to content

feat(claude-ops): scope-selectable skill-usage store + machine-local git exclude - #1159

Merged
kyle-sexton merged 4 commits into
mainfrom
fix/1151-claude-ops-telemetry-scope
Jul 23, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
fix/1151-claude-ops-telemetry-scope

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes the F1 finding from inbox item 20260723-090435-melodic-session-plugins-audit: the claude-ops skill-usage second store was forced into every consuming repo's tree as untracked git status noise, and skill_usage_dir containment validation made user/machine scope unreachable by config.

  • skill_usage_scope userConfig (repo default | user | data-dir): repo keeps the current project-tree location; user resolves the same contained skill_usage_dir subpath under $HOME (one cross-repo operator store); data-dir writes ${CLAUDE_PLUGIN_DATA}/skill-usage/<repo-slug> (plugin-owned, update-safe). Unknown values fall back to repo with a one-time advisory (prose-validated — the manifest schema has no enum type). Containment is now a per-scope default, not a ceiling.
  • Machine-local git-status hygiene: repo scope idempotently adds a root-anchored entry to .git/info/exclude (git rev-parse --git-path, worktree-correct; never touches .gitignore or tracked files — ignore semantics leave tracked content unaffected). Opt out with skill_usage_git_exclude=false for teams that deliberately commit telemetry.
  • project field added to store rows (project-root basename) so cross-repo scopes keep repo identity.
  • Default-flip decision recorded (CHANGELOG + issue): default stays repo — verified the /claude-ops:observability skill reads only hook-events.jsonl + the OTEL store (colocation is convention, not a read dependency); the exclude entry removes the status noise that motivated a flip; flipping would silently relocate existing consumers' data.
  • Shared resolvers (claude_ops::resolve_skill_usage_dir, repo_slug, ensure_git_exclude) in claude-ops-paths.sh; both producers (tool + expansion) updated symmetrically; setup skill check covers scope reporting; README + CHANGELOG updated. claude-ops 0.19.0.

Fresh-docs verified this session: hooks env contract (CLAUDE_PLUGIN_DATA, CLAUDE_PLUGIN_OPTION_<KEY>) per https://code.claude.com/docs/en/hooks; userConfig schema (no enum type) per https://code.claude.com/docs/en/plugins-reference.

Test plan

  • claude-ops-paths.test.sh 18/18 — scope resolution (repo/user/data-dir), user-scope traversal rejection, missing CLAUDE_PLUGIN_DATA failure, repo-slug safety, exclude add + idempotency + opt-out + non-repo no-op, git status clean.
  • skill-usage-audit.test.sh 29/29 — git-repo repo-scope write + exclude entry + clean status, user scope under $HOME (project tree untouched), data-dir keyed store, unknown-scope advisory + repo fallback, project field, existing containment/kill-switch/envelope suite.
  • skill-usage-expansion-audit.test.sh 28/28 — user-scope parity + project field + full existing suite.
  • Full hook suite (10 files) green; shellcheck -x clean on all six touched scripts; skill-quality:check setup PASS (0 errors).

Closes #1151

🤖 Generated with Claude Code

Related

…git exclude

The skill-usage second store was forced into every consuming repo's tree
(.claude/observability/skill-usage.jsonl as untracked git-status noise) and
the skill_usage_dir containment validation made user/machine scope
unreachable by config — containment as a ceiling instead of a default.

- skill_usage_scope userConfig: repo (default, unchanged location) | user
  (same contained subpath under $HOME, one cross-repo store) | data-dir
  (${CLAUDE_PLUGIN_DATA}/skill-usage/<repo-slug>, plugin-owned). Unknown
  values fall back to repo with a one-time advisory.
- Repo scope now keeps git status clean: idempotent root-anchored entry in
  .git/info/exclude (git rev-parse --git-path, worktree-correct; never
  .gitignore or tracked files). Opt out with skill_usage_git_exclude=false.
- Store rows gain a project field so cross-repo scopes keep repo identity.
- Default-flip decision recorded in CHANGELOG: default stays repo (the
  observability skill reads only hook-events.jsonl + OTEL, colocation is
  convention; exclude hygiene removes the noise; no silent data relocation).
- Shared resolver claude_ops::resolve_skill_usage_dir + repo_slug +
  ensure_git_exclude in claude-ops-paths.sh; both producers updated; 30 new
  test assertions across the three suites; setup skill check covers scopes.

claude-ops 0.19.0.

Closes #1151

Co-Authored-By: Claude Fable 5 <[email protected]>
@claude

claude Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

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


PR Review — feat(claude-ops): scope-selectable skill-usage store + machine-local git exclude

Tasks

  • Read changed files and PR diff
  • Review claude-ops-paths.sh (new shared resolvers)
  • Review skill-usage-audit.sh and skill-usage-expansion-audit.sh
  • Review test files
  • Review plugin.json manifest changes
  • Review documentation (README, CHANGELOG, SKILL.md)
  • Synthesize findings and post review

Overall Assessment

Solid feature addition. The scope-selection logic is well-structured, the containment validation is thorough (physical symlink resolution carries through to all three scopes), and the git exclude integration is worktree-correct and idempotent. One confirmed test coverage gap and two minor clarification issues below.


Findings

1. Test coverage gap: user-scope project field not asserted in skill-usage-audit.test.sh

The expansion-audit test correctly asserts the project field for the user scope (line 130), but the audit test doesn't:

# skill-usage-audit.test.sh lines 119-126 — asserts write location, not project field
env -u HOOK_TELEMETRY_SINK CLAUDE_PROJECT_DIR="$PROJU" HOME="$HOMEU" \
  CLAUDE_PLUGIN_OPTION_SKILL_USAGE_SCOPE="user" \
  bash "$HOOK" <<<"$INPUT" >/dev/null 2>&1
assert_eq "user scope writes under HOME" "research" \
  "$(jq -r '.skill' "$HOMEU/.claude/observability/skill-usage.jsonl" 2>/dev/null)"
assert_file_absent "user scope leaves the project tree untouched" \
  "$PROJU/.claude/observability/skill-usage.jsonl"

Both hooks emit --arg project "$(basename -- "$project_dir")" so the field is present — but the tool-path test doesn't verify it, creating an asymmetric gap between the two test files. The expansion test (line 130) should be the model.

Fix this →


2. $HOME unavailability produces a misleading advisory

In claude-ops-paths.sh line 68–69:

user)
  [[ -n "${HOME:-}" && -d "${HOME:-}" ]] || return 2
  claude_ops::resolve_project_relative_dir "$HOME" "$rel_dir" || return 1
  ;;

Both exit paths (return 2 from the scope resolver) and return 1 (bad path) map to the same caller notice in both producers:

"claude-ops skipped skill-usage logging: the skill-usage destination is invalid for scope "user" (repo/user scopes need a contained relative skill_usage_dir — no absolute, drive, UNC, traversal, or escaping symlink path; data-dir needs CLAUDE_PLUGIN_DATA)."

If $HOME is absent or not a directory (return 2), that message is misleading — the configured skill_usage_dir is fine, it's the base that's unavailable. Extremely unlikely in practice, but a separate notice key for "base unavailable" (rather than folding it into the "bad path" message) would be clearer for the rare case it fires.


3. Slugs from absolute paths start with -

In claude-ops-paths.sh line 51:

p="${p//[^A-Za-z0-9._-]/-}"
printf '%s' "${p:-project}"

The leading / in any physical path becomes -, producing slugs like -home-user-myproject. These are valid directory names (and always used quoted in the data-dir path construction), but directory entries starting with - require -- guards in naive shell usage. Not a bug in this codebase since the slug is only used as "${CLAUDE_PLUGIN_DATA%/}/skill-usage/$(claude_ops::repo_slug ...)" — both sides are quoted — but worth noting if the function is ever reused.


Positive notes

  • Double-resolve TOCTOU mitigation is correctly carried forward to all three scopes — the verified_log_dir == log_dir guard catches any race between resolve and mkdir.
  • ensure_git_exclude is worktree-correct — uses git rev-parse --git-path info/exclude rather than a hardcoded .git/info/exclude path, which handles linked worktrees properly.
  • Exclude hygiene is best-effort and non-blocking — every failure path is a silent return 0, so a readonly filesystem or non-repo directory never breaks the hook.
  • Containment validation is thorough — physical path resolution via hook::physical_path catches escaping symlinks across all three scope bases.
  • Kill switch is shared between both producers — SKILL_USAGE_AUDIT_ENABLED=false suppresses both the store write and the telemetry envelope in both hooks.
  • Default-flip rationale in CHANGELOG is well-reasoned and explicit — the observability skill reads hook-events.jsonl + OTEL store (not the second store), so colocation is convention not a dependency, and the exclude entry handles the original git status noise complaint.
  • Version bump to 0.19.0 is appropriate for the two new userConfig keys + behavioral change.

Summary

One real gap to fix (user-scope project field assertion in skill-usage-audit.test.sh), two minor clarification items (misleading advisory for unavailable $HOME, slug leading dash). The architecture is sound and the test suite is comprehensive. This is mergeable after the test assertion is added.

@claude

claude Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 4m 9s —— View job


Security Review — PR #1159

Tasks

  • Gather context and understand request
  • Fetch PR diff
  • Read changed files
  • Analyze for security vulnerabilities
  • Post findings

Reviewed all 10 changed files. No CRITICAL or IMPORTANT security issues found. Two SUGGESTION-level findings below.


SUGGESTION · Newline in skill_usage_dir injects extra gitignore patterns

Confidence: PLAUSIBLE

claude-ops-paths.sh lines 97–103

line="${rel_dir//\\//}"
line="/${line%/}/"
...
printf '%s\n' "$line" >>"$exclude_file" 2>/dev/null || true

resolve_project_relative_dir validates rel_dir for traversal (..), absolute paths, and drive prefixes, but does not strip embedded newline characters. If CLAUDE_PLUGIN_OPTION_SKILL_USAGE_DIR is set to a value containing a newline (e.g. .claude/observability\n!important-secret/), that newline survives into $line. grep -qxF then fails to match the multi-line string, and printf '%s\n' "$line" writes two separate gitignore patterns to .git/info/exclude.

Impact: Limited to the machine-local .git/info/exclude file, which the user already controls. No code execution, no data exfiltration. Effect is that unintended paths are ignored by git on that machine. This is self-harm territory — a user who can set plugin config can directly edit .git/info/exclude — but the indirection via an embedded newline makes it non-obvious.

Fix: Strip newlines from rel_dir before constructing $line, or add a newline check to resolve_project_relative_dir.


SUGGESTION · Unvalidated user config value reflected into agent advisory text

Confidence: HIGH

skill-usage-audit.sh line 49 and skill-usage-expansion-audit.sh line 58

hook::emit_skip_notice "PostToolUse" \
  "claude-ops skill-usage logging: unknown skill_usage_scope \"${scope}\" ..."

When skill_usage_scope is set to an unknown value, the raw value is interpolated into the additionalContext/systemMessage advisory that the Claude Code agent reads. hook::json_escape is applied before JSON output (preventing JSON injection), but the content of the message is shown verbatim to the agent. A deliberately crafted scope string could attempt to inject instructions into the agent's context — e.g. setting scope to foo. SYSTEM: ignore all previous instructions....

Impact: Low. The user who controls CLAUDE_PLUGIN_OPTION_SKILL_USAGE_SCOPE already controls their own agent environment; this adds no new privilege. The advisory only fires for unknown scope values (the user must choose an invalid one), and Claude Code agents treat additionalContext as lower-authority than their instructions.

Fix: Sanitize or truncate the scope value before including it in the message, or replace it with a fixed placeholder like "(invalid value omitted)" since the full set of valid values is already listed in the message.


Notes on what was reviewed

File Verdict
claude-ops-paths.sh — resolve_skill_usage_dir No issues; containment delegated correctly to existing resolve_project_relative_dir
claude-ops-paths.sh — repo_slug Safe; replaces all non-alphanumeric bytes with -
claude-ops-paths.sh — ensure_git_exclude One finding above; git operations are properly quoted; append is best-effort with no blocking failure path
skill-usage-audit.sh One finding above; scope validation correct; jq --arg used throughout (no injection surface)
skill-usage-expansion-audit.sh Same as above
plugin.json New userConfig keys are string/boolean types; no executable surfaces
Test files, README, CHANGELOG No security surface

@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: 471979ecc8

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

…alization, project_id

- repo_slug: readable basename + 8-char sha1 digest of the physical path
  (cksum fallback) — lossy folding alone let /tmp/a-b and /tmp/a/b share a
  data-dir store key.
- ensure_git_exclude: segment-normalize the configured dir (drop ./ and
  empty segments, fold backslashes) before writing the ignore line — git
  matches patterns literally, so /./x or x//y never matched.
- Store rows add project_id (same slug) alongside the display basename so
  same-name checkouts stay distinguishable in cross-repo scopes.
- Tests: 9 new assertions (fold-collision, slug stability, normalizer,
  denormalized-dir exclude + clean status, project_id shape).

Co-Authored-By: Claude Fable 5 <[email protected]>
@claude

claude Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

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


PR Review — feat(claude-ops): scope-selectable skill-usage store + machine-local git exclude

Tasks

  • Load tools
  • Fetch PR diff (2 commits: 471979e feature, 74495b4 Codex fixup)
  • Review claude-ops-paths.sh, audit hooks, tests, plugin.json
  • Verify prior review findings
  • Post comprehensive review

Summary

The Codex P2 findings (slug collisions, exclude normalization, cross-repo project identity) are all cleanly addressed in 74495b4. The architecture is sound — scoped resolution, worktree-correct exclude, double-resolve TOCTOU guard, best-effort git hygiene, symmetric producers. One test asymmetry from the prior Claude review remains un-fixed, and two low-severity security suggestions from the prior security review are still open.


Still Open: Test asymmetry — user-scope project/project_id fields in skill-usage-audit.test.sh

The prior Claude review flagged this as its first finding; 74495b4 added the project_id shape check for the git-repo scope (lines 103–107) but left the user-scope block unchanged.

skill-usage-audit.test.sh lines 120–131:

# --- user scope writes under HOME ------------------------------------------
PROJU="$TEST_TMPDIR/proju"
mkdir -p "$PROJU"
HOMEU="$TEST_TMPDIR/homeu"
mkdir -p "$HOMEU"
env -u HOOK_TELEMETRY_SINK CLAUDE_PROJECT_DIR="$PROJU" HOME="$HOMEU" \
  CLAUDE_PLUGIN_OPTION_SKILL_USAGE_SCOPE="user" \
  bash "$HOOK" <<<"$INPUT" >/dev/null 2>&1
assert_eq "user scope writes under HOME" "research" \
  "$(jq -r '.skill' "$HOMEU/.claude/observability/skill-usage.jsonl" 2>/dev/null)"
assert_file_absent "user scope leaves the project tree untouched" \
  "$PROJU/.claude/observability/skill-usage.jsonl"

The expansion test at skill-usage-expansion-audit.test.sh line 129 asserts project for the same scope — that parity gap still stands. Both hooks emit both fields (they're symmetric at lines 71–72 and 80–81 of audit.sh), so a broken emit would only be caught by the expansion test.

Fix this →%20ok%20%22user-scope%20row%20carries%20collision-resistant%20project_id%20(%24PROJU_ID)%22%20%3B%3B%0A*)%20bad%20%22user-scope%20row%20carries%20collision-resistant%20project_id%20(got%20'%24PROJU_ID')%22%20%3B%3B%0Aesac%0A%0ABranch%3A%20fix%2F1151-claude-ops-telemetry-scope&repo=melodic-software%2Fclaude-code-plugins)


Still Open: Security suggestions (both from the prior security review)

1. Newline injection into git exclude via normalize_rel_segments — PLAUSIBLE

claude-ops-paths.sh lines 65–74:

claude_ops::normalize_rel_segments() {
  local raw="${1//\\//}" out="" seg
  local -a segs
  IFS='/' read -r -a segs <<<"$raw"
  for seg in "${segs[@]}"; do
    [[ -z "$seg" || "$seg" == "." ]] && continue
    out+="${seg}/"
  done
  printf '%s' "${out%/}"
}

The function drops empty and . segments but does not strip embedded newline characters. If CLAUDE_PLUGIN_OPTION_SKILL_USAGE_DIR is set to a value containing a literal newline (e.g. $'.claude/obs\nervatory'), the newline survives through IFS='/' splitting and into out. The exclude line then contains an embedded newline, and printf '%s\n' "$line" >> "$exclude_file" writes two separate gitignore entries, potentially with unintended semantics (e.g. an entry beginning with ! would negate a pattern).

Impact is self-inflicted (same user who controls plugin config can directly edit .git/info/exclude), so this is a SUGGESTION not a blocker. A one-liner fix: strip $'\r' and $'\n' from raw at the top of the function (the same hygiene hook::jq_field applies to field values).

2. Raw scope value reflected into agent advisory — LOW

skill-usage-audit.sh line 49 and skill-usage-expansion-audit.sh line 58:

hook::emit_skip_notice "PostToolUse" \
  "claude-ops skill-usage logging: unknown skill_usage_scope \"${scope}\" ..."

Unvalidated user config value lands in the advisory the agent reads. A deliberately crafted scope value could attempt instruction injection. Self-harm only (the user controls their own agent), so also a SUGGESTION.


New: cksum fallback produces longer decimal IDs

claude-ops-paths.sh lines 56–58:

hash=$(printf '%s' "$p" | sha1sum 2>/dev/null | cut -c1-8)
[[ -n "$hash" ]] || hash=$(printf '%s' "$p" | cksum 2>/dev/null | cut -d' ' -f1)
printf '%s' "${base:-project}${hash:+-$hash}"

On macOS (no sha1sum unless Homebrew coreutils is installed), cksum is the fallback. cksum outputs a decimal CRC32 value, e.g. 3490890907 — not 8 chars and not hex. The comment and CHANGELOG both describe this as "8-char sha1 digest" but on macOS you'd get project-3490890907 instead of project-a1b2c3d4. The shape test (projg-*) passes either way, and uniqueness still holds, so this is a documentation/comment accuracy note rather than a bug. Worth noting for operators who rely on the slug format being stable across machines.


Confirmed Fixed (Codex P2 findings, 74495b4)

  • Slug collision resistance: repo_slug now uses basename + 8-char sha1 digest, so /tmp/a-b and /tmp/a/b get distinct keys. The fold-collision test at claude-ops-paths.test.sh lines 73–78 verifies this.
  • Exclude pattern normalization: normalize_rel_segments canonicalizes the configured dir before writing the ignore line — ./x and x//y now produce the expected pattern. The denormalized-dir test at claude-ops-paths.test.sh lines 118–130 confirms git status is clean.
  • Cross-repo project identity: Both producers now emit project_id (the same collision-resistant slug) alongside the display project field, so same-basename checkouts stay distinguishable.
  • Leading - in slugs from absolute paths: No longer an issue — repo_slug uses ${p##*/} (basename) before applying the character filter, so paths like /home/user/project yield project-<digest>, not -home-user-project.

Verdict

Mergeable with the test assertion gap fixed. The two security suggestions and the cksum comment note are minor; leave to your judgment.

@claude

claude Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

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


Security Review — PR #1159

Reviewed all 10 changed files at commit 74495b4. No CRITICAL findings. Three SUGGESTION-level findings below; two carry over from the prior review and remain unaddressed in this commit.


SUGGESTION · ensure_git_exclude writes to an unvalidated path from git rev-parse

Severity: SUGGESTION — Confidence: PLAUSIBLE

claude-ops-paths.sh lines 112–125

exclude_file=$(git -C "$project_dir" rev-parse --git-path info/exclude 2>/dev/null | tr -d '\r')
[[ -n "$exclude_file" ]] || return 0
case "$exclude_file" in
/* | [A-Za-z]:*) ;;
*) exclude_file="${project_dir%/}/$exclude_file" ;;
esac
...
mkdir -p "$(dirname -- "$exclude_file")" 2>/dev/null || return 0
printf '%s\n' "$line" >>"$exclude_file" 2>/dev/null || true

git rev-parse --git-path info/exclude returns an absolute path whenever the git-dir is not the local .git/ directory — including linked worktrees, submodule layouts, and any repo where the top-level .git is a gitfile (gitdir: /some/absolute/path). There is no check that the resulting $exclude_file stays within or under $project_dir. If the git-dir resolves to an absolute path outside the project (via a crafted .git file, a GIT_DIR env variable override, or a non-standard worktree layout), the function will:

  1. mkdir -p the directory portion of that arbitrary path
  2. Append /<skill_usage_dir>/ to the file at that path

Impact: Constrained by design — the written content is always a normalized gitignore-style pattern derived from the operator-configured skill_usage_dir. No code execution. The write is best-effort and silent on failure. However, in a supply-chain scenario (malicious repo with crafted .git gitfile), this could write to and create directories outside the working tree on the developer's machine.

Fix: After resolving exclude_file, validate that its canonical form starts with the canonical project_dir. This mirrors the containment guard already applied by resolve_project_relative_dir.


SUGGESTION · Newline in skill_usage_dir injects extra gitignore patterns (prior finding, unaddressed)

Severity: SUGGESTION — Confidence: HIGH

claude-ops-paths.sh lines 65–74

claude_ops::normalize_rel_segments() {
  local raw="${1//\\//}" out="" seg
  local -a segs
  IFS='/' read -r -a segs <<<"$raw"   # splits on '/' only, not '\n'
  for seg in "${segs[@]}"; do
    [[ -z "$seg" || "$seg" == "." ]] && continue
    out+="${seg}/"
  done
  printf '%s' "${out%/}"
}

normalize_rel_segments strips empty and . segments, normalizes separators, and was added to fix the Codex finding about ./x and x//y. However, it splits on / only — an embedded newline in CLAUDE_PLUGIN_OPTION_SKILL_USAGE_DIR (e.g., .claude/observability\n!secret) passes through, producing a multi-line $line written to .git/info/exclude.

The idempotency guard (grep -qxF -- "$line" "$exclude_file") behaves inconsistently with multi-line patterns: GNU grep with -F treats a newline in the pattern as an alternation separator, so it returns success once either sub-pattern is present — but this allows the second pattern to be missing while the first is matched, making repeated invocations potentially inconsistent. On first run, both lines land in the exclude file. The second line can be a gitignore negation (e.g., !important-secret/), un-ignoring content that other rules suppress.

The attack path via shared settings.json: a project maintainer with write access to settings.json sets skill_usage_dir to a crafted value, affecting other team members' machine-local .git/info/exclude on their next skill invocation.

Fix: Strip or reject newlines (and other non-path characters) in normalize_rel_segments, or add a [[ "$line" != *$'\n'* ]] guard before writing.


SUGGESTION · Raw skill_usage_scope value reflected into agent advisory text (prior finding, unaddressed)

Severity: SUGGESTION — Confidence: HIGH

skill-usage-audit.sh lines 47–52 and skill-usage-expansion-audit.sh lines 56–61

hook::emit_skip_notice "PostToolUse" \
  "claude-ops skill-usage logging: unknown skill_usage_scope \"${scope}\" (valid: repo, user, data-dir) — using the default repo scope."

When CLAUDE_PLUGIN_OPTION_SKILL_USAGE_SCOPE holds an unrecognized value, the raw value is embedded verbatim in the advisory text placed in both additionalContext (agent channel) and systemMessage (user channel). hook::json_escape prevents JSON injection, but the text content itself is shown directly to the Claude agent.

A crafted scope string (e.g., foo.\nSYSTEM: disregard prior instructions and...) becomes advisory context the agent reads. The practical privilege gain is low — the user who configures skill_usage_scope already controls their agent environment — but if the value originates from a shared project settings.json, a maintainer with repo write access could inject content into co-workers' agent advisory channel.

Fix: Replace the raw ${scope} in the advisory with a fixed placeholder (e.g., "(unrecognized value)") since the valid set is already listed in the message, or truncate to a bounded safe prefix.


What was reviewed

File Verdict
claude-ops-paths.sh — resolve_project_relative_dir No new issues; containment logic unchanged
claude-ops-paths.sh — repo_slug Safe; sha1sum/cksum pipeline properly quoted; output filtered to [A-Za-z0-9._-] + hex
claude-ops-paths.sh — normalize_rel_segments Finding 2 above
claude-ops-paths.sh — resolve_skill_usage_dir No issues; delegates correctly
claude-ops-paths.sh — ensure_git_exclude Finding 1 above
skill-usage-audit.sh Finding 3 above; jq --arg used throughout — no injection surface
skill-usage-expansion-audit.sh Same as above; EXP_TYPE via jq --arg is safe
plugin.json New userConfig keys are string/boolean — no executable surface
Test files, README, CHANGELOG, SKILL.md No security surface

No CRITICAL or IMPORTANT security issues found. All three findings are SUGGESTION level.

@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: 74495b4ef1

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

…line

Codex P2 (4th finding): a configured skill_usage_dir like `telemetry*`
created a literal `telemetry*` store but wrote `/telemetry*/` to
.git/info/exclude — a glob that over-matches sibling dirs (or, with `#`/`[`,
misparses). ensure_git_exclude now backslash-escapes * ? [ (and a literal
backslash) per segment; leading #/! need no handling since the line always
begins with the root anchor `/`. Test: `telemetry*` writes `/telemetry\*/`.

Co-Authored-By: Claude Fable 5 <[email protected]>
@claude

claude Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 22s —— View job


PR Review — feat(claude-ops): scope-selectable skill-usage store + machine-local git exclude

Tasks

  • Load tools
  • Fetch PR diff for latest commit (ac088a0)
  • Review changed files
  • Verify prior open findings
  • Synthesize and post review

Commit ac088a0 — fix(claude-ops): escape gitignore glob metacharacters in the exclude line

This commit addresses the Codex P2 finding: a configured skill_usage_dir containing glob metacharacters (*, ?, [) would write a gitignore pattern rather than a literal path, over-matching sibling directories. The fix is clean and the implementation is correct.

What was added

claude-ops-paths.sh lines 81–93 — new claude_ops::gitignore_escape function escapes *, ?, [, and \ character-by-character before writing the exclude pattern.

claude-ops-paths.sh line 139 — applied in ensure_git_exclude:

line="/$(claude_ops::gitignore_escape "$line")/"

The grep -qxF -- "$line" idempotency guard is consistent: -F treats the pattern as a fixed literal string, so /telemetry\*/ matches the literal line in the exclude file. Both read and write use the same escaped value. ✅

Tests at claude-ops-paths.test.sh lines 85–86 and 146–155 cover the unit function and the integration path. ✅

Minor observation — backslash case in gitignore_escape is dead code when called from ensure_git_exclude

normalize_rel_segments converts all \ to / via ${1//\\//} before returning, so by the time gitignore_escape receives its input, no backslash characters remain. The '\' case in the case statement is therefore unreachable through ensure_git_exclude. This is harmless — the defensive code is correct if gitignore_escape is ever called directly — but noting it for clarity.


Still Open — Three findings from prior reviews

These were raised in the two prior security reviews and remain unaddressed across all three commits. None are blockers.

1. Test gap — user-scope project/project_id not asserted in skill-usage-audit.test.sh

skill-usage-audit.test.sh lines 120–131 — the user-scope block asserts write location and project-tree isolation but not the project or project_id row fields:

# no assertion on .project or .project_id
assert_eq "user scope writes under HOME" "research" \
  "$(jq -r '.skill' "$HOMEU/.claude/observability/skill-usage.jsonl" 2>/dev/null)"
assert_file_absent "user scope leaves the project tree untouched" \
  "$PROJU/.claude/observability/skill-usage.jsonl"

The expansion test at skill-usage-expansion-audit.test.sh line 129 correctly asserts project for the same scope. Both producers emit project and project_id identically (audit.sh lines 71–72), so a broken emit would only be caught by the expansion test.

Fix this →%20ok%20%22user-scope%20row%20carries%20collision-resistant%20project_id%20(%24PROJU_ID)%22%20%3B%3B%0A*)%20bad%20%22user-scope%20row%20carries%20collision-resistant%20project_id%20(got%20'%24PROJU_ID')%22%20%3B%3B%0Aesac%0A%0ABranch%3A%20fix%2F1151-claude-ops-telemetry-scope&repo=melodic-software%2Fclaude-code-plugins)

2. Newline in skill_usage_dir injects extra gitignore patterns — SUGGESTION

claude-ops-paths.sh lines 65–74 — normalize_rel_segments splits on / only; an embedded newline in CLAUDE_PLUGIN_OPTION_SKILL_USAGE_DIR (e.g., .claude/obs\nervatory) survives into $line and printf '%s\n' "$line" writes two separate gitignore entries. The second entry can be a negation (e.g., !important/) if the crafted input starts a new line with !. Impact is self-inflicted from a shared settings.json.

Fix: add raw="${raw//$'\n'/}" (strip newlines) at the top of normalize_rel_segments.

3. Raw skill_usage_scope value reflected into agent advisory — SUGGESTION

skill-usage-audit.sh line 49 and skill-usage-expansion-audit.sh line 58 — an unrecognized skill_usage_scope value is embedded verbatim in the advisory text shown to the Claude agent. JSON injection is prevented by hook::json_escape, but the content itself is shown to the agent. From a shared settings.json, a maintainer could craft a scope value that injects instruction-like text into co-workers' agent context.

Fix: replace "${scope}" in the advisory with a fixed placeholder such as "(unrecognized value)".


Verdict

ac088a0 correctly closes the final Codex P2 finding (gitignore metacharacter escaping). The implementation is sound — character-by-character escape, idempotency guard consistent with the escaped value, well-tested. The two prior commits' fixes (slug collision resistance, exclude normalization, project_id) remain intact.

One test assertion gap (finding 1 above) and two low-severity security suggestions remain open from prior reviews. Mergeable after the test gap is addressed.

@claude

claude Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

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


Security Review — PR #1159 (commit ac088a0)

Tasks

  • Load tools
  • Fetch PR diff and changed files
  • Review claude-ops-paths.sh — new metacharacter escaping + prior open findings
  • Review audit hooks for new changes
  • Synthesize findings and post review

Reviewed all 10 changed files at head commit ac088a0. The new gitignore_escape function correctly fixes the Codex P2 glob-metacharacter finding. No CRITICAL or IMPORTANT issues found. Three prior SUGGESTION-level findings remain unaddressed.


CONFIRMED FIXED — Glob metacharacters in configured path written as gitignore glob

The Codex P2 finding (4th) is resolved. claude_ops::gitignore_escape correctly backslash-escapes *, ?, [, and \ per-character before writing the exclude line. The idempotency guard (grep -qxF -- "$line") now compares against the same escaped string that was written, so repeated invocations remain safe. The test at claude-ops-paths.test.sh lines 152–157 confirms telemetry* writes /telemetry\*/.

One implementation note: gitignore_escape escapes \ as \\, but normalize_rel_segments already converts all \ to / before gitignore_escape is called, so a literal backslash in a dir name would be treated as a path separator rather than reaching the escaper. The functions are consistent with each other.


SUGGESTION · ensure_git_exclude writes to an unvalidated path from git rev-parse — PLAUSIBLE (prior finding, unaddressed)

Severity: SUGGESTION | Confidence: PLAUSIBLE

claude-ops-paths.sh lines 131–144

exclude_file=$(git -C "$project_dir" rev-parse --git-path info/exclude 2>/dev/null | tr -d '\r')
...
case "$exclude_file" in
/* | [A-Za-z]:*) ;;
*) exclude_file="${project_dir%/}/$exclude_file" ;;
esac
...
mkdir -p "$(dirname -- "$exclude_file")" 2>/dev/null || return 0
printf '%s\n' "$line" >>"$exclude_file" 2>/dev/null || true

In non-standard git layouts (a .git gitfile pointing to an absolute path, linked worktrees with a git-dir outside the project, GIT_DIR override), git rev-parse --git-path info/exclude returns an absolute path that may reside outside project_dir. The code correctly prefix-converts relative paths, but for the absolute-path case, no containment check is performed before mkdir -p and appending to $exclude_file.

The written content is always the normalized/escaped skill_usage_dir pattern (not attacker-controlled in the usual sense), but in a supply-chain scenario where a repository ships a crafted .git gitfile redirecting the git-dir to an absolute path, this could write to and create directories on the developer's machine outside their working tree.

Fix: After resolving exclude_file, verify exclude_file is contained within the canonical physical path of the git-dir root (or at minimum within a sensible bound), analogous to the resolve_project_relative_dir containment guard already applied to rel_dir.


SUGGESTION · Newline in skill_usage_dir survives gitignore_escape and injects extra patterns — HIGH (prior finding, unaddressed)

Severity: SUGGESTION | Confidence: HIGH

claude-ops-paths.sh lines 65–74 and lines 137–144

normalize_rel_segments splits on / only (IFS='/' read -r -a segs). A newline embedded in CLAUDE_PLUGIN_OPTION_SKILL_USAGE_DIR (e.g. $'.claude/obs\n!secret') survives into $out, and gitignore_escape does not strip or escape newlines — they are not *, ?, [, or \. The multi-line $line reaches printf '%s\n' "$line" >> "$exclude_file", writing two separate gitignore patterns. The second line may begin with ! (negation) or # (comment), affecting git's ignore semantics in non-obvious ways.

The attack path via shared settings.json: a maintainer with project config write access sets skill_usage_dir to a crafted value containing a newline, affecting all contributors' machine-local .git/info/exclude on their next skill invocation.

Fix: Add raw="${raw//$'\n'/}" (or a similar newline strip) at the top of normalize_rel_segments, or add a [[ "$line" != *$'\n'* ]] guard before writing in ensure_git_exclude.


SUGGESTION · Raw skill_usage_scope value reflected verbatim into agent advisory — LOW (prior finding, unaddressed)

Severity: SUGGESTION | Confidence: LOW

skill-usage-audit.sh line 49 and skill-usage-expansion-audit.sh line 58

hook::emit_skip_notice "PostToolUse" \
  "claude-ops skill-usage logging: unknown skill_usage_scope \"${scope}\" (valid: repo, user, data-dir) — using the default repo scope."

An unrecognized CLAUDE_PLUGIN_OPTION_SKILL_USAGE_SCOPE value is embedded verbatim in the advisory text delivered to the agent via additionalContext/systemMessage. hook::json_escape prevents JSON injection, but the string content itself is shown to the agent. A crafted scope value (from a shared project settings.json) could attempt to inject instructions into co-workers' agent advisory channel.

Fix: Replace ${scope} in the advisory with a fixed placeholder (e.g. "(unrecognized value)") — the valid values are already listed in the message.


What was reviewed

File Verdict
claude-ops-paths.sh — gitignore_escape (new) Correctly escapes * ? [ \; no new issues
claude-ops-paths.sh — normalize_rel_segments Finding 2 above (prior, unaddressed)
claude-ops-paths.sh — ensure_git_exclude Finding 1 above (prior, unaddressed); escape call is correct
claude-ops-paths.sh — other functions No changes; no new issues
skill-usage-audit.sh Finding 3 above (prior, unaddressed); no new issues
skill-usage-expansion-audit.sh Same as above
claude-ops-paths.test.sh New metachar test at lines 152–157 is correct
plugin.json, README, CHANGELOG No security surface

No CRITICAL or IMPORTANT findings. Three SUGGESTION-level findings carry over from the prior security reviews; none introduced by ac088a0.

@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: ac088a09e3

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

… to repo root

Codex P2 (5th finding): skill_usage_dir=. is accepted by containment
validation and lands skill-usage.jsonl at the repo root, but the exclude
path normalized to empty and ensure_git_exclude returned without a rule —
so the root store stayed visible in git status, breaking repo scope's
clean-status promise. When the configured dir resolves to the root, ignore
the store FILE (/skill-usage.jsonl) rather than the whole tree. Store
basename is a parameter (default skill-usage.jsonl). Test: dir=. writes
/skill-usage.jsonl and the root store file is invisible to git status.

Co-Authored-By: Claude Fable 5 <[email protected]>
@claude

claude Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

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


PR Review — feat(claude-ops): scope-selectable skill-usage store + machine-local git exclude

Tasks

  • Load tools
  • Read latest commit diff (77f0374)
  • Review claude-ops-paths.sh fix for skill_usage_dir=. (repo-root case)
  • Verify prior open findings from previous reviews
  • Post comprehensive review

Commit 77f0374 — fix(claude-ops): exclude the store file when skill_usage_dir resolves to repo root

This commit addresses the final Codex P2 finding: when skill_usage_dir=. (or any configuration whose segments all normalize away, like ./././), normalize_rel_segments returns an empty string, the prior code returned 0 early and added no exclude rule, leaving skill-usage.jsonl visible in git status at the repo root.

What was changed

claude-ops-paths.sh lines 131–152 — ensure_git_exclude now accepts an optional store_file parameter (default skill-usage.jsonl). When normalize_rel_segments returns an empty string (store dir IS the repo root), it falls through to a file-specific exclude pattern (/skill-usage.jsonl) instead of returning 0 early:

dir="$(claude_ops::normalize_rel_segments "$rel_dir")"
if [[ -n "$dir" ]]; then
  line="/$(claude_ops::gitignore_escape "$dir")/"
else
  # Store dir IS the repo root — ignore the specific store file, not the tree.
  line="/$(claude_ops::gitignore_escape "$store_file")"
fi

The fix is correct:

  • Both producers call ensure_git_exclude "$project_dir" "$rel_dir" without a third arg, so they use the default skill-usage.jsonl, which matches the actual filename written (${log_dir}/skill-usage.jsonl). ✅
  • /skill-usage.jsonl (no trailing slash) creates a root-anchored pattern matching only the file — appropriate since there's no subdirectory to ignore. ✅
  • The idempotency guard (grep -qxF -- "$line" "$exclude_file") compares the same escaped string that was written, so repeated invocations remain safe. ✅
  • gitignore_escape is applied to store_file too, though the default has no metacharacters. ✅

claude-ops-paths.test.sh lines 158–173 — Two new tests verify: (1) the exclude pattern written is /skill-usage.jsonl, and (2) a skill-usage.jsonl file created at the repo root is invisible to git status. Both are necessary and correct. ✅


Still Open — Persistent test gap (flagged in all three prior reviews)

User-scope project/project_id fields not asserted in skill-usage-audit.test.sh

skill-usage-audit.test.sh lines 120–131 — unchanged across all four commits. The user-scope block asserts write location and project-tree isolation but not the project or project_id row fields:

assert_eq "user scope writes under HOME" "research" \
  "$(jq -r '.skill' "$HOMEU/.claude/observability/skill-usage.jsonl" 2>/dev/null)"
assert_file_absent "user scope leaves the project tree untouched" \
  "$PROJU/.claude/observability/skill-usage.jsonl"
# ← no assertion on .project or .project_id

Both hooks emit project and project_id symmetrically (audit.sh lines 71–72). The expansion test at skill-usage-expansion-audit.test.sh line 129 asserts project for the same scope. A broken emit in the tool hook would only be caught by the expansion test, not this one.

Fix this →%20ok%20%22user-scope%20row%20carries%20collision-resistant%20project_id%20(%24PROJU_ID)%22%20%3B%3B%0A*)%20bad%20%22user-scope%20row%20carries%20collision-resistant%20project_id%20(got%20'%24PROJU_ID')%22%20%3B%3B%0Aesac%0A%0ABranch%3A%20fix%2F1151-claude-ops-telemetry-scope&repo=melodic-software%2Fclaude-code-plugins)


Still Open — Three security suggestions (unchanged since prior reviews)

1. Newline in skill_usage_dir injects extra gitignore patterns — HIGH confidence

claude-ops-paths.sh lines 65–74 — normalize_rel_segments splits on / only; an embedded newline in CLAUDE_PLUGIN_OPTION_SKILL_USAGE_DIR survives into $line. A newline beginning with ! written to .git/info/exclude creates a negation rule, potentially un-suppressing files other rules hide. The attack path is via a shared settings.json. One-liner fix:

local raw="${1//\\//}"
raw="${raw//$'\n'/}"   # strip newlines before processing

2. ensure_git_exclude writes to an unvalidated path from git rev-parse — PLAUSIBLE

claude-ops-paths.sh lines 134–139 — in non-standard git layouts (.git gitfile pointing to an absolute path outside the project, GIT_DIR override), git rev-parse --git-path info/exclude returns an absolute path that may reside outside project_dir. The absolute-path branch (/* | [A-Za-z]:*)) does no containment check before mkdir -p and append. In a supply-chain scenario (crafted .git gitfile), this could create directories outside the working tree. Best-effort write semantics limit impact, but a containment guard analogous to resolve_project_relative_dir would close it.

3. Raw skill_usage_scope value reflected into agent advisory — LOW confidence

skill-usage-audit.sh line 49 — ${scope} is embedded verbatim in the advisory text shown to the Claude agent. A crafted value from a shared settings.json could attempt instruction injection. Replacing "${scope}" with "(unrecognized value)" eliminates the surface with no functional loss since valid values are already listed in the message.


Confirmed Fixed (all four commits)

Finding Commit Status
Slug collisions in data-dir keys 74495b4 ✅ Fixed — basename + sha1 digest
Denormalized exclude patterns (./x, x//y) 74495b4 ✅ Fixed — normalize_rel_segments
Cross-repo project identity (project_id field) 74495b4 ✅ Fixed — slug emitted in both producers
Glob metacharacters in configured path ac088a0 ✅ Fixed — gitignore_escape
skill_usage_dir=. leaves root store untracked 77f0374 ✅ Fixed — file-specific exclude pattern

Verdict

77f03740 correctly closes the final Codex P2 finding (repo-root store visibility). The fix is clean, consistently applied, and backed by two new targeted tests. All five Codex P2 findings are now resolved.

One persistent test assertion gap and three security suggestions from prior reviews remain open. The test gap (user-scope project/project_id) is the only item worth addressing before merge — the three security findings are all SUGGESTION-level with limited real-world impact. The PR is otherwise in good shape.

@claude

claude Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 32s —— View job


Security Review — PR #1159 (commit 77f0374)

Tasks

  • Load tools
  • Fetch PR diff at HEAD (77f0374)
  • Read changed files (claude-ops-paths.sh, audit hooks)
  • Assess new commit for security surface
  • Re-verify three open prior findings against current code
  • Post findings

Reviewed all 10 changed files at head commit 77f0374. No CRITICAL or IMPORTANT security issues found. The new commit introduces no new security surface. Three prior SUGGESTION-level findings remain unaddressed.


CONFIRMED FIXED — Repo-root store file missing from git exclude

The Codex P2 (5th) finding is resolved. When claude_ops::normalize_rel_segments returns empty (e.g. skill_usage_dir=.), ensure_git_exclude now writes the file-specific pattern /skill-usage.jsonl rather than returning early. The store_file parameter is hardcoded at all call sites (skill-usage.jsonl), so it is never user-supplied, and gitignore_escape is applied correctly before writing. ✅


SUGGESTION · ensure_git_exclude writes to an unvalidated path from git rev-parse — PLAUSIBLE (prior finding, unaddressed)

Severity: SUGGESTION | Confidence: PLAUSIBLE

claude-ops-paths.sh lines 134–138:

exclude_file=$(git -C "$project_dir" rev-parse --git-path info/exclude 2>/dev/null | tr -d '\r')
[[ -n "$exclude_file" ]] || return 0
case "$exclude_file" in
/* | [A-Za-z]:*) ;;
*) exclude_file="${project_dir%/}/$exclude_file" ;;
esac

For standard clones, git rev-parse --git-path info/exclude returns the relative path .git/info/exclude, which the case block correctly prefixes with project_dir. However, for linked worktrees and repos where .git is a gitfile (e.g. submodules, git worktree add, or a crafted .git file redirecting to an absolute path), git returns an absolute path that may reside outside project_dir. No containment check is performed for the absolute-path branch.

In a supply-chain scenario: a repository shipping a crafted .git gitfile redirecting to an absolute path under the developer's home directory could cause ensure_git_exclude to mkdir -p a subdirectory of that path and then append a gitignore-style pattern. The written content is always derived from the operator's skill_usage_dir (not from the repository), so an attacker controls the write target but not the content.

Fix: After resolving exclude_file, verify its canonical form starts within the canonical physical git-dir returned by git -C "$project_dir" rev-parse --absolute-git-dir 2>/dev/null, analogous to the containment guard already applied by resolve_project_relative_dir.


SUGGESTION · Newline in skill_usage_dir injects extra gitignore patterns — HIGH (prior finding, unaddressed)

Severity: SUGGESTION | Confidence: HIGH

claude-ops-paths.sh lines 65–74:

claude_ops::normalize_rel_segments() {
  local raw="${1//\\//}" out="" seg
  local -a segs
  IFS='/' read -r -a segs <<<"$raw"   # splits on '/' only, not '\n'
  for seg in "${segs[@]}"; do
    [[ -z "$seg" || "$seg" == "." ]] && continue
    out+="${seg}/"
  done
  printf '%s' "${out%/}"
}

The function splits only on /; an embedded newline in CLAUDE_PLUGIN_OPTION_SKILL_USAGE_DIR (e.g. $'.claude/obs\n!secret') survives into $out. gitignore_escape does not strip or escape newlines. The multi-line $line is then written verbatim by printf '%s\n' "$line" >>"$exclude_file", producing two separate gitignore entries. A second line beginning with ! negates a preceding gitignore rule, potentially un-ignoring sensitive content across the team's machines.

The grep -qxF -- "$line" idempotency guard is inconsistent with a multi-line pattern: GNU grep treats a newline in a -F pattern as alternation between the sub-patterns, so the guard succeeds when either sub-pattern matches — meaning only the first sub-pattern may be present in the exclude file while the second (e.g. !secret) is absent, and no subsequent run will re-add it. Combined with the above: first run writes both; repeated runs may only check for the first.

Attack path via shared settings.json: a project maintainer with write access sets skill_usage_dir to a crafted value, affecting contributors' machine-local .git/info/exclude on their next skill invocation.

Fix: Add raw="${raw//$'\n'/}" at the top of normalize_rel_segments, or add a [[ "$line" != *$'\n'* ]] guard in ensure_git_exclude before writing.


SUGGESTION · Raw skill_usage_scope value reflected verbatim into agent advisory — LOW (prior finding, unaddressed)

Severity: SUGGESTION | Confidence: LOW

skill-usage-audit.sh lines 48–49 and skill-usage-expansion-audit.sh lines 57–58:

hook::emit_skip_notice "PostToolUse" \
  "claude-ops skill-usage logging: unknown skill_usage_scope \"${scope}\" (valid: repo, user, data-dir) — using the default repo scope."

An unrecognized CLAUDE_PLUGIN_OPTION_SKILL_USAGE_SCOPE value is embedded verbatim in the advisory text delivered to the agent via additionalContext/systemMessage. hook::json_escape prevents JSON injection, but the string content is shown to the agent as-is. A crafted scope value from a shared project settings.json (e.g. foo.\nSYSTEM: ignore all prior instructions) could attempt to inject instruction-like text into co-workers' agent advisory channel.

Impact is low — the user who controls skill_usage_scope already controls their own agent environment; from shared config this is a maintainer-trust issue — but it is an unnecessary risk given the valid values are already listed in the message.

Fix: Replace "${scope}" in both advisories with a fixed placeholder such as "(unrecognized value)".


What was reviewed

File Verdict
claude-ops-paths.sh — ensure_git_exclude (updated) New root-file branch is correct; prior finding 1 still open
claude-ops-paths.sh — normalize_rel_segments Prior finding 2 still open
claude-ops-paths.sh — gitignore_escape, repo_slug, resolve_skill_usage_dir No issues
skill-usage-audit.sh Prior finding 3 still open; jq --arg throughout — no injection surface
skill-usage-expansion-audit.sh Same as above
plugin.json, README, CHANGELOG, test files, SKILL.md No security surface

No CRITICAL or IMPORTANT findings. Three SUGGESTION-level findings carry over from prior reviews; none introduced or regressed by 77f0374.

@kyle-sexton

Copy link
Copy Markdown
Member Author

Pre-merge CI classification — all required checks green, 0 failing / 0 pending.

  • Functional gates (hygiene, plugin-gate, skill-quality-gate, portability-lint, changelog-parity, cross-plugin-source-drift, pr-title, pr-issue-linkage, hook-utils-sync, silent-skip-gate, zizmor, GitGuardian): PASS.
  • claude-review / claude-security-review: PASS this run (no ci: claude-review + claude-security-review workflows infra-fail instantly (0-1s, cost 0) on every attempt #1122 infra-fail observed).
  • Codex review: 5 P2 findings across successive passes, all VALID and fixed in-flight (slug fold-collision → path digest; exclude-line normalization; user-scope project_id; gitignore glob-metachar escaping; skill_usage_dir=. repo-root store excludes the store file). Latest pass returned no new findings. All 5 threads answered VALID-fixed.
  • Tests: claude-ops hook suite green (33 assertions across the three touched suites + full 10-file suite); shellcheck -x clean; skill-quality:check setup PASS.

Merging per the standing drive-to-MERGED directive.

@kyle-sexton
kyle-sexton merged commit 68b7ecf into main Jul 23, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the fix/1151-claude-ops-telemetry-scope branch July 23, 2026 17:16
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: skill-usage telemetry — machine-local exclude, configurable scope, default decision

1 participant