Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
6de7bab2
Kaydet (Commit)
6de7bab2
authored
Şub 05, 2018
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Rewrite access check in create_archive with EAFP
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
539b321b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
utils.py
docker/utils/utils.py
+3
-5
utils_test.py
tests/unit/utils_test.py
+6
-2
No files found.
docker/utils/utils.py
Dosyayı görüntüle @
6de7bab2
...
@@ -97,10 +97,6 @@ def create_archive(root, files=None, fileobj=None, gzip=False):
...
@@ -97,10 +97,6 @@ def create_archive(root, files=None, fileobj=None, gzip=False):
for
path
in
files
:
for
path
in
files
:
full_path
=
os
.
path
.
join
(
root
,
path
)
full_path
=
os
.
path
.
join
(
root
,
path
)
if
os
.
lstat
(
full_path
)
.
st_mode
&
os
.
R_OK
==
0
:
raise
IOError
(
'Can not access file in context: {}'
.
format
(
full_path
)
)
i
=
t
.
gettarinfo
(
full_path
,
arcname
=
path
)
i
=
t
.
gettarinfo
(
full_path
,
arcname
=
path
)
if
i
is
None
:
if
i
is
None
:
# This happens when we encounter a socket file. We can safely
# This happens when we encounter a socket file. We can safely
...
@@ -121,7 +117,9 @@ def create_archive(root, files=None, fileobj=None, gzip=False):
...
@@ -121,7 +117,9 @@ def create_archive(root, files=None, fileobj=None, gzip=False):
with
open
(
full_path
,
'rb'
)
as
f
:
with
open
(
full_path
,
'rb'
)
as
f
:
t
.
addfile
(
i
,
f
)
t
.
addfile
(
i
,
f
)
except
IOError
:
except
IOError
:
t
.
addfile
(
i
,
None
)
raise
IOError
(
'Can not read file in context: {}'
.
format
(
full_path
)
)
else
:
else
:
# Directories, FIFOs, symlinks... don't need to be read.
# Directories, FIFOs, symlinks... don't need to be read.
t
.
addfile
(
i
,
None
)
t
.
addfile
(
i
,
None
)
...
...
tests/unit/utils_test.py
Dosyayı görüntüle @
6de7bab2
...
@@ -933,7 +933,10 @@ class TarTest(unittest.TestCase):
...
@@ -933,7 +933,10 @@ class TarTest(unittest.TestCase):
tar_data
=
tarfile
.
open
(
fileobj
=
archive
)
tar_data
=
tarfile
.
open
(
fileobj
=
archive
)
assert
sorted
(
tar_data
.
getnames
())
==
[
'bar'
,
'foo'
]
assert
sorted
(
tar_data
.
getnames
())
==
[
'bar'
,
'foo'
]
@pytest.mark.skipif
(
IS_WINDOWS_PLATFORM
,
reason
=
'No chmod on Windows'
)
@pytest.mark.skipif
(
IS_WINDOWS_PLATFORM
or
os
.
geteuid
()
==
0
,
reason
=
'root user always has access ; no chmod on Windows'
)
def
test_tar_with_inaccessible_file
(
self
):
def
test_tar_with_inaccessible_file
(
self
):
base
=
tempfile
.
mkdtemp
()
base
=
tempfile
.
mkdtemp
()
full_path
=
os
.
path
.
join
(
base
,
'foo'
)
full_path
=
os
.
path
.
join
(
base
,
'foo'
)
...
@@ -944,8 +947,9 @@ class TarTest(unittest.TestCase):
...
@@ -944,8 +947,9 @@ class TarTest(unittest.TestCase):
with
pytest
.
raises
(
IOError
)
as
ei
:
with
pytest
.
raises
(
IOError
)
as
ei
:
tar
(
base
)
tar
(
base
)
assert
'Can not
access file in context: {}'
.
format
(
full_path
)
in
\
assert
'Can not
read file in context: {}'
.
format
(
full_path
)
in
(
ei
.
exconly
()
ei
.
exconly
()
)
@pytest.mark.skipif
(
IS_WINDOWS_PLATFORM
,
reason
=
'No symlinks on Windows'
)
@pytest.mark.skipif
(
IS_WINDOWS_PLATFORM
,
reason
=
'No symlinks on Windows'
)
def
test_tar_with_file_symlinks
(
self
):
def
test_tar_with_file_symlinks
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment