mirror of
https://github.com/clearml/clearml-agent
synced 2025-01-31 17:16:51 +00:00
Add protection against bad file name parsing in git diff apply
This commit is contained in:
parent
d419fa1e4f
commit
3bed0ef33c
@ -150,12 +150,23 @@ class VCS(object):
|
|||||||
"""
|
"""
|
||||||
Apply patch repository at `location`
|
Apply patch repository at `location`
|
||||||
"""
|
"""
|
||||||
self.log.info("applying diff to %s", location)
|
self.log.info("applying diff to %s" % location)
|
||||||
|
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
for match in filter(
|
for match in filter(
|
||||||
None, map(self.PATCH_ADDED_FILE_RE.match, patch_content.splitlines())
|
None, map(self.PATCH_ADDED_FILE_RE.match, patch_content.splitlines())
|
||||||
):
|
):
|
||||||
create_file_if_not_exists(normalize_path(location, match.group("path")))
|
file_path = None
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
file_path = normalize_path(location, match.group("path"))
|
||||||
|
create_file_if_not_exists(file_path)
|
||||||
|
except Exception:
|
||||||
|
if file_path:
|
||||||
|
self.log.warning("failed creating file for git diff (%s)" % file_path)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
return_code, errors = self.call_with_stdin(
|
return_code, errors = self.call_with_stdin(
|
||||||
patch_content, *self.patch_base, cwd=location
|
patch_content, *self.patch_base, cwd=location
|
||||||
|
Loading…
Reference in New Issue
Block a user