Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
710cd82c
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,发现更多精彩内容 >>
提交
710cd82c
编写于
4月 05, 2017
作者:
R
Rémy Coutable
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Set Git-specific env in /api/internal/allowed
Signed-off-by:
N
Rémy Coutable
<
remy@rymai.me
>
上级
05aa038c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
20 deletion
+31
-20
lib/api/helpers/internal_helpers.rb
lib/api/helpers/internal_helpers.rb
+3
-3
lib/api/internal.rb
lib/api/internal.rb
+9
-15
spec/requests/api/internal_spec.rb
spec/requests/api/internal_spec.rb
+19
-2
未找到文件。
lib/api/helpers/internal_helpers.rb
浏览文件 @
710cd82c
...
...
@@ -53,12 +53,12 @@ module API
]
end
def
parse_
allowed_environment_variables
return
if
params
[
:env
].
blank?
def
parse_
env
return
{}
if
params
[
:env
].
blank?
JSON
.
parse
(
params
[
:env
])
rescue
JSON
::
ParserError
{}
end
end
end
...
...
lib/api/internal.rb
浏览文件 @
710cd82c
...
...
@@ -11,14 +11,16 @@ module API
# Params:
# key_id - ssh key id for Git over SSH
# user_id - user id for Git over HTTP
# protocol - Git access protocol being used, e.g. HTTP or SSH
# project - project path with namespace
# action - git action (git-upload-pack or git-receive-pack)
# ref - branch name
# forced_push - forced_push
# protocol - Git access protocol being used, e.g. HTTP or SSH
# changes - changes as "oldrev newrev ref", see Gitlab::ChangesList
post
"/allowed"
do
status
200
# Stores some Git-specific env thread-safely
Gitlab
::
Git
::
Env
.
set
(
parse_env
)
actor
=
if
params
[
:key_id
]
Key
.
find_by
(
id:
params
[
:key_id
])
...
...
@@ -30,18 +32,10 @@ module API
actor
.
update_last_used_at
if
actor
.
is_a?
(
Key
)
access
=
if
wiki?
Gitlab
::
GitAccessWiki
.
new
(
actor
,
project
,
protocol
,
authentication_abilities:
ssh_authentication_abilities
)
else
Gitlab
::
GitAccess
.
new
(
actor
,
project
,
protocol
,
authentication_abilities:
ssh_authentication_abilities
,
env:
parse_allowed_environment_variables
)
end
access_status
=
access
.
check
(
params
[
:action
],
params
[
:changes
])
access_checker
=
wiki?
?
Gitlab
::
GitAccessWiki
:
Gitlab
::
GitAccess
access_status
=
access_checker
.
new
(
actor
,
project
,
protocol
,
authentication_abilities:
ssh_authentication_abilities
)
.
check
(
params
[
:action
],
params
[
:changes
])
response
=
{
status:
access_status
.
status
,
message:
access_status
.
message
}
...
...
spec/requests/api/internal_spec.rb
浏览文件 @
710cd82c
...
...
@@ -153,6 +153,22 @@ describe API::Internal, api: true do
project
.
team
<<
[
user
,
:developer
]
end
context
'with env passed as a JSON'
do
it
'sets env in RequestStore'
do
expect
(
Gitlab
::
Git
::
Env
).
to
receive
(
:set
).
with
({
'GIT_OBJECT_DIRECTORY'
=>
'foo'
,
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
=>
'bar'
})
push
(
key
,
project
.
wiki
,
env:
{
GIT_OBJECT_DIRECTORY
:
'foo'
,
GIT_ALTERNATE_OBJECT_DIRECTORIES
:
'bar'
}.
to_json
)
expect
(
response
).
to
have_http_status
(
200
)
end
end
context
"git push with project.wiki"
do
it
'responds with success'
do
push
(
key
,
project
.
wiki
)
...
...
@@ -463,7 +479,7 @@ describe API::Internal, api: true do
)
end
def
push
(
key
,
project
,
protocol
=
'ssh'
)
def
push
(
key
,
project
,
protocol
=
'ssh'
,
env:
nil
)
post
(
api
(
"/internal/allowed"
),
changes:
'd14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master'
,
...
...
@@ -471,7 +487,8 @@ describe API::Internal, api: true do
project:
project
.
repository
.
path_to_repo
,
action:
'git-receive-pack'
,
secret_token:
secret_token
,
protocol:
protocol
protocol:
protocol
,
env:
env
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录