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
17a069ae
Commit
17a069ae
authored
Aug 19, 2020
by
Jonathan Schafer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove elements from base json file
Use base file and remove elements for invalid data
parent
b24538af
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
692 deletions
+11
-692
ee/app/services/security/store_report_service.rb
ee/app/services/security/store_report_service.rb
+1
-0
ee/spec/factories/ci/job_artifacts.rb
ee/spec/factories/ci/job_artifacts.rb
+6
-2
ee/spec/fixtures/security_reports/master/gl-sast-missing-identifiers.json
.../security_reports/master/gl-sast-missing-identifiers.json
+0
-686
ee/spec/services/security/store_report_service_spec.rb
ee/spec/services/security/store_report_service_spec.rb
+4
-4
No files found.
ee/app/services/security/store_report_service.rb
View file @
17a069ae
...
@@ -17,6 +17,7 @@ module Security
...
@@ -17,6 +17,7 @@ module Security
def
execute
def
execute
# Ensure we're not trying to insert data twice for this report
# Ensure we're not trying to insert data twice for this report
return
error
(
"
#{
@report
.
type
}
report already stored for this pipeline, skipping..."
)
if
executed?
return
error
(
"
#{
@report
.
type
}
report already stored for this pipeline, skipping..."
)
if
executed?
raise
ParseError
,
'JSON parsing failed'
if
report
.
error
.
is_a?
(
Gitlab
::
Ci
::
Parsers
::
Security
::
Common
::
SecurityReportParserError
)
vulnerability_ids
=
create_all_vulnerabilities!
vulnerability_ids
=
create_all_vulnerabilities!
mark_as_resolved_except
(
vulnerability_ids
)
mark_as_resolved_except
(
vulnerability_ids
)
...
...
ee/spec/factories/ci/job_artifacts.rb
View file @
17a069ae
...
@@ -184,8 +184,12 @@ FactoryBot.define do
...
@@ -184,8 +184,12 @@ FactoryBot.define do
file_format
{
:raw
}
file_format
{
:raw
}
after
(
:build
)
do
|
artifact
,
_
|
after
(
:build
)
do
|
artifact
,
_
|
artifact
.
file
=
fixture_file_upload
(
file
=
fixture_file_upload
(
Rails
.
root
.
join
(
'ee/spec/fixtures/security_reports/master/gl-sast-missing-identifiers.json'
),
'application/json'
)
Rails
.
root
.
join
(
'ee/spec/fixtures/security_reports/master/gl-sast-report.json'
),
'application/json'
)
data
=
Gitlab
::
Json
.
parse
(
file
.
tempfile
.
read
)[
'vulnerabilities'
].
each
{
|
v
|
v
.
delete
(
'identifiers'
)
}.
to_json
output
=
Tempfile
.
new
(
"gl-sast-missing-identifiers"
)
output
.
write
(
data
)
artifact
.
file
=
fixture_file_upload
(
output
.
path
,
'application/json'
)
end
end
end
end
...
...
ee/spec/fixtures/security_reports/master/gl-sast-missing-identifiers.json
deleted
100644 → 0
View file @
b24538af
This diff is collapsed.
Click to expand it.
ee/spec/services/security/store_report_service_spec.rb
View file @
17a069ae
...
@@ -205,14 +205,14 @@ RSpec.describe Security::StoreReportService, '#execute' do
...
@@ -205,14 +205,14 @@ RSpec.describe Security::StoreReportService, '#execute' do
end
end
context
'when the finding does not include a primary identifier'
do
context
'when the finding does not include a primary identifier'
do
let
(
:bad_p
ipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:bad_p
roject
)
{
bad_artifact
.
project
}
let
(
:bad_
build
)
{
create
(
:ci_build
,
pipeline:
bad_pipeline
)
}
let
(
:bad_
pipeline
)
{
bad_artifact
.
job
.
pipeline
}
let!
(
:bad_artifact
)
{
create
(
:ee_ci_job_artifact
,
:sast_with_missing_identifiers
,
job:
bad_build
)
}
let!
(
:bad_artifact
)
{
create
(
:ee_ci_job_artifact
,
:sast_with_missing_identifiers
)
}
let
(
:bad_report
)
{
bad_pipeline
.
security_reports
.
get_report
(
report_type
.
to_s
,
bad_artifact
)
}
let
(
:bad_report
)
{
bad_pipeline
.
security_reports
.
get_report
(
report_type
.
to_s
,
bad_artifact
)
}
let
(
:report_type
)
{
:sast
}
let
(
:report_type
)
{
:sast
}
before
do
before
do
project
.
add_developer
(
user
)
bad_
project
.
add_developer
(
user
)
allow
(
bad_pipeline
).
to
receive
(
:user
).
and_return
(
user
)
allow
(
bad_pipeline
).
to
receive
(
:user
).
and_return
(
user
)
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