Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
e485b3f6
Commit
e485b3f6
authored
Dec 15, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give forbidden if project for the build was deleted
Closes #25309
parent
278baa5b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
15 deletions
+30
-15
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+6
-13
lib/ci/api/helpers.rb
lib/ci/api/helpers.rb
+5
-2
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+19
-0
No files found.
lib/ci/api/builds.rb
View file @
e485b3f6
...
...
@@ -41,7 +41,7 @@ module Ci
put
":id"
do
authenticate_runner!
build
=
Ci
::
Build
.
where
(
runner_id:
current_runner
.
id
).
running
.
find
(
params
[
:id
])
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
authenticate_build!
(
build
,
verify_token:
false
)
update_runner_info
...
...
@@ -71,9 +71,7 @@ module Ci
# PATCH /builds/:id/trace.txt
patch
":id/trace.txt"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
not_found!
unless
build
authenticate_build_token!
(
build
)
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
authenticate_build!
(
build
)
error!
(
'400 Missing header Content-Range'
,
400
)
unless
request
.
headers
.
has_key?
(
'Content-Range'
)
content_range
=
request
.
headers
[
'Content-Range'
]
...
...
@@ -104,8 +102,7 @@ module Ci
Gitlab
::
Workhorse
.
verify_api_request!
(
headers
)
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
not_found!
unless
build
authenticate_build_token!
(
build
)
authenticate_build!
(
build
)
forbidden!
(
'build is not running'
)
unless
build
.
running?
if
params
[
:filesize
]
...
...
@@ -142,10 +139,8 @@ module Ci
require_gitlab_workhorse!
not_allowed!
unless
Gitlab
.
config
.
artifacts
.
enabled
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
not_found!
unless
build
authenticate_build_token!
(
build
)
authenticate_build!
(
build
)
forbidden!
(
'Build is not running!'
)
unless
build
.
running?
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
artifacts_upload_path
=
ArtifactUploader
.
artifacts_upload_path
artifacts
=
uploaded_file
(
:file
,
artifacts_upload_path
)
...
...
@@ -176,8 +171,7 @@ module Ci
# GET /builds/:id/artifacts
get
":id/artifacts"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
not_found!
unless
build
authenticate_build_token!
(
build
)
authenticate_build!
(
build
)
artifacts_file
=
build
.
artifacts_file
unless
artifacts_file
.
file_storage?
...
...
@@ -202,8 +196,7 @@ module Ci
# DELETE /builds/:id/artifacts
delete
":id/artifacts"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
not_found!
unless
build
authenticate_build_token!
(
build
)
authenticate_build!
(
build
)
build
.
erase_artifacts!
end
...
...
lib/ci/api/helpers.rb
View file @
e485b3f6
...
...
@@ -13,8 +13,11 @@ module Ci
forbidden!
unless
current_runner
end
def
authenticate_build_token!
(
build
)
forbidden!
unless
build_token_valid?
(
build
)
def
authenticate_build!
(
build
,
verify_token:
true
)
not_found!
unless
build
forbidden!
if
verify_token
&&
!
build_token_valid?
(
build
)
forbidden!
(
'Project has been deleted!'
)
unless
build
.
project
forbidden!
(
'Build has been erased!'
)
if
build
.
erased?
end
def
runner_registration_token_valid?
...
...
spec/requests/ci/api/builds_spec.rb
View file @
e485b3f6
...
...
@@ -329,6 +329,25 @@ describe Ci::API::Builds do
end
end
end
context
'when project for the build has been deleted'
do
let
(
:build
)
do
create
(
:ci_build
,
:pending
,
:trace
,
runner_id:
runner
.
id
,
pipeline:
pipeline
)
end
it
'responds with forbidden'
do
expect
(
response
.
status
).
to
eq
403
end
def
initial_patch_the_trace
build
.
project
.
update
(
pending_delete:
true
)
super
end
end
end
context
'when Runner makes a force-patch'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment