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
788dceaf
Commit
788dceaf
authored
Aug 13, 2019
by
Cameron Swords
Committed by
Mike Greiling
Aug 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE 10161 hide issuable urls on vulnerability feedback
parent
c5dded9d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
45 deletions
+133
-45
ee/app/assets/javascripts/vue_shared/security_reports/components/modal.vue
...ascripts/vue_shared/security_reports/components/modal.vue
+7
-1
ee/app/serializers/vulnerabilities/feedback_entity.rb
ee/app/serializers/vulnerabilities/feedback_entity.rb
+10
-2
ee/spec/frontend/vue_shared/security_reports/components/modal_spec.js
...tend/vue_shared/security_reports/components/modal_spec.js
+76
-0
ee/spec/serializers/vulnerabilities/feedback_entity_spec.rb
ee/spec/serializers/vulnerabilities/feedback_entity_spec.rb
+40
-42
No files found.
ee/app/assets/javascripts/vue_shared/security_reports/components/modal.vue
View file @
788dceaf
...
@@ -100,9 +100,15 @@ export default {
...
@@ -100,9 +100,15 @@ export default {
issueFeedback
()
{
issueFeedback
()
{
return
this
.
vulnerability
&&
this
.
vulnerability
.
issue_feedback
;
return
this
.
vulnerability
&&
this
.
vulnerability
.
issue_feedback
;
},
},
canReadIssueFeedback
()
{
return
this
.
issueFeedback
&&
this
.
issueFeedback
.
issue_url
;
},
mergeRequestFeedback
()
{
mergeRequestFeedback
()
{
return
this
.
vulnerability
&&
this
.
vulnerability
.
merge_request_feedback
;
return
this
.
vulnerability
&&
this
.
vulnerability
.
merge_request_feedback
;
},
},
canReadMergeRequestFeedback
()
{
return
this
.
mergeRequestFeedback
&&
this
.
mergeRequestFeedback
.
merge_request_path
;
},
dismissalFeedback
()
{
dismissalFeedback
()
{
return
(
return
(
this
.
vulnerability
&&
this
.
vulnerability
&&
...
@@ -204,7 +210,7 @@ export default {
...
@@ -204,7 +210,7 @@ export default {
:vulnerability-feedback-help-path=
"vulnerabilityFeedbackHelpPath"
:vulnerability-feedback-help-path=
"vulnerabilityFeedbackHelpPath"
/>
/>
<ul
v-if=
"
issueFeedback || m
ergeRequestFeedback"
class=
"notes card my-4"
>
<ul
v-if=
"
canReadIssueFeedback || canReadM
ergeRequestFeedback"
class=
"notes card my-4"
>
<li
v-if=
"issueFeedback"
class=
"note"
>
<li
v-if=
"issueFeedback"
class=
"note"
>
<div
class=
"card-body"
>
<div
class=
"card-body"
>
<issue-note
:feedback=
"issueFeedback"
:project=
"project"
/>
<issue-note
:feedback=
"issueFeedback"
:project=
"project"
/>
...
...
ee/app/serializers/vulnerabilities/feedback_entity.rb
View file @
788dceaf
...
@@ -27,7 +27,7 @@ class Vulnerabilities::FeedbackEntity < Grape::Entity
...
@@ -27,7 +27,7 @@ class Vulnerabilities::FeedbackEntity < Grape::Entity
feedback
.
issue
.
iid
feedback
.
issue
.
iid
end
end
expose
:issue_url
,
if:
->
(
feedback
,
_
)
{
feedback
.
issue
.
present
?
}
do
|
feedback
|
expose
:issue_url
,
if:
->
(
_
,
_
)
{
can_read_issue
?
}
do
|
feedback
|
project_issue_url
(
feedback
.
project
,
feedback
.
issue
)
project_issue_url
(
feedback
.
project
,
feedback
.
issue
)
end
end
...
@@ -35,7 +35,7 @@ class Vulnerabilities::FeedbackEntity < Grape::Entity
...
@@ -35,7 +35,7 @@ class Vulnerabilities::FeedbackEntity < Grape::Entity
feedback
.
merge_request
.
iid
feedback
.
merge_request
.
iid
end
end
expose
:merge_request_path
,
if:
->
(
feedback
,
_
)
{
feedback
.
merge_request
.
presen
t?
}
do
|
feedback
|
expose
:merge_request_path
,
if:
->
(
_
,
_
)
{
can_read_merge_reques
t?
}
do
|
feedback
|
project_merge_request_path
(
feedback
.
project
,
feedback
.
merge_request
)
project_merge_request_path
(
feedback
.
project
,
feedback
.
merge_request
)
end
end
...
@@ -59,4 +59,12 @@ class Vulnerabilities::FeedbackEntity < Grape::Entity
...
@@ -59,4 +59,12 @@ class Vulnerabilities::FeedbackEntity < Grape::Entity
def
can_destroy_feedback?
def
can_destroy_feedback?
can?
(
request
.
current_user
,
:destroy_vulnerability_feedback
,
feedback
)
can?
(
request
.
current_user
,
:destroy_vulnerability_feedback
,
feedback
)
end
end
def
can_read_issue?
feedback
.
issue
.
present?
&&
can?
(
request
.
current_user
,
:read_issue
,
feedback
.
issue
)
end
def
can_read_merge_request?
feedback
.
merge_request
.
present?
&&
can?
(
request
.
current_user
,
:read_merge_request
,
feedback
.
merge_request
)
end
end
end
ee/spec/frontend/vue_shared/security_reports/components/modal_spec.js
View file @
788dceaf
...
@@ -128,6 +128,82 @@ describe('Security Reports modal', () => {
...
@@ -128,6 +128,82 @@ describe('Security Reports modal', () => {
});
});
});
});
describe
(
'
related issue read access
'
,
()
=>
{
describe
(
'
with permission to read
'
,
()
=>
{
beforeEach
(()
=>
{
const
propsData
=
{
modal
:
createState
().
modal
,
};
propsData
.
modal
.
vulnerability
.
issue_feedback
=
{
issue_url
:
'
http://issue.url
'
,
};
wrapper
=
shallowMount
(
Component
,
{
propsData
});
});
it
(
'
displays a link to the issue
'
,
()
=>
{
const
notes
=
wrapper
.
find
(
'
.notes
'
);
expect
(
notes
.
exists
()).
toBe
(
true
);
});
});
describe
(
'
without permission to read
'
,
()
=>
{
beforeEach
(()
=>
{
const
propsData
=
{
modal
:
createState
().
modal
,
};
propsData
.
modal
.
vulnerability
.
issue_feedback
=
{
issue_url
:
null
,
};
wrapper
=
shallowMount
(
Component
,
{
propsData
});
});
it
(
'
hides the link to the issue
'
,
()
=>
{
const
notes
=
wrapper
.
find
(
'
.notes
'
);
expect
(
notes
.
exists
()).
toBe
(
false
);
});
});
});
describe
(
'
related merge request read access
'
,
()
=>
{
describe
(
'
with permission to read
'
,
()
=>
{
beforeEach
(()
=>
{
const
propsData
=
{
modal
:
createState
().
modal
,
};
propsData
.
modal
.
vulnerability
.
merge_request_feedback
=
{
merge_request_path
:
'
http://mr.url
'
,
};
wrapper
=
shallowMount
(
Component
,
{
propsData
});
});
it
(
'
displays a link to the merge request
'
,
()
=>
{
const
notes
=
wrapper
.
find
(
'
.notes
'
);
expect
(
notes
.
exists
()).
toBe
(
true
);
});
});
describe
(
'
without permission to read
'
,
()
=>
{
beforeEach
(()
=>
{
const
propsData
=
{
modal
:
createState
().
modal
,
};
propsData
.
modal
.
vulnerability
.
merge_request_feedback
=
{
merge_request_path
:
null
,
};
wrapper
=
shallowMount
(
Component
,
{
propsData
});
});
it
(
'
hides the link to the merge request
'
,
()
=>
{
const
notes
=
wrapper
.
find
(
'
.notes
'
);
expect
(
notes
.
exists
()).
toBe
(
false
);
});
});
});
describe
(
'
with a resolved issue
'
,
()
=>
{
describe
(
'
with a resolved issue
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
const
propsData
=
{
const
propsData
=
{
...
...
ee/spec/serializers/vulnerabilities/feedback_entity_spec.rb
View file @
788dceaf
...
@@ -22,9 +22,26 @@ describe Vulnerabilities::FeedbackEntity do
...
@@ -22,9 +22,26 @@ describe Vulnerabilities::FeedbackEntity do
context
'feedback type is issue'
do
context
'feedback type is issue'
do
let
(
:feedback
)
{
build
(
:vulnerability_feedback
,
:issue
,
project:
project
)
}
let
(
:feedback
)
{
build
(
:vulnerability_feedback
,
:issue
,
project:
project
)
}
it
'exposes issue information'
do
context
'when issue is present'
do
is_expected
.
to
include
(
:issue_iid
)
it
'exposes the issue iid'
do
is_expected
.
to
include
(
:issue_url
)
is_expected
.
to
include
(
:issue_iid
)
end
context
'when user can view issues'
do
before
do
project
.
add_developer
(
user
)
end
it
'exposes issue url'
do
is_expected
.
to
include
(
:issue_url
)
end
end
context
'when user cannot view issues'
do
it
'does not expose issue url'
do
is_expected
.
not_to
include
(
:issue_url
)
end
end
end
end
context
'when issue is not present'
do
context
'when issue is not present'
do
...
@@ -50,9 +67,26 @@ describe Vulnerabilities::FeedbackEntity do
...
@@ -50,9 +67,26 @@ describe Vulnerabilities::FeedbackEntity do
context
'feedback type is merge_request'
do
context
'feedback type is merge_request'
do
let
(
:feedback
)
{
build
(
:vulnerability_feedback
,
:merge_request
,
project:
project
)
}
let
(
:feedback
)
{
build
(
:vulnerability_feedback
,
:merge_request
,
project:
project
)
}
it
'exposes merge request information'
do
context
'when merge request is present'
do
is_expected
.
to
include
(
:merge_request_iid
)
it
'exposes the merge request iid'
do
is_expected
.
to
include
(
:merge_request_path
)
is_expected
.
to
include
(
:merge_request_iid
)
end
context
'when user can view merge requests'
do
before
do
project
.
add_developer
(
user
)
end
it
'exposes merge request url'
do
is_expected
.
to
include
(
:merge_request_path
)
end
end
context
'when user cannot view merge requests'
do
it
'does not expose merge request url'
do
is_expected
.
not_to
include
(
:merge_request_path
)
end
end
end
end
context
'when merge request is not present'
do
context
'when merge request is not present'
do
...
@@ -116,40 +150,4 @@ describe Vulnerabilities::FeedbackEntity do
...
@@ -116,40 +150,4 @@ describe Vulnerabilities::FeedbackEntity do
expect
(
subject
[
:comment_details
]).
to
include
(
:comment_author
)
expect
(
subject
[
:comment_details
]).
to
include
(
:comment_author
)
end
end
end
end
context
'when issue is present'
do
let
(
:feedback
)
{
build
(
:vulnerability_feedback
,
:issue
)
}
it
'exposes issue information'
do
is_expected
.
to
include
(
:issue_iid
)
is_expected
.
to
include
(
:issue_url
)
end
end
context
'when issue is not present'
do
let
(
:feedback
)
{
build
(
:vulnerability_feedback
,
feedback_type:
'issue'
,
issue:
nil
)
}
it
'does not expose issue information'
do
is_expected
.
not_to
include
(
:issue_iid
)
is_expected
.
not_to
include
(
:issue_url
)
end
end
context
'when merge request is present'
do
let
(
:feedback
)
{
build
(
:vulnerability_feedback
,
:merge_request
)
}
it
'exposes merge request information'
do
is_expected
.
to
include
(
:merge_request_iid
)
is_expected
.
to
include
(
:merge_request_path
)
end
end
context
'when merge request is not present'
do
let
(
:feedback
)
{
build
(
:vulnerability_feedback
,
feedback_type:
'merge_request'
,
merge_request:
nil
)
}
it
'does not expose merge request information'
do
is_expected
.
not_to
include
(
:merge_request_iid
)
is_expected
.
not_to
include
(
:merge_request_path
)
end
end
end
end
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