Fix bug which allowed for implicit library namespace access via the V1 registry protocol when the feature flag was off

Now we raise a 400 as expected
This commit is contained in:
Joseph Schorr 2018-05-01 13:26:24 +03:00
parent 178c8e7cb0
commit 77adf9dd77
2 changed files with 20 additions and 5 deletions

View file

@ -9,7 +9,7 @@ import features
from app import app
from auth.auth_context import get_authenticated_context
from util.names import parse_namespace_repository
from util.names import parse_namespace_repository, ImplicitLibraryNamespaceNotAllowed
from util.http import abort
logger = logging.getLogger(__name__)
@ -26,9 +26,14 @@ def parse_repository_name(include_tag=False,
def inner(func):
@wraps(func)
def wrapper(*args, **kwargs):
repo_name_components = parse_namespace_repository(kwargs[incoming_repo_kwarg],
app.config['LIBRARY_NAMESPACE'],
include_tag=include_tag)
try:
repo_name_components = parse_namespace_repository(kwargs[incoming_repo_kwarg],
app.config['LIBRARY_NAMESPACE'],
include_tag=include_tag,
allow_library=features.LIBRARY_SUPPORT)
except ImplicitLibraryNamespaceNotAllowed:
abort(400)
del kwargs[incoming_repo_kwarg]
kwargs[ns_kwarg_name] = repo_name_components[0]
kwargs[repo_kwarg_name] = repo_name_components[1]