Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e8972c11
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e8972c11
编写于
5月 22, 2017
作者:
M
Michael Kozono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clarify error messages
And refactor to self-document a little better.
上级
23d37382
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
31 addition
and
13 deletion
+31
-13
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+26
-8
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+2
-2
spec/requests/git_http_spec.rb
spec/requests/git_http_spec.rb
+3
-3
未找到文件。
lib/gitlab/git_access.rb
浏览文件 @
e8972c11
...
...
@@ -14,8 +14,8 @@ module Gitlab
project_not_found:
'The project you were looking for could not be found.'
,
account_blocked:
'Your account has been blocked.'
,
command_not_allowed:
"The command you're trying to execute is not allowed."
,
upload_pack_disabled_
in_config:
'The command "git-upload-pack"
is not allowed.'
,
receive_pack_disabled_
in_config:
'The command "git-receive-pack"
is not allowed.'
upload_pack_disabled_
over_http:
'Pulling over HTTP
is not allowed.'
,
receive_pack_disabled_
over_http:
'Pushing over HTTP
is not allowed.'
}.
freeze
DOWNLOAD_COMMANDS
=
%w{ git-upload-pack git-upload-archive }
.
freeze
...
...
@@ -94,13 +94,23 @@ module Gitlab
end
def
check_command_disabled!
(
cmd
)
if
http?
if
upload_pack?
(
cmd
)
&&
!
Gitlab
.
config
.
gitlab_shell
.
upload_pack
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:upload_pack_disabled_in_config
]
elsif
receive_pack?
(
cmd
)
&&
!
Gitlab
.
config
.
gitlab_shell
.
receive_pack
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:receive_pack_disabled_in_config
]
if
upload_pack?
(
cmd
)
check_upload_pack_disabled!
elsif
receive_pack?
(
cmd
)
check_receive_pack_disabled!
end
end
def
check_upload_pack_disabled!
if
http?
&&
upload_pack_disabled_over_http?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:upload_pack_disabled_over_http
]
end
end
def
check_receive_pack_disabled!
if
http?
&&
receive_pack_disabled_over_http?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:receive_pack_disabled_over_http
]
end
end
def
check_command_existence!
(
cmd
)
...
...
@@ -215,6 +225,14 @@ module Gitlab
command
==
'git-receive-pack'
end
def
upload_pack_disabled_over_http?
!
Gitlab
.
config
.
gitlab_shell
.
upload_pack
end
def
receive_pack_disabled_over_http?
!
Gitlab
.
config
.
gitlab_shell
.
receive_pack
end
protected
def
user
...
...
spec/lib/gitlab/git_access_spec.rb
浏览文件 @
e8972c11
...
...
@@ -170,7 +170,7 @@ describe Gitlab::GitAccess, lib: true do
end
context
'when calling git-upload-pack'
do
it
{
expect
{
pull_access_check
}.
to
raise_unauthorized
(
'
The command "git-upload-pack"
is not allowed.'
)
}
it
{
expect
{
pull_access_check
}.
to
raise_unauthorized
(
'
Pulling over HTTP
is not allowed.'
)
}
end
context
'when calling git-receive-pack'
do
...
...
@@ -184,7 +184,7 @@ describe Gitlab::GitAccess, lib: true do
end
context
'when calling git-receive-pack'
do
it
{
expect
{
push_access_check
}.
to
raise_unauthorized
(
'
The command "git-receive-pack"
is not allowed.'
)
}
it
{
expect
{
push_access_check
}.
to
raise_unauthorized
(
'
Pushing over HTTP
is not allowed.'
)
}
end
context
'when calling git-upload-pack'
do
...
...
spec/requests/git_http_spec.rb
浏览文件 @
e8972c11
...
...
@@ -254,7 +254,7 @@ describe 'Git HTTP requests', lib: true do
it
'rejects pushes with 403 Forbidden'
do
upload
(
path
,
env
)
do
|
response
|
expect
(
response
).
to
have_http_status
(
:forbidden
)
expect
(
response
.
body
).
to
eq
(
git_access_error
(
:receive_pack_disabled_
in_config
))
expect
(
response
.
body
).
to
eq
(
git_access_error
(
:receive_pack_disabled_
over_http
))
end
end
end
...
...
@@ -265,7 +265,7 @@ describe 'Git HTTP requests', lib: true do
download
(
path
,
env
)
do
|
response
|
expect
(
response
).
to
have_http_status
(
:forbidden
)
expect
(
response
.
body
).
to
eq
(
git_access_error
(
:upload_pack_disabled_
in_config
))
expect
(
response
.
body
).
to
eq
(
git_access_error
(
:upload_pack_disabled_
over_http
))
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录