Skip to content
代码片段 群组 项目
未验证 提交 1388e82a 编辑于 作者: Vitali Tatarintev's avatar Vitali Tatarintev 提交者: GitLab
浏览文件

Merge branch 'minac_451309_remove_optimized_vulnerability_report_export_ff' into 'master'

Remove `optimized_vulnerability_report_export` feature flag

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/160071



Merged-by: default avatarVitali Tatarintev <vtatarintev@gitlab.com>
Approved-by: default avatarSubashis Chakraborty <schakraborty@gitlab.com>
Approved-by: default avatarVitali Tatarintev <vtatarintev@gitlab.com>
Co-authored-by: default avatarMehmet Emin INAC <minac@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -12,10 +12,7 @@ class ExportService
EXPORTERS = {
'csv' => VulnerabilityExports::Exporters::CsvService
}.freeze
BATCH_SIZE = 500
# Remove the below constant and set BATCH_SIZE constant to 1K while enabling the
# `optimized_vulnerability_report_export` globally and cleaning up the code.
VULNERABILITY_READS_QUERY_BATCH_SIZE = 1_000
BATCH_SIZE = 1_000
# This constant determines the number of records to be handled per segmented export.
VULNERABILITY_READS_PARTIAL_FILE_BATCH_SIZE = 25_000
......@@ -168,35 +165,15 @@ def exporter(scope = vulnerabilities)
def vulnerabilities
if exportable.is_a?(Group)
if Feature.enabled?(:optimized_vulnerability_report_export, exportable)
group_vulnerabilities_enumerator
else
in_operator_optimized_enumerator(::Vulnerability.unscoped, {
in_operator_optimization_options: {
array_scope: exportable.all_projects.non_archived.select(:id),
array_mapping_scope: ::Vulnerability.method(:in_optimization_array_mapping_scope)
}
})
end
group_vulnerabilities_enumerator
else
Security::VulnerabilitiesFinder.new(exportable).execute.with_findings_scanner_identifiers_and_notes
end
end
def in_operator_optimized_enumerator(scope, opts = {})
Enumerator.new do |yielder|
Gitlab::Pagination::Keyset::Iterator.new(scope: scope, **opts).each_batch(of: BATCH_SIZE) do |records|
::Vulnerability
.id_in(records.pluck_primary_key)
.with_findings_scanner_identifiers_and_notes
.each { |preloaded_record| yielder << preloaded_record }
end
end
end
def group_vulnerabilities_enumerator(iterator = group_vulnerability_reads_iterator)
Enumerator.new do |yielder|
iterator.each_batch(of: VULNERABILITY_READS_QUERY_BATCH_SIZE) do |records|
iterator.each_batch(of: BATCH_SIZE) do |records|
records.with_export_entities.to_a.each do |vulnerability_read|
yielder.yield(vulnerability_read.vulnerability)
end
......
---
name: optimized_vulnerability_report_export
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/440163
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/147365
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/451309
milestone: '16.11'
group: group::threat insights
type: development
default_enabled: false
......@@ -390,24 +390,6 @@
vulnerabilities_b.map(&:title)
)
end
context 'with `optimized_vulnerability_report_export` disabled' do
before do
stub_feature_flags(optimized_vulnerability_report_export: false)
end
it 'appends each vulnerability to a CSV file' do
export
csv = CSV.read(vulnerability_export.file.path, headers: true)
expect(csv.headers).to be_present
expect(csv['Vulnerability']).to match_array(
vulnerabilities_a.map(&:title) +
vulnerabilities_b.map(&:title)
)
end
end
end
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册