Skip to content

chore(claude): review every AI commit for project names - #108

Merged
Astrasu merged 3 commits into
developfrom
chore/project-name-review
Oct 22, 2026
Merged

Astrasu merged 3 commits into
developfrom
chore/project-name-review

Conversation

@Astrasu

@Astrasu Astrasu commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Why

Internal project and product names reached this public repository -- in docs, specs, changelogs and commit messages -- because AI assistants carry the context a feature is built in into what they write. They have been removed from the history; this PR keeps new ones out.

There is deliberately no list of forbidden names: such a list in a public repository would publish exactly the names it is meant to keep out. Instead, the assistant reviews every commit itself and asks before using any name.

What

  • CLAUDE.md -- "Project names" rule. Describe where a change came from generically; before every commit, review the staged diff and the message for anything that could be a project, product, customer, team or internal-system name, and commit such a name only after an explicit yes from the user. IDAC is approved. The rule holds whether or not hooks run.
  • .claude/hooks/project-name-review.sh + .claude/settings.json -- a Claude Code PreToolUse hook on Bash. It holds every git commit (also git -C dir commit, git -c k=v commit, --amend; not commit-tree or git log --grep=commit) and tells the assistant what to check. The commit goes through once the command carries PROJECT_NAMES_REVIEWED=1. Plain sh, no dependencies.
  • .gitignore commits .claude/settings.json and .claude/hooks/; .claude/settings.local.json and everything else under .claude/ stays local.
  • .gitattributes keeps *.sh at LF, so the hook still runs on Windows checkouts with core.autocrlf.

Limits

The hook enforces that the review is acknowledged, not that it was done well: an assistant can set the prefix without looking. Humans committing by hand are not affected. Other assistants (Copilot, Codex, ...) only see the CLAUDE.md rule; the same rule goes into AGENTS.md once #96 has brought that file to develop.

Tested

  • The hook script against 16 command shapes (8 held, 8 passed through) -- all as expected.
  • Live in a Claude Code session: a commit without the prefix was held and the assistant got the instructions; after the review, the commit with the prefix went through. This PR's own commit was made that way.

Replaced history (second commit)

The rewrite gave every commit from 2026-08-24 on a new SHA. A branch that started on the old history still carries it -- and merging it would bring the names back. Every replaced commit descends from 1c2098c, so one ancestry check finds them all:

  • ci.yml -- job "No replaced history". Full-history checkout; fails when 1c2098c is reachable from HEAD, on every push and pull request. To make it a gate, an admin adds "No replaced history" as a required status check on develop and main. Pushing such a branch cannot be prevented on github.com (no pre-receive hooks), but merging it can.
  • .claude/hooks/replaced-history-guard.sh -- a second PreToolUse hook: refuses a git push of a branch that contains 1c2098c, before anything leaves the machine. It reads only each push's own arguments (named branches and refspec sources, --all/--mirror, otherwise the current branch), follows git -C <dir> and a leading cd <dir> -- but only into the project; a command naming any other directory is let through unchecked, because the hook runs before the user approves the command. All its git calls run with GIT_NO_LAZY_FETCH=1 and -c safe.bareRepository=explicit (security review finding, fixed in 2d72ecc). It lets --delete and tags-only pushes through.
  • CLAUDE.md -- "Replaced history": what happened, and the git rebase --onto recipe to move a branch's own commits onto the new history.

Security: a crafted partial clone outside the project, one inside and a bare one inside made the first version of the hook run an injected command; the fixed hook runs it in none of the three. Tested: the hook against 33 command shapes (single pushes, refspecs, --all/--mirror, -C/cd, chains with &&/;/|, multi-line commands), each with compact and spaced JSON -- 66 of 66 as expected; live in a Claude Code session, an old-history branch was refused and a clean one went through. The CI step's script, run locally: exit 1 on the old feature tip, exit 0 on the new develop and feature tip.

Review notes

  • Generated with an AI assistant: the hook scripts, the settings and the CI job need a human security review.
  • No new dependencies, no licence questions.

🤖 Generated with Claude Code

Project and product names reached this public repository through AI assistants, which carry the
context a feature is built in into comments, docs and commit messages. There is no list of
forbidden names: a list here would publish them. Instead the assistant reviews each commit and
asks before using a name.

- CLAUDE.md: a "Project names" rule -- generic wording while writing, a review of the staged diff
  and the message before every commit, an explicit yes for any name; IDAC is approved. It holds
  whether or not hooks run.
