BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
248e14ea
Commit
248e14ea
authored
Aug 08, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'import-symlinks-9-2' into 'security-9-2'
Fix file disclosure via hidden symlinks using the project import (9.2) See merge request !2163
parent
23ba6c72
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletion
+14
-1
fix-import-symbolink-links.yml
changelogs/unreleased/fix-import-symbolink-links.yml
+4
-0
file_importer.rb
lib/gitlab/import_export/file_importer.rb
+5
-1
file_importer_spec.rb
spec/lib/gitlab/import_export/file_importer_spec.rb
+5
-0
No files found.
changelogs/unreleased/fix-import-symbolink-links.yml
0 → 100644
View file @
248e14ea
---
title
:
Remove hidden symlinks from project import files
merge_request
:
author
:
lib/gitlab/import_export/file_importer.rb
View file @
248e14ea
...
@@ -47,12 +47,16 @@ module Gitlab
...
@@ -47,12 +47,16 @@ module Gitlab
end
end
def
remove_symlinks!
def
remove_symlinks!
Dir
[
"
#{
@shared
.
export_path
}
/**/*"
]
.
each
do
|
path
|
extracted_files
.
each
do
|
path
|
FileUtils
.
rm
(
path
)
if
File
.
lstat
(
path
).
symlink?
FileUtils
.
rm
(
path
)
if
File
.
lstat
(
path
).
symlink?
end
end
true
true
end
end
def
extracted_files
Dir
.
glob
(
"
#{
@shared
.
export_path
}
/**/*"
,
File
::
FNM_DOTMATCH
).
reject
{
|
f
|
f
=~
/.*\/\.{1,2}$/
}
end
end
end
end
end
end
end
spec/lib/gitlab/import_export/file_importer_spec.rb
View file @
248e14ea
...
@@ -5,6 +5,7 @@ describe Gitlab::ImportExport::FileImporter, lib: true do
...
@@ -5,6 +5,7 @@ describe Gitlab::ImportExport::FileImporter, lib: true do
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/file_importer_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/file_importer_spec"
}
let
(
:valid_file
)
{
"
#{
shared
.
export_path
}
/valid.json"
}
let
(
:valid_file
)
{
"
#{
shared
.
export_path
}
/valid.json"
}
let
(
:symlink_file
)
{
"
#{
shared
.
export_path
}
/invalid.json"
}
let
(
:symlink_file
)
{
"
#{
shared
.
export_path
}
/invalid.json"
}
let
(
:hidden_symlink_file
)
{
"
#{
shared
.
export_path
}
/.hidden"
}
let
(
:subfolder_symlink_file
)
{
"
#{
shared
.
export_path
}
/subfolder/invalid.json"
}
let
(
:subfolder_symlink_file
)
{
"
#{
shared
.
export_path
}
/subfolder/invalid.json"
}
before
do
before
do
...
@@ -25,6 +26,10 @@ describe Gitlab::ImportExport::FileImporter, lib: true do
...
@@ -25,6 +26,10 @@ describe Gitlab::ImportExport::FileImporter, lib: true do
expect
(
File
.
exist?
(
symlink_file
)).
to
be
false
expect
(
File
.
exist?
(
symlink_file
)).
to
be
false
end
end
it
'removes hidden symlinks in root folder'
do
expect
(
File
.
exist?
(
hidden_symlink_file
)).
to
be
false
end
it
'removes symlinks in subfolders'
do
it
'removes symlinks in subfolders'
do
expect
(
File
.
exist?
(
subfolder_symlink_file
)).
to
be
false
expect
(
File
.
exist?
(
subfolder_symlink_file
)).
to
be
false
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