diff --git a/endpoints/api/build.py b/endpoints/api/build.py index 0b2ef5464..b64f3ad37 100644 --- a/endpoints/api/build.py +++ b/endpoints/api/build.py @@ -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