Skip to content

fix(plugin): exclude nested Git metadata from scan inventories - #1099

Merged
mldangelo-oai merged 2 commits into
openai:mainfrom
Linxiushen:fix/scan-file-inventory-includes-nested-git-
Sep 30, 2026
Merged

mldangelo-oai merged 2 commits into
openai:mainfrom
Linxiushen:fix/scan-file-inventory-includes-nested-git-

Conversation

@Linxiushen

@Linxiushen Linxiushen commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Repository and directory scan inventories now exclude nested Git metadata and linked-worktree .git files while retaining the surrounding source files. Metadata no longer inflates the inventory or its coverage count.

Changes

  • Exclude .git entries at any depth in both shared inventory generation and scoped rank-input enumeration.
  • Also exclude their descendants when a directory scope starts inside .git; ripgrep otherwise bypasses the directory-name exclusion for an explicit search root.
  • Cover root and nested linked worktrees, six metadata-directory scopes, and MCP inventory preparation and reading with explicit expected paths and counts.
  • Verify that .gitignore, .github, and ordinary files ending in .git remain included.

Testing

  • Inventory and rank-input Python test modules: 142 passed.
  • Six directory-scope regression cases verified to fail without the descendant exclusion.
  • node --test plugins/codex-security/mcp-app/tests/test_artifact_inventory.mjs: passed.
  • Ruff 0.16.8 lint and format checks for the entire plugin: passed.
  • Prettier check for the changed MCP test: passed.
  • pnpm --config.verify-deps-before-run=false --dir sdk/typescript run build:ci: passed using the installed dependencies.
  • Plugin source compatibility check and all nine compatibility tests: passed.
  • git diff --check: passed.

Risk and rollout

The change is limited to directory enumeration. Git metadata is removed from nested-repository inventories and coverage counts; source files, ignore behavior, and explicit-file scope behavior are preserved. No public CLI, configuration, or artifact-format changes are required.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

The shared file inventory is built with `rg --files --hidden --glob
'!.git/**'`. A ripgrep glob that contains a slash is anchored at the
search root, so `!.git/**` only prunes the repository's own top-level
`.git` directory. Two common layouts slip through:

- a vendored or nested checkout keeps its own `.git` directory, and
  `--hidden` makes ripgrep descend into it, so `vendor/lib/.git/HEAD`,
  `vendor/lib/.git/config`, and loose object files land in the
  inventory;
- a linked `git worktree` stores its gitdir pointer in a `.git` *file*,
  which `.git/**` never matches, so `./.git` is listed as a source file.

The inventory is the authorized list that scan coverage is reconciled
against, so Git internals become paths the scan is expected to review or
defer, even though ranking already drops any path with a `.git`
component and can never score them.

Use `!**/.git` instead. The leading `**/` makes the pattern match a
`.git` entry at any depth, ripgrep stops descending once the directory
is excluded, and a plain `.git` file is excluded as well. Apply the same
glob to the scoped ripgrep call in `generate_rank_input.py` and to the
two mirrored oracle commands in the tests so they keep matching the
command the scripts actually run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label Sep 30, 2026

@mldangelo-oai mldangelo-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for tracking this down. Keeping Git internals out of the inventory makes both the review list and coverage counts more useful. The directory-scope fix and worktree tests cover the tricky cases, and the 142 targeted Python tests, MCP checks, and platform CI are all green. Looks good to merge.

@mldangelo-oai
mldangelo-oai merged commit 15c018d into openai:main Sep 30, 2026
48 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 30, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants