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
e1f3fd2b
Commit
e1f3fd2b
authored
Mar 08, 2022
by
Dominic Couture
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escape branch names in push instructions
Changelog: security
parent
0cc6a229
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
app/views/projects/empty.html.haml
app/views/projects/empty.html.haml
+5
-4
spec/views/projects/empty.html.haml_spec.rb
spec/views/projects/empty.html.haml_spec.rb
+15
-0
No files found.
app/views/projects/empty.html.haml
View file @
e1f3fd2b
-
@content_class
=
"limit-container-width"
unless
fluid_layout
-
default_branch_name
=
@project
.
default_branch_or_main
-
escaped_default_branch_name
=
default_branch_name
.
shellescape
-
@skip_current_level_breadcrumb
=
true
=
render
partial:
'flash_messages'
,
locals:
{
project:
@project
}
...
...
@@ -42,25 +43,25 @@
:preserve
git clone
#{
content_tag
(
:span
,
default_url_to_repo
,
class:
'js-clone'
)
}
cd
#{
h
@project
.
path
}
git switch -c
#{
h
default_branch_name
}
git switch -c
#{
h
escaped_
default_branch_name
}
touch README.md
git add README.md
git commit -m "add README"
-
if
@project
.
can_current_user_push_to_default_branch?
%span
>
<
git
push
-u
origin
#{
h
default_branch_name
}
git
push
-u
origin
#{
h
escaped_
default_branch_name
}
%h5
=
_
(
'Push an existing folder'
)
%pre
.bg-light
:preserve
cd existing_folder
git init --initial-branch=
#{
h
default_branch_name
}
git init --initial-branch=
#{
h
escaped_
default_branch_name
}
git remote add origin
#{
content_tag
(
:span
,
default_url_to_repo
,
class:
'js-clone'
)
}
git add .
git commit -m "Initial commit"
-
if
@project
.
can_current_user_push_to_default_branch?
%span><
git
push
-u
origin
#{
h
default_branch_name
}
git
push
-u
origin
#{
h
escaped_
default_branch_name
}
%h5
=
_
(
'Push an existing Git repository'
)
%pre
.bg-light
...
...
spec/views/projects/empty.html.haml_spec.rb
View file @
e1f3fd2b
...
...
@@ -25,6 +25,21 @@ RSpec.describe 'projects/empty' do
expect
(
rendered
).
to
have_content
(
"git clone"
)
end
context
'when default branch name contains special shell characters'
do
let
(
:branch_name
)
{
';rm -rf /'
}
before
do
allow
(
project
).
to
receive
(
:default_branch_or_main
).
and_return
(
branch_name
)
end
it
'escapes the default branch name'
do
render
expect
(
rendered
).
not_to
have_content
(
branch_name
)
expect
(
rendered
).
to
have_content
(
branch_name
.
shellescape
)
end
end
end
context
'when user can not push code on the project'
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