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
nexedi
gitlab-shell
Commits
252a96d6
Commit
252a96d6
authored
Jul 26, 2018
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidy up GitlabShell
* Use constants for git commands * private instead of protected
parent
c4d63ab0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+12
-7
No files found.
lib/gitlab_shell.rb
View file @
252a96d6
...
...
@@ -6,7 +6,6 @@ require_relative 'gitlab_metrics'
class
GitlabShell
# rubocop:disable Metrics/ClassLength
GIT_COMMANDS
=
%w(git-upload-pack git-receive-pack git-upload-archive git-lfs-authenticate)
.
freeze
GITALY_MIGRATED_COMMANDS
=
{
'git-upload-pack'
=>
File
.
join
(
ROOT_PATH
,
'bin'
,
'gitaly-upload-pack'
),
'git-upload-archive'
=>
File
.
join
(
ROOT_PATH
,
'bin'
,
'gitaly-upload-archive'
),
...
...
@@ -16,6 +15,13 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
attr_accessor
:key_id
,
:gl_repository
,
:repo_name
,
:command
,
:git_access
attr_reader
:repo_path
GIT_UPLOAD_PACK_COMMAND
=
'git-upload-pack'
.
freeze
GIT_RECEIVE_PACK_COMMAND
=
'git-receive-pack'
.
freeze
GIT_UPLOAD_ARCHIVE_COMMAND
=
'git-upload-archive'
.
freeze
GIT_LFS_AUTHENTICATE_COMMAND
=
'git-lfs-authenticate'
.
freeze
GIT_COMMANDS
=
[
GIT_UPLOAD_PACK_COMMAND
,
GIT_RECEIVE_PACK_COMMAND
,
GIT_UPLOAD_ARCHIVE_COMMAND
,
GIT_LFS_AUTHENTICATE_COMMAND
].
freeze
def
initialize
(
key_id
)
@key_id
=
key_id
...
...
@@ -26,7 +32,7 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
# ssh git@gitlab.example.com 'evil command', then origin_cmd contains
# 'evil command'.
def
exec
(
origin_cmd
)
unless
origin_cmd
if
!
origin_cmd
||
origin_cmd
.
empty?
puts
"Welcome to GitLab,
#{
username
}
!"
return
true
end
...
...
@@ -46,20 +52,19 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
false
rescue
AccessDeniedError
=>
ex
$logger
.
warn
(
'Access denied'
,
command:
origin_cmd
,
user:
log_username
)
$stderr
.
puts
"GitLab:
#{
ex
.
message
}
"
false
rescue
DisallowedCommandError
$logger
.
warn
(
'Denied disallowed command'
,
command:
origin_cmd
,
user:
log_username
)
$stderr
.
puts
"GitLab: Disallowed command"
$stderr
.
puts
'GitLab: Disallowed command'
false
rescue
InvalidRepositoryPathError
$stderr
.
puts
"GitLab: Invalid repository path"
$stderr
.
puts
'GitLab: Invalid repository path'
false
end
protected
private
def
parse_cmd
(
args
)
# Handle Git for Windows 2.14 using "git upload-pack" instead of git-upload-pack
...
...
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