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
d1015036
Commit
d1015036
authored
May 07, 2019
by
rossfuhrman
Committed by
Mayra Cabrera
May 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Query was duplicating results
This query was duplicating results due to a bad join.
parent
2d73fd0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
ee/app/models/vulnerabilities/occurrence.rb
ee/app/models/vulnerabilities/occurrence.rb
+2
-2
ee/spec/models/group_spec.rb
ee/spec/models/group_spec.rb
+8
-3
No files found.
ee/app/models/vulnerabilities/occurrence.rb
View file @
d1015036
...
@@ -85,8 +85,8 @@ module Vulnerabilities
...
@@ -85,8 +85,8 @@ module Vulnerabilities
end
end
def
self
.
for_pipelines_with_sha
(
pipelines
)
def
self
.
for_pipelines_with_sha
(
pipelines
)
for_pipelines
(
pipelines
)
joins
(
:
pipelines
)
.
joins
(
:pipelines
)
.
where
(
ci_pipelines:
{
id:
pipelines
}
)
.
select
(
"vulnerability_occurrences.*, ci_pipelines.sha"
)
.
select
(
"vulnerability_occurrences.*, ci_pipelines.sha"
)
end
end
...
...
ee/spec/models/group_spec.rb
View file @
d1015036
...
@@ -289,7 +289,7 @@ describe Group do
...
@@ -289,7 +289,7 @@ describe Group do
end
end
describe
'Vulnerabilities::Occurrence collection methods'
do
describe
'Vulnerabilities::Occurrence collection methods'
do
describe
'
#latest_vulnerabilitie
s'
do
describe
'
vulnerabilities finder method
s'
do
let
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
let
(
:external_project
)
{
create
(
:project
)
}
let
(
:external_project
)
{
create
(
:project
)
}
let
(
:failed_pipeline
)
{
create
(
:ci_pipeline
,
:failed
,
project:
project
)
}
let
(
:failed_pipeline
)
{
create
(
:ci_pipeline
,
:failed
,
project:
project
)
}
...
@@ -299,6 +299,11 @@ describe Group do
...
@@ -299,6 +299,11 @@ describe Group do
let!
(
:external_vuln
)
{
create_vulnerability
(
external_project
)
}
let!
(
:external_vuln
)
{
create_vulnerability
(
external_project
)
}
let!
(
:failed_vuln
)
{
create_vulnerability
(
project
,
failed_pipeline
)
}
let!
(
:failed_vuln
)
{
create_vulnerability
(
project
,
failed_pipeline
)
}
before
do
pipeline_ran_against_new_sha
=
create
(
:ci_pipeline
,
:success
,
project:
project
,
sha:
'123'
)
new_vuln
.
pipelines
<<
pipeline_ran_against_new_sha
end
def
create_vulnerability
(
project
,
pipeline
=
nil
)
def
create_vulnerability
(
project
,
pipeline
=
nil
)
pipeline
||=
create
(
:ci_pipeline
,
:success
,
project:
project
)
pipeline
||=
create
(
:ci_pipeline
,
:success
,
project:
project
)
create
(
:vulnerabilities_occurrence
,
pipelines:
[
pipeline
],
project:
project
)
create
(
:vulnerabilities_occurrence
,
pipelines:
[
pipeline
],
project:
project
)
...
@@ -350,7 +355,7 @@ describe Group do
...
@@ -350,7 +355,7 @@ describe Group do
subject
{
group
.
all_vulnerabilities
}
subject
{
group
.
all_vulnerabilities
}
it
'returns vulns for all successful pipelines of projects belonging to the group'
do
it
'returns vulns for all successful pipelines of projects belonging to the group'
do
is_expected
.
to
contain_exactly
(
old_vuln
,
new_vuln
)
is_expected
.
to
contain_exactly
(
old_vuln
,
new_vuln
,
new_vuln
)
end
end
context
'with vulnerabilities from other branches'
do
context
'with vulnerabilities from other branches'
do
...
@@ -361,7 +366,7 @@ describe Group do
...
@@ -361,7 +366,7 @@ describe Group do
# per branch as soon as we store them for other branches
# per branch as soon as we store them for other branches
# Dependent on https://gitlab.com/gitlab-org/gitlab-ee/issues/9524
# Dependent on https://gitlab.com/gitlab-org/gitlab-ee/issues/9524
it
'includes vulnerabilities from all branches'
do
it
'includes vulnerabilities from all branches'
do
is_expected
.
to
contain_exactly
(
old_vuln
,
new_vuln
,
branch_vuln
)
is_expected
.
to
contain_exactly
(
old_vuln
,
new_vuln
,
new_vuln
,
branch_vuln
)
end
end
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