- .claude/hooks/project-name-review.sh, wired as a PreToolUse hook in .claude/settings.json:
  holds every `git commit` (also `git -C dir commit`, `--amend`; not `commit-tree`) until the
  command carries PROJECT_NAMES_REVIEWED=1, and tells the assistant what to check.
- .gitignore keeps .claude/settings.local.json local but commits the shared settings and hooks;
  .gitattributes keeps *.sh at LF so the hook runs on Windows checkouts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Astrasu
Astrasu requested a review from pajoma October 21, 2026 13:43

SawwR commented Oct 21, 2026

Copy link
Copy Markdown

⚠️ Version not bumped: pyproject.toml has version = "0.8.2" on this branch, the same as the target branch develop (0.8.2). Please bump the version (semver) before merging.


Generated by Claude Code

On 2026-10-21 the history from 2026-08-24 on was rewritten to remove internal project names.
A branch that started on the old history still contains it, and merging such a branch would bring
the names back. Every replaced commit descends from 1c2098c, so one ancestry check finds them all.

- ci.yml: job "No replaced history" -- full-history checkout, fails when 1c2098c is reachable
  from HEAD, for every push and pull request. Made a required status check on develop and main,
  it keeps such a branch from being merged.
- .claude/hooks/replaced-history-guard.sh (PreToolUse, Bash): refuses a `git push` of a branch
  that contains 1c2098c, before anything leaves the machine. It reads only each push's own
  arguments (named branches, refspec sources, --all/--mirror, else the current branch), follows
  `git -C dir` and a leading `cd dir`, and lets --delete and tags-only pushes through.
- CLAUDE.md: "Replaced history" -- what happened and how to move a branch's own commits onto the
  new history.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Astrasu

Astrasu commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the check. No version bump in this PR, on purpose: it changes nothing that ships in the package -- only .claude/ (hooks and their settings), the CI workflow, CLAUDE.md, .gitignore and .gitattributes. The wheel and sdist built from this branch are identical in content to develop's, so a new version number would announce a release without a change.

