Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
Kazuhiko Shiozaki
gitlab-shell
Commits
310131d1
Commit
310131d1
authored
Aug 29, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wrong_number_of_arguments' into 'master'
Handle invalid number of arguments See merge request !37
parents
b5284310
5de3c0e8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
3 deletions
+17
-3
CHANGELOG
CHANGELOG
+1
-0
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+8
-3
spec/gitlab_shell_spec.rb
spec/gitlab_shell_spec.rb
+8
-0
No files found.
CHANGELOG
View file @
310131d1
v1.9.8
- Replace raise with abort when checking path to prevent path exposure
- Handle invalid number of arguments on remote commands
v1.9.7
- Increased test coverage
...
...
lib/gitlab_shell.rb
View file @
310131d1
...
...
@@ -3,6 +3,8 @@ require 'shellwords'
require_relative
'gitlab_net'
class
GitlabShell
class
DisallowedCommandError
<
StandardError
;
end
attr_accessor
:key_id
,
:repo_name
,
:git_cmd
,
:repos_path
,
:repo_name
def
initialize
...
...
@@ -28,19 +30,22 @@ class GitlabShell
$stderr
.
puts
"Access denied."
end
else
message
=
"gitlab-shell: Attempt to execute disallowed command <
#{
@origin_cmd
}
> by
#{
log_username
}
."
$logger
.
warn
message
puts
'Not allowed command'
raise
DisallowedCommandError
end
else
puts
"Welcome to GitLab,
#{
username
}
!"
end
rescue
DisallowedCommandError
=>
ex
message
=
"gitlab-shell: Attempt to execute disallowed command <
#{
@origin_cmd
}
> by
#{
log_username
}
."
$logger
.
warn
message
puts
'Not allowed command'
end
protected
def
parse_cmd
args
=
Shellwords
.
shellwords
(
@origin_cmd
)
raise
DisallowedCommandError
unless
args
.
count
==
2
@git_cmd
=
args
[
0
]
@repo_name
=
escape_path
(
args
[
1
])
end
...
...
spec/gitlab_shell_spec.rb
View file @
310131d1
...
...
@@ -48,6 +48,14 @@ describe GitlabShell do
its
(
:repo_name
)
{
should
==
'dmitriy.zaporozhets/gitlab-ci.git'
}
its
(
:git_cmd
)
{
should
==
'git-upload-pack'
}
end
context
'with an invalid number of arguments'
do
before
{
ssh_cmd
'foobar'
}
it
"should raise an DisallowedCommandError"
do
expect
{
subject
.
send
:parse_cmd
}.
to
raise_error
(
GitlabShell
::
DisallowedCommandError
)
end
end
end
describe
:exec
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