FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Require explicit opt-in for filesystem diffs by Byron · Pull Request #2217 · gitpython-developers/GitPython · GitHub

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

Filter by extension

Filter by extension .py  (3) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions doc/source/changes.rst
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
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
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
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
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
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
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
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

Back | FazBrowse Home | New Git URL