Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
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-ce
Commits
405f5f23
Commit
405f5f23
authored
Mar 02, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restrict access to references for confidential issues
parent
52f183ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
12 deletions
+51
-12
lib/banzai/filter/issue_reference_filter.rb
lib/banzai/filter/issue_reference_filter.rb
+17
-3
spec/lib/banzai/filter/redactor_filter_spec.rb
spec/lib/banzai/filter/redactor_filter_spec.rb
+34
-9
No files found.
lib/banzai/filter/issue_reference_filter.rb
View file @
405f5f23
...
@@ -10,14 +10,28 @@ module Banzai
...
@@ -10,14 +10,28 @@ module Banzai
end
end
def
self
.
user_can_see_reference?
(
user
,
node
,
context
)
def
self
.
user_can_see_reference?
(
user
,
node
,
context
)
if
node
.
has_attribute?
(
'data-issue'
)
project
=
Project
.
find
(
node
.
attr
(
'data-project'
))
rescue
nil
issue
=
Issue
.
find
(
node
.
attr
(
'data-issue'
))
rescue
nil
return
unless
project
issue
&&
!
issue
.
confidential?
id
=
node
.
attr
(
'data-issue'
)
issue
=
find_object
(
project
,
id
)
return
unless
issue
if
issue
.
is_a?
(
Issue
)
&&
issue
.
confidential?
Ability
.
abilities
.
allowed?
(
user
,
:read_issue
,
issue
)
else
else
super
super
end
end
end
end
def
self
.
find_object
(
project
,
id
)
if
project
.
default_issues_tracker?
project
.
issues
.
find_by
(
id:
id
)
else
ExternalIssue
.
new
(
id
,
project
)
end
end
def
find_object
(
project
,
id
)
def
find_object
(
project
,
id
)
project
.
get_issue
(
id
)
project
.
get_issue
(
id
)
end
end
...
...
spec/lib/banzai/filter/redactor_filter_spec.rb
View file @
405f5f23
...
@@ -45,23 +45,48 @@ describe Banzai::Filter::RedactorFilter, lib: true do
...
@@ -45,23 +45,48 @@ describe Banzai::Filter::RedactorFilter, lib: true do
end
end
context
'with data-issue'
do
context
'with data-issue'
do
it
'removes references for confidential issues'
do
context
'for confidential issues'
do
user
=
create
(
:user
)
it
'removes references for non project members'
do
project
=
create
(
:empty_project
)
non_member
=
create
(
:user
)
issue
=
create
(
:issue
,
:confidential
,
project:
project
)
project
=
create
(
:empty_project
,
:public
)
issue
=
create
(
:issue
,
:confidential
,
project:
project
)
link
=
reference_link
(
issue:
issue
.
id
,
reference_filter:
'IssueReferenceFilter'
)
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_filter:
'IssueReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
us
er
)
doc
=
filter
(
link
,
current_user:
non_memb
er
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
0
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
0
end
it
'allows references for author'
do
author
=
create
(
:user
)
project
=
create
(
:empty_project
,
:public
)
issue
=
create
(
:issue
,
:confidential
,
project:
project
,
author:
author
)
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_filter:
'IssueReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
author
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
end
it
'allows references for project members'
do
member
=
create
(
:user
)
project
=
create
(
:empty_project
,
:public
)
project
.
team
<<
[
member
,
:developer
]
issue
=
create
(
:issue
,
:confidential
,
project:
project
)
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_filter:
'IssueReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
member
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
end
end
end
it
'allows references for non confidential issues'
do
it
'allows references for non confidential issues'
do
user
=
create
(
:user
)
user
=
create
(
:user
)
project
=
create
(
:empty_project
)
project
=
create
(
:empty_project
,
:public
)
issue
=
create
(
:issue
,
project:
project
)
issue
=
create
(
:issue
,
project:
project
)
link
=
reference_link
(
issue:
issue
.
id
,
reference_filter:
'IssueReferenceFilter'
)
link
=
reference_link
(
project:
project
.
id
,
issue:
issue
.
id
,
reference_filter:
'IssueReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
user
)
doc
=
filter
(
link
,
current_user:
user
)
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
expect
(
doc
.
css
(
'a'
).
length
).
to
eq
1
...
...
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