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

Suggested fixes by iCR, OpenRefactory, Inc. by openrefactory · Pull Request #1486 · gitpython-developers/GitPython · GitHub

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

Filter by extension

Filter by extension .py  (2) All 1 file type 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
6 changes: 5 additions & 1 deletion git/index/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 @@ -4,6 +4,7 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php

from ast import Delete
import glob
from io import BytesIO
import os
Expand Down Expand Up @@ -351,7 +352,10 @@ def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile

# tmp file created in git home directory to be sure renaming
# works - /tmp/ dirs could be on another device
tmp_index = tempfile.mktemp("", "", repo.git_dir)

# OpenRefactory Warning: The method 'tempfile.mktemp' creates temporary file in an insecure way.
# use 'NamedTemporaryFile' instead of using 'mktemp' to create temporary file
tmp_index = tempfile.NamedTemporaryFile("", "", repo.git_dir).name
arg_list.append("--index-output=%s" % tmp_index)
arg_list.extend(treeish)

Expand Down
4 changes: 3 additions & 1 deletion git/index/util.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 @@ -40,7 +40,9 @@ class TemporaryFileSwap(object):

def __init__(self, file_path: PathLike) -> None:
self.file_path = file_path
self.tmp_file_path = str(self.file_path) + tempfile.mktemp("", "", "")
# OpenRefactory Warning: The method 'tempfile.mktemp' creates temporary file in an insecure way.
# use 'NamedTemporaryFile' instead of using 'mktemp' to create temporary file
self.tmp_file_path = str(self.file_path) + tempfile.NamedTemporaryFile("", "", "").name
# it may be that the source does not exist
try:
os.rename(self.file_path, self.tmp_file_path)
Expand Down

Back | FazBrowse Home | New Git URL