Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changelog
Security fixes for

* https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-g5vv-9gxw-82hx
* https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-whh4-5q6c-9v3x

If you can, also try and provide feedback on the upcoming v4 branch
https://github.com/gitpython-developers/GitPython/pull/2177 - patches welcome.
Expand Down
4 changes: 2 additions & 2 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ def diff(
to be read and diffed.

:param allow_unsafe_options:
If ``True``, allow options such as ``--output`` and ``-O`` that can write to
or read from arbitrary filesystem paths.
If ``True``, allow options such as ``--output``, ``--no-index``, and ``-O``
that can write to or read from arbitrary filesystem paths.

:param kwargs:
Additional arguments passed to :manpage:`git-diff(1)`, such as ``R=True`` to
Expand Down
2 changes: 2 additions & 0 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ class Repo:
]

unsafe_git_diff_options = unsafe_git_revision_options + [
# Treats path operands as arbitrary filesystem paths.
"--no-index",
# Reads caller-controlled order patterns from an arbitrary file.
"-O",
"--orderfile",
Expand Down
11 changes: 11 additions & 0 deletions test/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,17 @@ def test_diff_rejects_unsafe_output_options(self):
commit.diff(output=allowed_target, allow_unsafe_options=True)
self.assertTrue(osp.isfile(allowed_target))

def test_diff_rejects_no_index(self):
calls = (
lambda: self.rorepo.head.commit.diff(no_index=True),
lambda: self.rorepo.head.commit.diff(other="--no-index"),
lambda: self.rorepo.index.diff(None, no_index=True),
lambda: self.rorepo.index.diff("--no-index"),
)
for call in calls:
with self.assertRaises(UnsafeOptionError):
call()

def test_diff_interface(self):
"""Test a few variations of the main diff routine."""
assertion_map = {}
Expand Down
Loading