Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit 8588e1c

Browse files
author
Olivier Gambier
committed
Better (index-based) validation
Docker-DCO-1.1-Signed-off-by: Olivier Gambier <[email protected]> (github: dmp42)
1 parent f12d7af commit 8588e1c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

docker_registry/images.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ def get_image_layer(image_id, headers):
203203
bytes_range = _parse_bytes_range()
204204
repository = toolkit.get_repository()
205205
if repository and store.is_private(*repository):
206-
return toolkit.api_error('Image not found', 404)
206+
if not toolkit.validate_parent_access(image_id):
207+
return toolkit.api_error('Image not found', 404)
207208
# If no auth token found, either standalone registry or privileged
208209
# access. In both cases, access is always "public".
209210
return _get_image_layer(image_id, headers, bytes_range)
@@ -321,7 +322,8 @@ def get_image_json(image_id, headers):
321322
try:
322323
repository = toolkit.get_repository()
323324
if repository and store.is_private(*repository):
324-
return toolkit.api_error('Image not found', 404)
325+
if not toolkit.validate_parent_access(image_id):
326+
return toolkit.api_error('Image not found', 404)
325327
# If no auth token found, either standalone registry or privileged
326328
# access. In both cases, access is always "public".
327329
return _get_image_json(image_id, headers)
@@ -448,7 +450,8 @@ def get_image_files(image_id, headers):
448450
try:
449451
repository = toolkit.get_repository()
450452
if repository and store.is_private(*repository):
451-
return toolkit.api_error('Image not found', 404)
453+
if not toolkit.validate_parent_access(image_id):
454+
return toolkit.api_error('Image not found', 404)
452455
# If no auth token found, either standalone registry or privileged
453456
# access. In both cases, access is always "public".
454457
data = layers.get_image_files_json(image_id)
@@ -469,7 +472,8 @@ def get_image_diff(image_id, headers):
469472
return toolkit.api_error('Diff queue is disabled', 400)
470473
repository = toolkit.get_repository()
471474
if repository and store.is_private(*repository):
472-
return toolkit.api_error('Image not found', 404)
475+
if not toolkit.validate_parent_access(image_id):
476+
return toolkit.api_error('Image not found', 404)
473477

474478
# first try the cache
475479
diff_json = layers.get_image_diff_cache(image_id)

0 commit comments

Comments
 (0)