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
Léo-Paul Géneau
gitlab-ce
Commits
26b98bff
Commit
26b98bff
authored
Aug 10, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve validation of X-Gitlab-Lfs-Tmp header
parent
f817eecb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
app/controllers/projects/lfs_storage_controller.rb
app/controllers/projects/lfs_storage_controller.rb
+3
-7
spec/requests/lfs_http_spec.rb
spec/requests/lfs_http_spec.rb
+14
-2
No files found.
app/controllers/projects/lfs_storage_controller.rb
View file @
26b98bff
...
...
@@ -58,13 +58,9 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
def
tmp_filename
name
=
request
.
headers
[
'X-Gitlab-Lfs-Tmp'
]
if
name
.
present?
name
.
gsub!
(
/^.*(\\|\/)/
,
''
)
name
=
name
.
match
(
/[0-9a-f]{73}/
)
name
[
0
]
if
name
else
nil
end
return
if
name
.
include?
(
'/'
)
return
unless
oid
.
present?
&&
name
.
start_with?
(
oid
)
name
end
def
store_file
(
oid
,
size
,
tmp_file
)
...
...
spec/requests/lfs_http_spec.rb
View file @
26b98bff
...
...
@@ -556,7 +556,7 @@ describe 'Git LFS API and storage' do
context
'and request is sent with a malformed headers'
do
before
do
put_finalize
(
'
cat
/etc/passwd'
)
put_finalize
(
'/etc/passwd'
)
end
it
'does not recognize it as a valid lfs command'
do
...
...
@@ -588,7 +588,7 @@ describe 'Git LFS API and storage' do
context
'and request is sent with a malformed headers'
do
before
do
put_finalize
(
'
cat
/etc/passwd'
)
put_finalize
(
'/etc/passwd'
)
end
it
'does not recognize it as a valid lfs command'
do
...
...
@@ -636,6 +636,18 @@ describe 'Git LFS API and storage' do
it
'lfs object is linked to the project'
do
expect
(
lfs_object
.
projects
.
pluck
(
:id
)).
to
include
(
project
.
id
)
end
en
context
'invalid tempfiles'
do
it
'rejects slashes in the tempfile name (path traversal'
do
put_finalize
(
'foo/bar'
)
expect
(
response
).
to
have_http_status
(
403
)
end
it
'rejects tempfile names that do not start with the oid'
do
put_finalize
(
"foo
#{
sample_oid
}
"
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
end
...
...
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