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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e251a51a
Commit
e251a51a
authored
Mar 24, 2021
by
Ron Chan
Committed by
Alex Kalderimis
Mar 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow import url scheme to start with javascript
Created a spec file to be tested with the scheme validation
parent
990ef110
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
0 deletions
+32
-0
changelogs/unreleased/manifest-unsafe-scheme.yml
changelogs/unreleased/manifest-unsafe-scheme.yml
+5
-0
lib/gitlab/manifest_import/manifest.rb
lib/gitlab/manifest_import/manifest.rb
+8
-0
spec/features/import/manifest_import_spec.rb
spec/features/import/manifest_import_spec.rb
+9
-0
spec/fixtures/unsafe_javascript.xml
spec/fixtures/unsafe_javascript.xml
+10
-0
No files found.
changelogs/unreleased/manifest-unsafe-scheme.yml
0 → 100644
View file @
e251a51a
---
title
:
Validate import manifest url scheme
merge_request
:
57071
author
:
type
:
fixed
lib/gitlab/manifest_import/manifest.rb
View file @
e251a51a
...
...
@@ -47,6 +47,10 @@ module Gitlab
@errors
<<
'Make sure every <project> tag has name and path attributes.'
end
unless
validate_scheme
@errors
<<
'Make sure the url does not start with javascript'
end
@errors
.
empty?
end
...
...
@@ -64,6 +68,10 @@ module Gitlab
end
end
def
validate_scheme
remote
!~
/\Ajavascript/i
end
def
repository_url
(
name
)
Gitlab
::
Utils
.
append_path
(
remote
,
name
)
end
...
...
spec/features/import/manifest_import_spec.rb
View file @
e251a51a
...
...
@@ -42,6 +42,15 @@ RSpec.describe 'Import multiple repositories by uploading a manifest file', :js
end
end
it
'renders an error if the remote url scheme starts with javascript'
do
visit
new_import_manifest_path
attach_file
(
'manifest'
,
Rails
.
root
.
join
(
'spec/fixtures/unsafe_javascript.xml'
))
click_on
'List available repositories'
expect
(
page
).
to
have_content
'Make sure the url does not start with javascript'
end
it
'renders an error if invalid file was provided'
do
visit
new_import_manifest_path
...
...
spec/fixtures/unsafe_javascript.xml
0 → 100644
View file @
e251a51a
<manifest>
<remote
review=
"javascript://HelloTheGitlabSecurityTeam%0Aprompt(1)%0A"
/>
<project
path=
"test1"
name=
"manifest1"
/>
<project
path=
"test2"
name=
"manifest2"
/>
<project
path=
"test3"
name=
"manifest3"
/>
<project
path=
"test4"
name=
"manifest4"
/>
<project
path=
"test5"
name=
"manifest5"
/>
<project
path=
"test6"
name=
"manifest6"
/>
</manifest>
\ No newline at end of file
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