Require explicit opt-in for filesystem diffs - #2217
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens GitPython’s high-level diff APIs against repository-boundary bypass by requiring explicit caller opt-in before enabling filesystem-wide diff semantics (--no-index).
Changes:
- Mark
--no-indexas an unsafe diff option (requiresallow_unsafe_options=True). - Add regression tests ensuring both keyword (
no_index=True) and raw-option ("--no-index") spellings are rejected by default. - Update
Diffable.diffdocumentation to include--no-indexin the unsafe-options description.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
test/test_diff.py |
Adds tests that --no-index/no_index are blocked unless explicitly allowed. |
git/repo/base.py |
Adds --no-index to the repo’s unsafe diff option allowlist/denylist used by high-level diff APIs. |
git/diff.py |
Updates the allow_unsafe_options docstring to document --no-index as unsafe. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
<!-- agent --> Treat --no-index as an unsafe diff option because it changes path operands from repository pathspecs to arbitrary filesystem paths. This addresses GHSA-whh4-5q6c-9v3x without exposing advisory reproduction details. Assisted-by: GPT 5.6 Co-authored-by: GPT 5.6 <codex@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by Codex GPT-5.
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Advisory
https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-whh4-5q6c-9v3x
GHSA-whh4-5q6c-9v3x reports a repository-boundary bypass in the high-level diff API. This change requires callers to explicitly opt in before diff paths may use filesystem-wide semantics. Reproduction mechanics are intentionally omitted while the advisory is unpublished.
Advisory summary
= 3.1.59Changes
--no-indexas an unsafe diff option.Validation
test/test_diff.py: 25 passed, 1 unrelated local-environment failure in staged conflict reporting.git diff --checkpassed.Documentation/git-diff.adocand implements it inbuiltin/diff.c.14200584but the CLI usage allowance was exhausted before review began.