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
a46ebf01
Commit
a46ebf01
authored
Feb 10, 2021
by
saikat sarkar
Committed by
Peter Leitzen
Feb 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move sast_reports and secret_detection_reports to CE [RUN AS-IF-FOSS]
parent
c997203d
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
237 additions
and
132 deletions
+237
-132
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+8
-0
app/models/ci/job_artifact.rb
app/models/ci/job_artifact.rb
+10
-0
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+10
-0
app/models/merge_request.rb
app/models/merge_request.rb
+35
-0
app/serializers/merge_request_widget_entity.rb
app/serializers/merge_request_widget_entity.rb
+4
-0
ee/app/controllers/ee/projects/merge_requests_controller.rb
ee/app/controllers/ee/projects/merge_requests_controller.rb
+0
-8
ee/app/models/ee/ci/job_artifact.rb
ee/app/models/ee/ci/job_artifact.rb
+0
-10
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+0
-10
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+0
-28
ee/app/serializers/ee/merge_request_widget_entity.rb
ee/app/serializers/ee/merge_request_widget_entity.rb
+0
-4
ee/changelogs/unreleased/move_methods.yml
ee/changelogs/unreleased/move_methods.yml
+5
-0
ee/spec/factories/ci/job_artifacts.rb
ee/spec/factories/ci/job_artifacts.rb
+2
-2
ee/spec/factories/merge_requests.rb
ee/spec/factories/merge_requests.rb
+0
-24
ee/spec/lib/gitlab/ci/parsers/security/dependency_scanning_spec.rb
...ib/gitlab/ci/parsers/security/dependency_scanning_spec.rb
+2
-2
ee/spec/models/merge_request_spec.rb
ee/spec/models/merge_request_spec.rb
+1
-44
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+18
-0
spec/factories/ci/job_artifacts.rb
spec/factories/ci/job_artifacts.rb
+20
-0
spec/factories/ci/pipelines.rb
spec/factories/ci/pipelines.rb
+24
-0
spec/factories/merge_requests.rb
spec/factories/merge_requests.rb
+24
-0
spec/fixtures/security_reports/master/gl-sast-report.json
spec/fixtures/security_reports/master/gl-sast-report.json
+0
-0
spec/fixtures/security_reports/master/gl-secret-detection-report.json
...s/security_reports/master/gl-secret-detection-report.json
+0
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+74
-0
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
a46ebf01
...
...
@@ -168,6 +168,14 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
}
end
def
sast_reports
reports_response
(
merge_request
.
compare_sast_reports
(
current_user
),
head_pipeline
)
end
def
secret_detection_reports
reports_response
(
merge_request
.
compare_secret_detection_reports
(
current_user
),
head_pipeline
)
end
def
context_commits
return
render_404
unless
project
.
context_commits_enabled?
...
...
app/models/ci/job_artifact.rb
View file @
a46ebf01
...
...
@@ -19,6 +19,8 @@ module Ci
NON_ERASABLE_FILE_TYPES
=
%w[trace]
.
freeze
TERRAFORM_REPORT_FILE_TYPES
=
%w[terraform]
.
freeze
UNSUPPORTED_FILE_TYPES
=
%i[license_management]
.
freeze
SAST_REPORT_TYPES
=
%w[sast]
.
freeze
SECRET_DETECTION_REPORT_TYPES
=
%w[secret_detection]
.
freeze
DEFAULT_FILE_NAMES
=
{
archive:
nil
,
metadata:
nil
,
...
...
@@ -150,6 +152,14 @@ module Ci
with_file_types
(
REPORT_TYPES
.
keys
.
map
(
&
:to_s
))
end
scope
:sast_reports
,
->
do
with_file_types
(
SAST_REPORT_TYPES
)
end
scope
:secret_detection_reports
,
->
do
with_file_types
(
SECRET_DETECTION_REPORT_TYPES
)
end
scope
:test_reports
,
->
do
with_file_types
(
TEST_REPORT_FILE_TYPES
)
end
...
...
app/models/ci/pipeline.rb
View file @
a46ebf01
...
...
@@ -1219,6 +1219,16 @@ module Ci
false
end
def
security_reports
(
report_types:
[])
reports_scope
=
report_types
.
empty?
?
::
Ci
::
JobArtifact
.
security_reports
:
::
Ci
::
JobArtifact
.
security_reports
(
file_types:
report_types
)
::
Gitlab
::
Ci
::
Reports
::
Security
::
Reports
.
new
(
self
).
tap
do
|
security_reports
|
latest_report_builds
(
reports_scope
).
each
do
|
build
|
build
.
collect_security_reports!
(
security_reports
)
end
end
end
private
def
add_message
(
severity
,
content
)
...
...
app/models/merge_request.rb
View file @
a46ebf01
...
...
@@ -1554,6 +1554,26 @@ class MergeRequest < ApplicationRecord
end
||
{
status: :parsing
}
end
def
has_sast_reports?
!!
actual_head_pipeline
&
.
has_reports?
(
::
Ci
::
JobArtifact
.
sast_reports
)
end
def
has_secret_detection_reports?
!!
actual_head_pipeline
&
.
has_reports?
(
::
Ci
::
JobArtifact
.
secret_detection_reports
)
end
def
compare_sast_reports
(
current_user
)
return
missing_report_error
(
"SAST"
)
unless
has_sast_reports?
compare_reports
(
::
Ci
::
CompareSecurityReportsService
,
current_user
,
'sast'
)
end
def
compare_secret_detection_reports
(
current_user
)
return
missing_report_error
(
"secret detection"
)
unless
has_secret_detection_reports?
compare_reports
(
::
Ci
::
CompareSecurityReportsService
,
current_user
,
'secret_detection'
)
end
def
calculate_reactive_cache
(
identifier
,
current_user_id
=
nil
,
report_type
=
nil
,
*
args
)
service_class
=
identifier
.
constantize
...
...
@@ -1799,8 +1819,19 @@ class MergeRequest < ApplicationRecord
merge_request_reviewers
.
find_by
(
user_id:
user
.
id
)
end
def
enabled_reports
{
sast:
report_type_enabled?
(
:sast
),
secret_detection:
report_type_enabled?
(
:secret_detection
)
}
end
private
def
missing_report_error
(
report_type
)
{
status: :error
,
status_reason:
"This merge request does not have
#{
report_type
}
reports"
}
end
def
with_rebase_lock
if
Feature
.
enabled?
(
:merge_request_rebase_nowait_lock
,
default_enabled:
true
)
with_retried_nowait_lock
{
yield
}
...
...
@@ -1842,6 +1873,10 @@ class MergeRequest < ApplicationRecord
key
=
Gitlab
::
Routing
.
url_helpers
.
cached_widget_project_json_merge_request_path
(
project
,
self
,
format: :json
)
Gitlab
::
EtagCaching
::
Store
.
new
.
touch
(
key
)
end
def
report_type_enabled?
(
report_type
)
!!
actual_head_pipeline
&
.
batch_lookup_report_artifact_for_file_type
(
report_type
)
end
end
MergeRequest
.
prepend_if_ee
(
'::EE::MergeRequest'
)
app/serializers/merge_request_widget_entity.rb
View file @
a46ebf01
...
...
@@ -133,6 +133,10 @@ class MergeRequestWidgetEntity < Grape::Entity
help_page_path
(
'user/application_security/index.md'
,
anchor:
'viewing-security-scan-information-in-merge-requests'
)
end
expose
:enabled_reports
do
|
merge_request
|
merge_request
.
enabled_reports
end
private
delegate
:current_user
,
to: :request
...
...
ee/app/controllers/ee/projects/merge_requests_controller.rb
View file @
a46ebf01
...
...
@@ -46,14 +46,6 @@ module EE
reports_response
(
merge_request
.
compare_dependency_scanning_reports
(
current_user
),
head_pipeline
)
end
def
sast_reports
reports_response
(
merge_request
.
compare_sast_reports
(
current_user
),
head_pipeline
)
end
def
secret_detection_reports
reports_response
(
merge_request
.
compare_secret_detection_reports
(
current_user
),
head_pipeline
)
end
def
dast_reports
reports_response
(
merge_request
.
compare_dast_reports
(
current_user
),
head_pipeline
)
end
...
...
ee/app/models/ee/ci/job_artifact.rb
View file @
a46ebf01
...
...
@@ -17,8 +17,6 @@ module EE
DEPENDENCY_LIST_REPORT_FILE_TYPES
=
%w[dependency_scanning]
.
freeze
METRICS_REPORT_FILE_TYPES
=
%w[metrics]
.
freeze
CONTAINER_SCANNING_REPORT_TYPES
=
%w[container_scanning]
.
freeze
SAST_REPORT_TYPES
=
%w[sast]
.
freeze
SECRET_DETECTION_REPORT_TYPES
=
%w[secret_detection]
.
freeze
DAST_REPORT_TYPES
=
%w[dast]
.
freeze
REQUIREMENTS_REPORT_FILE_TYPES
=
%w[requirements]
.
freeze
COVERAGE_FUZZING_REPORT_TYPES
=
%w[coverage_fuzzing]
.
freeze
...
...
@@ -46,14 +44,6 @@ module EE
with_file_types
(
CONTAINER_SCANNING_REPORT_TYPES
)
end
scope
:sast_reports
,
->
do
with_file_types
(
SAST_REPORT_TYPES
)
end
scope
:secret_detection_reports
,
->
do
with_file_types
(
SECRET_DETECTION_REPORT_TYPES
)
end
scope
:dast_reports
,
->
do
with_file_types
(
DAST_REPORT_TYPES
)
end
...
...
ee/app/models/ee/ci/pipeline.rb
View file @
a46ebf01
...
...
@@ -99,16 +99,6 @@ module EE
batch_lookup_report_artifact_for_file_type
(
:license_scanning
).
present?
end
def
security_reports
(
report_types:
[])
reports_scope
=
report_types
.
empty?
?
::
Ci
::
JobArtifact
.
security_reports
:
::
Ci
::
JobArtifact
.
security_reports
(
file_types:
report_types
)
::
Gitlab
::
Ci
::
Reports
::
Security
::
Reports
.
new
(
self
).
tap
do
|
security_reports
|
latest_report_builds
(
reports_scope
).
each
do
|
build
|
build
.
collect_security_reports!
(
security_reports
)
end
end
end
def
license_scanning_report
::
Gitlab
::
Ci
::
Reports
::
LicenseScanning
::
Report
.
new
.
tap
do
|
license_management_report
|
latest_report_builds
(
::
Ci
::
JobArtifact
.
license_scanning_reports
).
each
do
|
build
|
...
...
ee/app/models/ee/merge_request.rb
View file @
a46ebf01
...
...
@@ -193,26 +193,6 @@ module EE
compare_reports
(
::
Ci
::
CompareSecurityReportsService
,
current_user
,
'container_scanning'
)
end
def
has_sast_reports?
!!
actual_head_pipeline
&
.
has_reports?
(
::
Ci
::
JobArtifact
.
sast_reports
)
end
def
has_secret_detection_reports?
!!
actual_head_pipeline
&
.
has_reports?
(
::
Ci
::
JobArtifact
.
secret_detection_reports
)
end
def
compare_sast_reports
(
current_user
)
return
missing_report_error
(
"SAST"
)
unless
has_sast_reports?
compare_reports
(
::
Ci
::
CompareSecurityReportsService
,
current_user
,
'sast'
)
end
def
compare_secret_detection_reports
(
current_user
)
return
missing_report_error
(
"secret detection"
)
unless
has_secret_detection_reports?
compare_reports
(
::
Ci
::
CompareSecurityReportsService
,
current_user
,
'secret_detection'
)
end
def
has_dast_reports?
!!
actual_head_pipeline
&
.
has_reports?
(
::
Ci
::
JobArtifact
.
dast_reports
)
end
...
...
@@ -287,13 +267,5 @@ module EE
ApprovalWrappedRule
.
wrap
(
self
,
rule
).
approved?
end
end
def
missing_report_error
(
report_type
)
{
status: :error
,
status_reason:
"This merge request does not have
#{
report_type
}
reports"
}
end
def
report_type_enabled?
(
report_type
)
!!
actual_head_pipeline
&
.
batch_lookup_report_artifact_for_file_type
(
report_type
)
end
end
end
ee/app/serializers/ee/merge_request_widget_entity.rb
View file @
a46ebf01
...
...
@@ -31,10 +31,6 @@ module EE
end
end
expose
:enabled_reports
do
|
merge_request
|
merge_request
.
enabled_reports
end
expose
:license_scanning
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_licenses
,
mr
.
target_project
)
}
do
expose
:managed_licenses_path
do
|
merge_request
|
expose_path
(
api_v4_projects_managed_licenses_path
(
id:
merge_request
.
target_project
.
id
))
...
...
ee/changelogs/unreleased/move_methods.yml
0 → 100644
View file @
a46ebf01
---
title
:
Move sast_reports and secret_detection_reports to CE
merge_request
:
48200
author
:
type
:
changed
ee/spec/factories/ci/job_artifacts.rb
View file @
a46ebf01
...
...
@@ -8,7 +8,7 @@ FactoryBot.define do
after
(
:build
)
do
|
artifact
,
_
|
artifact
.
file
=
fixture_file_upload
(
Rails
.
root
.
join
(
'
ee/
spec/fixtures/security_reports/master/gl-sast-report.json'
),
'application/json'
)
Rails
.
root
.
join
(
'spec/fixtures/security_reports/master/gl-sast-report.json'
),
'application/json'
)
end
end
...
...
@@ -28,7 +28,7 @@ FactoryBot.define do
after
(
:build
)
do
|
artifact
,
_
|
artifact
.
file
=
fixture_file_upload
(
Rails
.
root
.
join
(
'
ee/
spec/fixtures/security_reports/master/gl-secret-detection-report.json'
),
'application/json'
)
Rails
.
root
.
join
(
'spec/fixtures/security_reports/master/gl-secret-detection-report.json'
),
'application/json'
)
end
end
...
...
ee/spec/factories/merge_requests.rb
View file @
a46ebf01
...
...
@@ -121,30 +121,6 @@ FactoryBot.define do
end
end
trait
:with_sast_reports
do
after
(
:build
)
do
|
merge_request
|
merge_request
.
head_pipeline
=
build
(
:ee_ci_pipeline
,
:success
,
:with_sast_report
,
project:
merge_request
.
source_project
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
)
end
end
trait
:with_secret_detection_reports
do
after
(
:build
)
do
|
merge_request
|
merge_request
.
head_pipeline
=
build
(
:ee_ci_pipeline
,
:success
,
:with_secret_detection_report
,
project:
merge_request
.
source_project
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
)
end
end
trait
:with_coverage_fuzzing_reports
do
after
(
:build
)
do
|
merge_request
|
merge_request
.
head_pipeline
=
build
(
...
...
ee/spec/lib/gitlab/ci/parsers/security/dependency_scanning_spec.rb
View file @
a46ebf01
...
...
@@ -47,7 +47,7 @@ RSpec.describe Gitlab::Ci::Parsers::Security::DependencyScanning do
end
context
"when parsing a vulnerability with a missing location"
do
let
(
:report_hash
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
'security_reports/master/gl-sast-report.json'
,
dir:
'ee'
),
symbolize_names:
true
)
}
let
(
:report_hash
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
'security_reports/master/gl-sast-report.json'
),
symbolize_names:
true
)
}
before
do
report_hash
[
:vulnerabilities
][
0
][
:location
]
=
nil
...
...
@@ -57,7 +57,7 @@ RSpec.describe Gitlab::Ci::Parsers::Security::DependencyScanning do
end
context
"when parsing a vulnerability with a missing cve"
do
let
(
:report_hash
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
'security_reports/master/gl-sast-report.json'
,
dir:
'ee'
),
symbolize_names:
true
)
}
let
(
:report_hash
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
'security_reports/master/gl-sast-report.json'
),
symbolize_names:
true
)
}
before
do
report_hash
[
:vulnerabilities
][
0
][
:cve
]
=
nil
...
...
ee/spec/models/merge_request_spec.rb
View file @
a46ebf01
...
...
@@ -241,6 +241,7 @@ RSpec.describe MergeRequest do
:license_scanning
|
:with_license_management_reports
|
:license_scanning
:license_scanning
|
:with_license_scanning_reports
|
:license_scanning
:coverage_fuzzing
|
:with_coverage_fuzzing_reports
|
:coverage_fuzzing
:secret_detection
|
:with_secret_detection_reports
|
:secret_detection
:api_fuzzing
|
:with_api_fuzzing_reports
|
:api_fuzzing
end
...
...
@@ -353,50 +354,6 @@ RSpec.describe MergeRequest do
end
end
describe
'#has_sast_reports?'
do
subject
{
merge_request
.
has_sast_reports?
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
stub_licensed_features
(
sast:
true
)
end
context
'when head pipeline has sast reports'
do
let
(
:merge_request
)
{
create
(
:ee_merge_request
,
:with_sast_reports
,
source_project:
project
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
'when head pipeline does not have sast reports'
do
let
(
:merge_request
)
{
create
(
:ee_merge_request
,
source_project:
project
)
}
it
{
is_expected
.
to
be_falsey
}
end
end
describe
'#has_secret_detection_reports?'
do
subject
{
merge_request
.
has_secret_detection_reports?
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
stub_licensed_features
(
secret_detection:
true
)
end
context
'when head pipeline has secret detection reports'
do
let
(
:merge_request
)
{
create
(
:ee_merge_request
,
:with_secret_detection_reports
,
source_project:
project
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
'when head pipeline does not have secrets detection reports'
do
let
(
:merge_request
)
{
create
(
:ee_merge_request
,
source_project:
project
)
}
it
{
is_expected
.
to
be_falsey
}
end
end
describe
'#has_dast_reports?'
do
subject
{
merge_request
.
has_dast_reports?
}
...
...
spec/factories/ci/builds.rb
View file @
a46ebf01
...
...
@@ -290,6 +290,24 @@ FactoryBot.define do
end
end
trait
:codequality_report
do
after
(
:build
)
do
|
build
|
build
.
job_artifacts
<<
create
(
:ci_job_artifact
,
:codequality
,
job:
build
)
end
end
trait
:sast_report
do
after
(
:build
)
do
|
build
|
build
.
job_artifacts
<<
create
(
:ci_job_artifact
,
:sast
,
job:
build
)
end
end
trait
:secret_detection_report
do
after
(
:build
)
do
|
build
|
build
.
job_artifacts
<<
create
(
:ci_job_artifact
,
:secret_detection
,
job:
build
)
end
end
trait
:test_reports
do
after
(
:build
)
do
|
build
|
build
.
job_artifacts
<<
create
(
:ci_job_artifact
,
:junit
,
job:
build
)
...
...
spec/factories/ci/job_artifacts.rb
View file @
a46ebf01
...
...
@@ -269,6 +269,26 @@ FactoryBot.define do
end
end
trait
:sast
do
file_type
{
:sast
}
file_format
{
:raw
}
after
(
:build
)
do
|
artifact
,
_
|
artifact
.
file
=
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/security_reports/master/gl-sast-report.json'
),
'application/json'
)
end
end
trait
:secret_detection
do
file_type
{
:secret_detection
}
file_format
{
:raw
}
after
(
:build
)
do
|
artifact
,
_
|
artifact
.
file
=
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/security_reports/master/gl-secret-detection-report.json'
),
'application/json'
)
end
end
trait
:lsif
do
file_type
{
:lsif
}
file_format
{
:zip
}
...
...
spec/factories/ci/pipelines.rb
View file @
a46ebf01
...
...
@@ -93,6 +93,30 @@ FactoryBot.define do
end
end
trait
:with_codequality_report
do
status
{
:success
}
after
(
:build
)
do
|
pipeline
,
evaluator
|
pipeline
.
builds
<<
build
(
:ci_build
,
:codequality_report
,
pipeline:
pipeline
,
project:
pipeline
.
project
)
end
end
trait
:with_sast_report
do
status
{
:success
}
after
(
:build
)
do
|
pipeline
,
evaluator
|
pipeline
.
builds
<<
build
(
:ci_build
,
:sast_report
,
pipeline:
pipeline
,
project:
pipeline
.
project
)
end
end
trait
:with_secret_detection_report
do
status
{
:success
}
after
(
:build
)
do
|
pipeline
,
evaluator
|
pipeline
.
builds
<<
build
(
:ci_build
,
:secret_detection_report
,
pipeline:
pipeline
,
project:
pipeline
.
project
)
end
end
trait
:with_test_reports
do
status
{
:success
}
...
...
spec/factories/merge_requests.rb
View file @
a46ebf01
...
...
@@ -224,6 +224,30 @@ FactoryBot.define do
end
end
trait
:with_sast_reports
do
after
(
:build
)
do
|
merge_request
|
merge_request
.
head_pipeline
=
build
(
:ci_pipeline
,
:success
,
:with_sast_report
,
project:
merge_request
.
source_project
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
)
end
end
trait
:with_secret_detection_reports
do
after
(
:build
)
do
|
merge_request
|
merge_request
.
head_pipeline
=
build
(
:ci_pipeline
,
:success
,
:with_secret_detection_report
,
project:
merge_request
.
source_project
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
)
end
end
trait
:with_exposed_artifacts
do
after
(
:build
)
do
|
merge_request
|
merge_request
.
head_pipeline
=
build
(
...
...
ee/
spec/fixtures/security_reports/master/gl-sast-report.json
→
spec/fixtures/security_reports/master/gl-sast-report.json
View file @
a46ebf01
File moved
ee/
spec/fixtures/security_reports/master/gl-secret-detection-report.json
→
spec/fixtures/security_reports/master/gl-secret-detection-report.json
View file @
a46ebf01
File moved
spec/models/merge_request_spec.rb
View file @
a46ebf01
...
...
@@ -2054,6 +2054,50 @@ RSpec.describe MergeRequest, factory_default: :keep do
end
end
describe
'#has_sast_reports?'
do
subject
{
merge_request
.
has_sast_reports?
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
stub_licensed_features
(
sast:
true
)
end
context
'when head pipeline has sast reports'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
:with_sast_reports
,
source_project:
project
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
'when head pipeline does not have sast reports'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
it
{
is_expected
.
to
be_falsey
}
end
end
describe
'#has_secret_detection_reports?'
do
subject
{
merge_request
.
has_secret_detection_reports?
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
before
do
stub_licensed_features
(
secret_detection:
true
)
end
context
'when head pipeline has secret detection reports'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
:with_secret_detection_reports
,
source_project:
project
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
'when head pipeline does not have secrets detection reports'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
it
{
is_expected
.
to
be_falsey
}
end
end
describe
'#calculate_reactive_cache'
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
...
...
@@ -4587,4 +4631,34 @@ RSpec.describe MergeRequest, factory_default: :keep do
.
from
(
nil
).
to
(
ref
)
end
end
describe
'#enabled_reports'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
where
(
:report_type
,
:with_reports
,
:feature
)
do
:sast
|
:with_sast_reports
|
:sast
:secret_detection
|
:with_secret_detection_reports
|
:secret_detection
end
with_them
do
subject
{
merge_request
.
enabled_reports
[
report_type
]
}
before
do
stub_feature_flags
(
drop_license_management_artifact:
false
)
stub_licensed_features
({
feature
=>
true
})
end
context
"when head pipeline has reports"
do
let
(
:merge_request
)
{
create
(
:merge_request
,
with_reports
,
source_project:
project
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
"when head pipeline does not have reports"
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
it
{
is_expected
.
to
be_falsy
}
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