GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: reject unsafe output options in Commit.count by Byron · Pull Request #2184 · gitpython-developers/GitPython

Conversation

@Byron

@Byron Byron commented Jul 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

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.

Summary

  • Validate options forwarded by Commit.count() with the existing revision unsafe-option guard.
  • Preserve the explicit allow_unsafe_options=True escape hatch for trusted callers.
  • Audit internal .git.* calls that can accept Git’s --output option; revision iteration, diff/diff-tree, blame, and archive paths were already guarded, leaving Commit.count() as the missing high-level wrapper.

Advisory summary

  • Advisory: GHSA-p538-c434-8v24
  • GHSA: GHSA-p538-c434-8v24
  • Severity: medium
  • Package: GitPython (pip)
  • Affected versions: <= 3.1.55
  • Patched versions: not yet designated
  • CVE: not assigned

The advisory is unpublished, so this public PR intentionally omits unnecessary exploitation detail.

Git reference

Git baseline a23bace963: diff.c defines --output as a shared diff option consumed by setup_revisions; t/t6000-rev-list-misc.sh covers the option with rev-list.

Validation

  • Regression test failed before the fix and passes after it.
  • Focused unsafe-option tests: 3 passed.
  • mypy git/objects/commit.py: passed.
  • Ruff check and format check: passed.
  • Full test/test_commit.py: 33 passed; 2 unrelated local failures because this fixture checkout has no master ref.
  • codex review --commit 056e1f1474ca5d1c8817abe274633f7420c8104d: no findings.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Byron @codex
fix: reject unsafe output options in Commit.count
38553b6
<!-- agent -->

Commit.count forwards keyword arguments to git rev-list but did not apply the
unsafe-option validation used by the sibling revision APIs.

Validate forwarded options with the existing Git.check_unsafe_options helper
and retain the explicit allow_unsafe_options escape hatch. This covers
GHSA-p538-c434-8v24 without adding another option parser.

Git baseline: git.git a23bace963 defines --output as a shared diff option
consumed by setup_revisions; t/t6000-rev-list-misc.sh exercises that option
with rev-list.

Co-authored-by: GPT 5.6 <[email protected]>
@Byron
Byron force-pushed the fix-output-arg branch from 056e1f1 to 38553b6 Compare July 25, 2026 07:29
@Byron
Byron marked this pull request as ready for review July 25, 2026 07:30
Copilot AI review requested due to automatic review settings July 25, 2026 07:30
Copilot started reviewing on behalf of Byron July 25, 2026 07:32
View session
Copilot AI reviewed Jul 25, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull request overview

This PR closes a security gap by ensuring Commit.count() rejects unsafe git rev-list options (notably --output/-o) unless explicitly allowed, aligning it with existing unsafe-option protections used elsewhere in GitPython’s revision/diff surfaces.

Changes:

  • Add an allow_unsafe_options escape hatch to Commit.count() and validate forwarded kwargs via Git.check_unsafe_options.
  • Add a regression test asserting Commit.count(output=...) raises UnsafeOptionError.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
git/objects/commit.py Adds unsafe-option validation to Commit.count() with an allow_unsafe_options bypass flag.
test/test_commit.py Adds a regression test ensuring Commit.count() rejects unsafe output options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test_commit.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Byron
Byron merged commit d3e9438 into main Jul 25, 2026
33 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Byron
Byron deleted the fix-output-arg branch July 25, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Byron
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.