Merge pull request #1213 from jzelinskie/manifesto
return an error when writing manifest v2 schema2
This commit is contained in:
commit
b76252b3f2
2 changed files with 18 additions and 2 deletions
|
@ -52,10 +52,11 @@ class ManifestBlobUnknown(V2RegistryException):
|
||||||
|
|
||||||
|
|
||||||
class ManifestInvalid(V2RegistryException):
|
class ManifestInvalid(V2RegistryException):
|
||||||
def __init__(self, detail=None):
|
def __init__(self, detail=None, http_status_code=400):
|
||||||
super(ManifestInvalid, self).__init__('MANIFEST_INVALID',
|
super(ManifestInvalid, self).__init__('MANIFEST_INVALID',
|
||||||
'manifest invalid',
|
'manifest invalid',
|
||||||
detail)
|
detail,
|
||||||
|
http_status_code)
|
||||||
|
|
||||||
|
|
||||||
class ManifestUnknown(V2RegistryException):
|
class ManifestUnknown(V2RegistryException):
|
||||||
|
|
|
@ -8,6 +8,7 @@ from flask import make_response, request, url_for
|
||||||
from collections import namedtuple, OrderedDict
|
from collections import namedtuple, OrderedDict
|
||||||
from jwkest.jws import SIGNER_ALGS, keyrep
|
from jwkest.jws import SIGNER_ALGS, keyrep
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
from app import docker_v2_signing_key, app
|
from app import docker_v2_signing_key, app
|
||||||
from auth.registry_jwt_auth import process_registry_jwt_auth
|
from auth.registry_jwt_auth import process_registry_jwt_auth
|
||||||
|
@ -33,6 +34,8 @@ MANIFEST_TAGNAME_ROUTE = BASE_MANIFEST_ROUTE.format(VALID_TAG_PATTERN)
|
||||||
|
|
||||||
# From: https://github.com/docker/distribution/blob/47a064d4195a9b56133891bbb13620c3ac83a827/manifest/schema1/manifest.go#L18
|
# From: https://github.com/docker/distribution/blob/47a064d4195a9b56133891bbb13620c3ac83a827/manifest/schema1/manifest.go#L18
|
||||||
MANIFEST_CONTENT_TYPE = 'application/vnd.docker.distribution.manifest.v1+prettyjws'
|
MANIFEST_CONTENT_TYPE = 'application/vnd.docker.distribution.manifest.v1+prettyjws'
|
||||||
|
MANIFEST2_SCHEMA2_CONTENT_TYPES = ['application/vnd.docker.distribution.manifest.v2+json',
|
||||||
|
'application/vnd.docker.distribution.manifest.list.v2+json']
|
||||||
|
|
||||||
ISO_DATETIME_FORMAT_ZULU = '%Y-%m-%dT%H:%M:%SZ'
|
ISO_DATETIME_FORMAT_ZULU = '%Y-%m-%dT%H:%M:%SZ'
|
||||||
JWS_ALGORITHM = 'RS256'
|
JWS_ALGORITHM = 'RS256'
|
||||||
|
@ -279,11 +282,22 @@ def fetch_manifest_by_digest(namespace, repo_name, manifest_ref):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def _reject_manifest2_schema2(func):
|
||||||
|
@wraps(func)
|
||||||
|
def wrapped(*args, **kwargs):
|
||||||
|
if request.content_type in MANIFEST2_SCHEMA2_CONTENT_TYPES:
|
||||||
|
raise ManifestInvalid(detail={'message': 'manifest schema version not supported'},
|
||||||
|
http_status_code=415)
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
return wrapped
|
||||||
|
|
||||||
|
|
||||||
@v2_bp.route(MANIFEST_TAGNAME_ROUTE, methods=['PUT'])
|
@v2_bp.route(MANIFEST_TAGNAME_ROUTE, methods=['PUT'])
|
||||||
@process_registry_jwt_auth
|
@process_registry_jwt_auth
|
||||||
@parse_repository_name
|
@parse_repository_name
|
||||||
@require_repo_write
|
@require_repo_write
|
||||||
@anon_protect
|
@anon_protect
|
||||||
|
@_reject_manifest2_schema2
|
||||||
def write_manifest_by_tagname(namespace, repo_name, manifest_ref):
|
def write_manifest_by_tagname(namespace, repo_name, manifest_ref):
|
||||||
try:
|
try:
|
||||||
manifest = SignedManifest(request.data)
|
manifest = SignedManifest(request.data)
|
||||||
|
@ -301,6 +315,7 @@ def write_manifest_by_tagname(namespace, repo_name, manifest_ref):
|
||||||
@parse_repository_name
|
@parse_repository_name
|
||||||
@require_repo_write
|
@require_repo_write
|
||||||
@anon_protect
|
@anon_protect
|
||||||
|
@_reject_manifest2_schema2
|
||||||
def write_manifest_by_digest(namespace, repo_name, manifest_ref):
|
def write_manifest_by_digest(namespace, repo_name, manifest_ref):
|
||||||
try:
|
try:
|
||||||
manifest = SignedManifest(request.data)
|
manifest = SignedManifest(request.data)
|
||||||
|
|
Reference in a new issue