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
6a14394d
Commit
6a14394d
authored
Apr 16, 2020
by
can eldem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log parameters when saving invalid occurrence
parent
61cdcb8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
ee/app/services/security/store_report_service.rb
ee/app/services/security/store_report_service.rb
+2
-0
ee/spec/services/security/store_report_service_spec.rb
ee/spec/services/security/store_report_service_spec.rb
+22
-0
No files found.
ee/app/services/security/store_report_service.rb
View file @
6a14394d
...
@@ -65,6 +65,8 @@ module Security
...
@@ -65,6 +65,8 @@ module Security
.
find_or_create_by!
(
find_params
)
.
find_or_create_by!
(
find_params
)
rescue
ActiveRecord
::
RecordNotUnique
rescue
ActiveRecord
::
RecordNotUnique
project
.
vulnerability_findings
.
find_by!
(
find_params
)
project
.
vulnerability_findings
.
find_by!
(
find_params
)
rescue
ActiveRecord
::
RecordInvalid
=>
e
Gitlab
::
ErrorTracking
.
track_and_raise_exception
(
e
,
create_params:
create_params
&
.
dig
(
:raw_metadata
))
end
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
...
ee/spec/services/security/store_report_service_spec.rb
View file @
6a14394d
...
@@ -54,6 +54,28 @@ describe Security::StoreReportService, '#execute' do
...
@@ -54,6 +54,28 @@ describe Security::StoreReportService, '#execute' do
expect
{
subject
}.
to
change
{
Vulnerability
.
count
}.
by
(
occurrences
)
expect
{
subject
}.
to
change
{
Vulnerability
.
count
}.
by
(
occurrences
)
end
end
end
end
context
'invalid data'
do
let
(
:artifact
)
{
create
(
:ee_ci_job_artifact
,
:sast
)
}
let
(
:occurrence_without_name
)
{
build
(
:ci_reports_security_occurrence
,
name:
nil
)
}
let
(
:report
)
{
Gitlab
::
Ci
::
Reports
::
Security
::
Report
.
new
(
'container_scanning'
,
nil
,
nil
)
}
before
do
allow
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_and_raise_exception
).
and_call_original
report
.
add_occurrence
(
occurrence_without_name
)
end
it
'raises invalid record error'
do
expect
{
subject
.
execute
}.
to
raise_error
(
ActiveRecord
::
RecordInvalid
)
end
it
'reports the error correctly'
do
expected_params
=
occurrence_without_name
.
to_hash
.
dig
(
:raw_metadata
)
expect
{
subject
.
execute
}.
to
raise_error
{
|
error
|
expect
(
Gitlab
::
ErrorTracking
).
to
have_received
(
:track_and_raise_exception
).
with
(
error
,
create_params:
expected_params
)
}
end
end
end
end
context
'with existing data from previous pipeline'
do
context
'with existing data from previous pipeline'
do
...
...
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