Add check for None repository in start build API

Fixes #2244
This commit is contained in:
Joseph Schorr 2016-12-19 11:40:24 -05:00
parent e58e04b0e9
commit f4f5a065df

View file

@ -273,10 +273,12 @@ class RepositoryBuildList(RepositoryParamResource):
# Start the build.
repo = model.repository.get_repository(namespace, repository)
if repo is None:
raise NotFound()
build_name = (user_files.get_file_checksum(dockerfile_id)
if dockerfile_id
else hashlib.sha224(archive_url).hexdigest()[0:7])
build_name = (user_files.get_file_checksum(dockerfile_id)
if dockerfile_id
else hashlib.sha224(archive_url).hexdigest()[0:7])
prepared = PreparedBuild()
prepared.build_name = build_name
@ -317,6 +319,9 @@ class RepositoryBuildResource(RepositoryParamResource):
except model.build.InvalidRepositoryBuildException:
raise NotFound()
if build.repository.name != repository or build.repository.namespace_user.username != namespace:
raise NotFound()
return build_status_view(build)
@require_repo_admin