The next version is set by the release work on develop (#96 keeps 0.8.2 there deliberately and folds its changes into [Unreleased]); bumping here would collide with that.

🤖 Generated with Claude Code

@pajoma

pajoma commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

🤖 Automatically created security review (Claude Code, /security-review). This is a recommendation, not an approval. A human reviewer decides; this comment does not change the PR's review state.

Security review: PR #108 (chore(claude): review every AI commit for project names, head 229d843)

Verdict: no security blocker. I found no vulnerability at or above the confidence threshold (8/10). I recommend fixing the one low-severity item below before merge. The fix is small, and the hook runs on every Bash call of every contributor's assistant session. As the PR itself asks, a human should still look over the hook scripts and the CI job.

Scope

The review covered the 7 changed files:

  • .claude/hooks/project-name-review.sh
  • .claude/hooks/replaced-history-guard.sh
  • .claude/settings.json
  • .gitattributes
  • .gitignore
  • CLAUDE.md
  • .github/workflows/ci.yml

Below threshold (low severity, recommended fix)

Git can run code from a directory named in the Bash command, before the permission prompt. .claude/hooks/replaced-history-guard.sh:25-30, confidence 6/10.

  • What the hook does: it takes the target directory from the proposed Bash command, either git -C <dir> or a leading cd <dir>. It then runs git -C "$dir" cat-file … in that directory. This happens before the permission prompt, and nothing limits the directory to the project.
  • How it can be exploited: an attacker needs two things.
    • A directory that git treats as a bare repository, with a crafted config (for example a promisor remote with uploadpack set). Git then runs the configured command during a lazy fetch.
    • A prompt injection that gets the assistant to propose any command containing the text git push together with cd/-C to that directory. A command that never runs git there, such as a grep, also qualifies.
  • Reproduced: with a marker file on Git 2.54.
  • Why it scored below threshold: the attack needs both conditions at once. A malicious fork branch gains nothing extra either, because it could simply edit the hook scripts directly.
  • Fix:
    • Take the repository from $CLAUDE_PROJECT_DIR or the hook's cwd field. Alternatively, accept only paths inside the project.
    • In both cases, run the hook's git calls with GIT_NO_LAZY_FETCH=1 git -c safe.bareRepository=explicit …. Each of these settings alone stopped the reproduction.

Checked and ruled out

  • project-name-review.sh: it only greps its input and never runs git or any part of the command. Getting past it with the prefix is intended, because it is a workflow guardrail, not a security boundary.
  • replaced-history-guard.sh, apart from the item above:
    • no eval, sh -c or sourcing
    • every expansion is quoted
    • branch tokens are limited to a strict character set and checked with show-ref --verify
  • CI job "No replaced history":
    • It runs on pull_request, not pull_request_target, so fork PRs get a read-only token and no secrets.
    • There is no ${{ github.* }} in run:, and the permissions block is unchanged.
  • .claude/settings.json: it only registers the two hooks; there are no permissions.allow rules.
  • .gitignore: only .claude/settings.json and .claude/hooks/ become trackable. settings.local.json, .credentials.json and the rest of .claude/ stay ignored (checked with git check-ignore).

…y fetches

The guard runs before the user approves the command, and took the directory for its git calls
from the command itself. A crafted repository there -- a partial clone whose promisor remote sets
uploadpack -- made `git cat-file -e` run a command through a lazy fetch, before any approval.
Reported in the security review of PR #108; reproduced with the hook of 229d843.

- Only the project ($CLAUDE_PROJECT_DIR) and directories inside it are checked; a command naming
  any other directory is let through unchecked, and CI still refuses an old branch.
- Every git call goes through g(): GIT_NO_LAZY_FETCH=1 and -c safe.bareRepository=explicit, so
  even a crafted repository inside the project runs nothing.
- JSON-escaped backslashes in a Windows path become slashes instead of being dropped.

Measured: a crafted partial clone outside the project, one inside, and a bare one inside -- the
hook of 229d843 ran the injected command in all three, this one in none. Regression: 33 command
shapes x 2 JSON styles, 66 of 66 as expected; live in a Claude Code session, an old branch in the
project was still refused.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Astrasu

Astrasu commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks -- confirmed and fixed in 2d72ecc.

Reproduced first, against the hook as of 229d843: a partial clone whose promisor remote sets uploadpack to an injected command, named via git -C <dir> push …. The hook's git cat-file -e triggered a lazy fetch and the command ran -- before any approval. Same result for such a repository inside the project and for a bare one.

Fix (.claude/hooks/replaced-history-guard.sh):

  • The hook only looks at the project ($CLAUDE_PROJECT_DIR) and directories inside it. A command that names any other directory is let through unchecked; CI ("No replaced history") still refuses an old branch there.
  • Every git call goes through one wrapper: GIT_NO_LAZY_FETCH=1 git -c safe.bareRepository=explicit -C "$dir" …, so even a crafted repository inside the project runs nothing.
  • JSON-escaped backslashes in Windows paths now become slashes instead of being dropped.

Measured after the fix:

Crafted repository hook 229d843 hook 2d72ecc
partial clone, outside the project command ran nothing ran
partial clone, inside the project command ran nothing ran
bare partial clone, inside the project command ran nothing ran

Regression: 33 command shapes × compact/spaced JSON, 66 of 66 as expected; live in a Claude Code session, an old-history branch in the project is still refused.

🤖 Generated with Claude Code

@pajoma

pajoma commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

🤖 Automatically created review report (Claude Code, lead PR review). This is a recommendation, not an approval. A human reviewer decides; this comment does not change the PR's review state.

PR Review: chore(claude): review every AI commit for project names (GitHub #108)

Recommendation: Approve with comments
Type: Fix / chore (target develop)
Change kind: Housekeeping (chore + CI)
Story: none linked
Reviewed head: 2d72ecc

Blocking issues

None.

Security finding from the earlier review: fixed, verified independently

The low-severity item from the security review (git run in a directory named by the command, before the permission prompt) is fixed in 2d72ecc. I reproduced it independently on Git 2.54 with a crafted partial clone whose promisor remote sets uploadpack to a marker command, and fed each hook the JSON for git -C <repo> push origin main:

Crafted repository hook 229d843 hook 2d72ecc
partial clone, outside the project command ran nothing ran
partial clone, inside the project command ran nothing ran
bare partial clone, inside the project command ran nothing ran

Functional check of the fixed hook in a scratch clone with a branch on 1c2098c and one on current develop, 6 of 6 as expected: refused push origin <old>, push origin +<old>:<other>, push --all, cd <repo> && push origin <old>; let through push origin <clean> and push origin --delete <old>.

The fix is sound: every git call goes through one wrapper with GIT_NO_LAZY_FETCH=1 and -c safe.bareRepository=explicit, the path check uses pwd -P on both sides (a symlink out of the project is resolved and let through unchecked), and all expansions stay quoted.

A · Traceability & B · Story

  • ⚠️ No issue linked (no Closes #…, none in branch or commits). In this repo feature and fix PRs usually close an issue; chores and releases often don't. The PR description states the motivation thoroughly, so I rate this a warning, not a blocker. Suggestion: open an issue for the follow-up admin work below and link it, so the history rewrite and its safeguards stay traceable.
  • PR → description: the diff does what the description says and nothing else. No package code changes; the built wheel and sdist are unaffected.
Claim in the PR Status Evidence
Hold every git commit until the review is acknowledged Covered .claude/hooks/project-name-review.sh, .claude/settings.json
"Project names" rule for all assistants Covered CLAUDE.md
Refuse pushes of the replaced history (client side) Covered, verified .claude/hooks/replaced-history-guard.sh; tests above
Refuse the replaced history in CI Covered, green on this PR .github/workflows/ci.yml, job "No replaced history"
CI job as a merge gate Not yet: needs an admin, see C/G repository settings
Hooks run on Windows checkouts Covered (not tested by me) .gitattributes

C · Code

No production code changed, so brooks-review was not run; I reviewed the two shell scripts, the settings and the CI job directly.

  • 🟡 The CI check is not a gate yet. All three branch rulesets on this repository (for main and develop) are currently not enforced, and neither branch has classic branch protection. So "No replaced history" cannot block a merge, and no review is required before merging. Remedy: an admin re-enables the rulesets and adds "No replaced history" as a required status check on develop and main (as the PR description already says). This does not block merging chore(claude): review every AI commit for project names #108, but the PR only reaches its goal once it is done.
  • 🟡 Hook regression tests are not in the repo. The 33 command shapes × 2 JSON layouts were run by hand. Remedy: commit them as a small script (e.g. tests/hooks/) and run it in CI, so a later change to the regexes cannot silently break the guard.
  • 🟢 Minimum Git version. GIT_NO_LAZY_FETCH needs Git ≥ 2.44, safe.bareRepository Git ≥ 2.38; older versions silently ignore the setting they do not know. The outside-the-project protection (path check) works regardless; the inside-the-project protection is weaker on older Git. Remedy: mention the minimum version in the script header or CLAUDE.md, or let the hook exit 0 on older Git.
  • 🟢 Repository selection. Without -C/cd, the hook checks $CLAUDE_PROJECT_DIR, not the shell's current directory (the hook input's cwd field). If the session has moved into another directory, the check targets the wrong repository. CI stays the backstop; a note in the header would do.
  • 🟢 Version bump: not needed. The target is develop, nothing that ships changes, and the release work on develop sets the next version. I agree with the author's reply.
  • Conventions: POSIX sh, no dependencies, comment density in line with the rest of the repo; both CI jobs green.

D · Documentation

CLAUDE.md: professional tone, consistent with the hooks and the CI job (dates, root commit, job name). The one approved name it lists is an explicit decision recorded in the file; a human reviewer should confirm it is meant to be public.

F · Liability

No findings. Diff and all three commits scanned for secrets, keys, tokens, connection strings, e-mail addresses and private IPs (manual pattern scan; gitleaks/trufflehog not installed): only the noreply@anthropic.com co-author trailers. No new dependencies, no licence questions. The PR discloses AI assistance and asks for a human security review, as required; the earlier security review plus this verification cover the hook scripts.

G · Repository hygiene (default branch develop, not blocking)

Item Status
README ✅ present
LICENSE ❌ no LICENSE file, although the repository is public
CODEOWNERS ❌ none; worth adding at least for .claude/ and .github/workflows/, since the hooks run in every contributor's assistant session
SECURITY.md ❌ none
CONTRIBUTING ⚠️ present as CONTRIBUTE.md (non-standard name, GitHub does not pick it up)
Secret scanning ⚠️ no scanner in CI; check GitHub secret scanning and push protection in the repository settings
SBOM ❌ no SBOM step found in the workflows
Dependency updates ❌ no Dependabot or Renovate config
SAST / dependency audit ⚠️ bandit in pre-commit only, not in CI
Branch protection ❌ rulesets for main and develop exist but are not enforced
CHANGELOG ✅ present

Not checked

  • Behaviour on Windows checkouts and on Git < 2.44 (only Git 2.54 on macOS tested).
  • The hooks inside a live Claude Code session (the author reports this; I tested the scripts directly with hook JSON).
  • project-name-review.sh command shapes beyond reading the regex (covered by the earlier security review).

@Astrasu
Astrasu merged commit 80e2e58 into develop Oct 22, 2026
4 checks passed
Astrasu added a commit that referenced this pull request Oct 22, 2026
Brings the project-name review hook, the replaced-history push guard and the CI job "No replaced history" onto the feature branch. CLAUDE.md: both sides appended sections; kept the branch's sections, then develop's.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

3 participants