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
6775a749
Commit
6775a749
authored
Mar 12, 2020
by
Michał Zając
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add #project_default_branch to Vulnerability
parent
4ab27275
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
3 deletions
+14
-3
ee/app/models/vulnerability.rb
ee/app/models/vulnerability.rb
+3
-2
ee/lib/ee/api/entities/vulnerability.rb
ee/lib/ee/api/entities/vulnerability.rb
+1
-0
ee/spec/models/vulnerability_spec.rb
ee/spec/models/vulnerability_spec.rb
+9
-0
tooling/overcommit/Gemfile.lock
tooling/overcommit/Gemfile.lock
+1
-1
No files found.
ee/app/models/vulnerability.rb
View file @
6775a749
...
...
@@ -60,6 +60,8 @@ class Vulnerability < ApplicationRecord
scope
:with_severities
,
->
(
severities
)
{
where
(
severity:
severities
)
}
scope
:with_states
,
->
(
states
)
{
where
(
state:
states
)
}
delegate
:default_branch
,
to: :project
,
prefix: :project
# There will only be one finding associated with a vulnerability for the foreseeable future
def
finding
findings
.
first
...
...
@@ -72,8 +74,7 @@ class Vulnerability < ApplicationRecord
end
def
resolved_on_default_branch
default_branch
=
project
.
default_branch
latest_pipeline_for_default_branch
=
project
.
pipeline_for
(
default_branch
)
latest_pipeline_for_default_branch
=
project
.
pipeline_for
(
project_default_branch
)
latest_pipeline_with_vulnerability
=
finding
.
pipelines
.
order
(
created_at: :desc
).
first
latest_pipeline_with_vulnerability
!=
latest_pipeline_for_default_branch
end
...
...
ee/lib/ee/api/entities/vulnerability.rb
View file @
6775a749
...
...
@@ -17,6 +17,7 @@ module EE
expose
:finding
expose
:resolved_on_default_branch
expose
:project_default_branch
expose
:author_id
expose
:updated_by_id
...
...
ee/spec/models/vulnerability_spec.rb
View file @
6775a749
...
...
@@ -172,6 +172,15 @@ describe Vulnerability do
it
{
is_expected
.
to
eq
(
finding
.
scanner_name
)
}
end
describe
'#project_default_branch'
do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:with_vulnerabilities
)
}
let_it_be
(
:vulnerability
)
{
project
.
vulnerabilities
.
first
}
subject
{
vulnerability
.
project_default_branch
}
it
{
is_expected
.
to
eq
(
"master"
)
}
end
describe
'#resolved_on_default_branch'
do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
,
:with_vulnerabilities
)
}
let_it_be
(
:pipeline_with_vulnerability
)
{
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
)
}
...
...
tooling/overcommit/Gemfile.lock
View file @
6775a749
...
...
@@ -72,4 +72,4 @@ DEPENDENCIES
scss_lint (~> 0.56.0)
BUNDLED WITH
1.17.3
2.1.4
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