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
350cf9f5
Commit
350cf9f5
authored
Nov 16, 2020
by
Mehmet Emin INAC
Committed by
Kerri Miller
Nov 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix undismissed scope
parent
a2bcee1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
ee/app/models/security/finding.rb
ee/app/models/security/finding.rb
+5
-1
ee/spec/models/security/finding_spec.rb
ee/spec/models/security/finding_spec.rb
+12
-5
No files found.
ee/app/models/security/finding.rb
View file @
350cf9f5
...
...
@@ -31,7 +31,11 @@ module Security
scope
:by_confidence_levels
,
->
(
confidence_levels
)
{
where
(
confidence:
confidence_levels
)
}
scope
:by_report_types
,
->
(
report_types
)
{
joins
(
:scan
).
merge
(
Scan
.
by_scan_types
(
report_types
))
}
scope
:undismissed
,
->
do
where
(
'NOT EXISTS (?)'
,
Scan
.
select
(
1
).
has_dismissal_feedback
.
where
(
'vulnerability_feedback.project_fingerprint = security_findings.project_fingerprint'
))
where
(
'NOT EXISTS (?)'
,
Scan
.
select
(
1
)
.
has_dismissal_feedback
.
where
(
'security_scans.id = security_findings.scan_id'
)
.
where
(
'vulnerability_feedback.project_fingerprint = security_findings.project_fingerprint'
))
end
scope
:ordered
,
->
{
order
(
severity: :desc
,
confidence: :desc
,
id: :asc
)
}
scope
:with_build_and_artifacts
,
->
{
includes
(
build: :job_artifacts
)
}
...
...
ee/spec/models/security/finding_spec.rb
View file @
350cf9f5
...
...
@@ -81,9 +81,10 @@ RSpec.describe Security::Finding do
end
describe
'.undismissed'
do
let
(
:scan
)
{
create
(
:security_scan
)
}
let!
(
:undismissed_finding
)
{
create
(
:security_finding
,
scan:
scan
)
}
let!
(
:dismissed_finding
)
{
create
(
:security_finding
,
scan:
scan
)
}
let
(
:scan_1
)
{
create
(
:security_scan
)
}
let
(
:scan_2
)
{
create
(
:security_scan
)
}
let!
(
:undismissed_finding
)
{
create
(
:security_finding
,
scan:
scan_1
)
}
let!
(
:dismissed_finding
)
{
create
(
:security_finding
,
scan:
scan_1
)
}
let
(
:expected_findings
)
{
[
undismissed_finding
]
}
subject
{
described_class
.
undismissed
}
...
...
@@ -91,9 +92,15 @@ RSpec.describe Security::Finding do
before
do
create
(
:vulnerability_feedback
,
:dismissal
,
project:
scan
.
project
,
category:
scan
.
scan_type
,
project:
scan
_1
.
project
,
category:
scan
_1
.
scan_type
,
project_fingerprint:
dismissed_finding
.
project_fingerprint
)
create
(
:vulnerability_feedback
,
:dismissal
,
project:
scan_2
.
project
,
category:
scan_2
.
scan_type
,
project_fingerprint:
undismissed_finding
.
project_fingerprint
)
end
it
{
is_expected
.
to
match_array
(
expected_findings
)
}
...
...
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