Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
a3cde026
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,发现更多精彩内容 >>
未验证
提交
a3cde026
编写于
12月 21, 2018
作者:
J
James Lopez
提交者:
Yorick Peterse
1月 31, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix contributed projects finder shown private info
上级
57f082d9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
0 deletion
+56
-0
app/finders/contributed_projects_finder.rb
app/finders/contributed_projects_finder.rb
+7
-0
changelogs/unreleased/security-contributed-projects.yml
changelogs/unreleased/security-contributed-projects.yml
+5
-0
spec/controllers/users_controller_spec.rb
spec/controllers/users_controller_spec.rb
+32
-0
spec/finders/contributed_projects_finder_spec.rb
spec/finders/contributed_projects_finder_spec.rb
+12
-0
未找到文件。
app/finders/contributed_projects_finder.rb
浏览文件 @
a3cde026
...
...
@@ -14,6 +14,9 @@ class ContributedProjectsFinder < UnionFinder
# Returns an ActiveRecord::Relation.
# rubocop: disable CodeReuse/ActiveRecord
def
execute
(
current_user
=
nil
)
# Do not show contributed projects if the user profile is private.
return
Project
.
none
unless
can_read_profile?
(
current_user
)
segments
=
all_projects
(
current_user
)
find_union
(
segments
,
Project
).
includes
(
:namespace
).
order_id_desc
...
...
@@ -22,6 +25,10 @@ class ContributedProjectsFinder < UnionFinder
private
def
can_read_profile?
(
current_user
)
Ability
.
allowed?
(
current_user
,
:read_user_profile
,
@user
)
end
def
all_projects
(
current_user
)
projects
=
[]
...
...
changelogs/unreleased/security-contributed-projects.yml
0 → 100644
浏览文件 @
a3cde026
---
title
:
Fix contributed projects info still visible when user enable private profile
merge_request
:
author
:
type
:
security
spec/controllers/users_controller_spec.rb
浏览文件 @
a3cde026
...
...
@@ -206,6 +206,38 @@ describe UsersController do
end
end
describe
'GET #contributed'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:current_user
)
{
create
(
:user
)
}
before
do
sign_in
(
current_user
)
project
.
add_developer
(
public_user
)
project
.
add_developer
(
private_user
)
end
context
'with public profile'
do
it
'renders contributed projects'
do
create
(
:push_event
,
project:
project
,
author:
public_user
)
get
:contributed
,
params:
{
username:
public_user
.
username
}
expect
(
assigns
[
:contributed_projects
]).
not_to
be_empty
end
end
context
'with private profile'
do
it
'does not render contributed projects'
do
create
(
:push_event
,
project:
project
,
author:
private_user
)
get
:contributed
,
params:
{
username:
private_user
.
username
}
expect
(
assigns
[
:contributed_projects
]).
to
be_empty
end
end
end
describe
'GET #snippets'
do
before
do
sign_in
(
user
)
...
...
spec/finders/contributed_projects_finder_spec.rb
浏览文件 @
a3cde026
...
...
@@ -31,4 +31,16 @@ describe ContributedProjectsFinder do
it
{
is_expected
.
to
match_array
([
private_project
,
internal_project
,
public_project
])
}
end
context
'user with private profile'
do
it
'does not return contributed projects'
do
private_user
=
create
(
:user
,
private_profile:
true
)
public_project
.
add_maintainer
(
private_user
)
create
(
:push_event
,
project:
public_project
,
author:
private_user
)
projects
=
described_class
.
new
(
private_user
).
execute
(
current_user
)
expect
(
projects
).
to
be_empty
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录