Commit 2fee02e3 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '333020-drop-sql-optimizations-for-store-reports-ff' into 'master'

chore: Drop optimize_sql_query_for_security_report feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!63558
parents 192fa57b d5e3be8a
...@@ -35,12 +35,6 @@ module Security ...@@ -35,12 +35,6 @@ module Security
pipeline.vulnerability_findings.report_type(@report.type).any? pipeline.vulnerability_findings.report_type(@report.type).any?
end end
def optimize_sql_query_for_security_report_enabled?
strong_memoize(:optimize_sql_query_for_security_report_enabled) do
Feature.enabled?(:optimize_sql_query_for_security_report, project)
end
end
def create_all_vulnerabilities! def create_all_vulnerabilities!
# Look for existing Findings using UUID # Look for existing Findings using UUID
finding_uuids = @report.findings.map(&:uuid) finding_uuids = @report.findings.map(&:uuid)
...@@ -48,18 +42,16 @@ module Security ...@@ -48,18 +42,16 @@ module Security
.where(uuid: finding_uuids) # rubocop: disable CodeReuse/ActiveRecord .where(uuid: finding_uuids) # rubocop: disable CodeReuse/ActiveRecord
.to_h { |vf| [vf.uuid, vf] } .to_h { |vf| [vf.uuid, vf] }
update_vulnerability_scanners!(@report.findings) if optimize_sql_query_for_security_report_enabled? update_vulnerability_scanners!(@report.findings)
vulnerability_ids = @report.findings.map do |finding| vulnerability_ids = @report.findings.map do |finding|
create_vulnerability_finding(vulnerability_findings_by_uuid, finding)&.id create_vulnerability_finding(vulnerability_findings_by_uuid, finding)&.id
end.compact.uniq end.compact.uniq
if optimize_sql_query_for_security_report_enabled? update_vulnerability_links_info
update_vulnerability_links_info create_vulnerability_pipeline_objects
create_vulnerability_pipeline_objects update_vulnerabilities_identifiers
update_vulnerabilities_identifiers update_vulnerabilities_finding_identifiers
update_vulnerabilities_finding_identifiers
end
vulnerability_ids vulnerability_ids
end end
...@@ -85,8 +77,6 @@ module Security ...@@ -85,8 +77,6 @@ module Security
vulnerability_finding_to_finding_map[vulnerability_finding] = finding vulnerability_finding_to_finding_map[vulnerability_finding] = finding
update_vulnerability_scanner(finding) unless optimize_sql_query_for_security_report_enabled?
update_vulnerability_finding(vulnerability_finding, vulnerability_params) update_vulnerability_finding(vulnerability_finding, vulnerability_params)
reset_remediations_for(vulnerability_finding, finding) reset_remediations_for(vulnerability_finding, finding)
...@@ -95,17 +85,6 @@ module Security ...@@ -95,17 +85,6 @@ module Security
update_finding_signatures(finding, vulnerability_finding) update_finding_signatures(finding, vulnerability_finding)
end end
unless optimize_sql_query_for_security_report_enabled?
# The maximum number of identifiers is not used in validation
# we just want to ignore the rest if a finding has more than that.
finding.identifiers.take(Vulnerabilities::Finding::MAX_NUMBER_OF_IDENTIFIERS).map do |identifier| # rubocop: disable CodeReuse/ActiveRecord
create_or_update_vulnerability_identifier_object(vulnerability_finding, identifier)
end
create_or_update_vulnerability_links(finding, vulnerability_finding)
create_vulnerability_pipeline_object(vulnerability_finding, pipeline)
end
create_vulnerability(vulnerability_finding, pipeline) create_vulnerability(vulnerability_finding, pipeline)
end end
......
---
name: optimize_sql_query_for_security_report
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57426
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/323059
milestone: '13.11'
type: development
group: group::static analysis
default_enabled: false
...@@ -15,17 +15,13 @@ RSpec.describe Security::StoreReportService, '#execute' do ...@@ -15,17 +15,13 @@ RSpec.describe Security::StoreReportService, '#execute' do
subject { described_class.new(pipeline, report).execute } subject { described_class.new(pipeline, report).execute }
where(:vulnerability_finding_signatures_enabled, :optimize_sql_query_for_security_report_ff) do where(:vulnerability_finding_signatures_enabled) do
true | true [true, false]
true | false
false | true
false | false
end end
with_them do with_them do
before do before do
stub_feature_flags(vulnerability_finding_tracking_signatures: vulnerability_finding_signatures_enabled) stub_feature_flags(vulnerability_finding_tracking_signatures: vulnerability_finding_signatures_enabled)
stub_feature_flags(optimize_sql_query_for_security_report: optimize_sql_query_for_security_report_ff)
stub_licensed_features( stub_licensed_features(
sast: true, sast: true,
dependency_scanning: true, dependency_scanning: true,
...@@ -675,7 +671,6 @@ RSpec.describe Security::StoreReportService, '#execute' do ...@@ -675,7 +671,6 @@ RSpec.describe Security::StoreReportService, '#execute' do
stub_feature_flags( stub_feature_flags(
vulnerability_finding_tracking_signatures: false vulnerability_finding_tracking_signatures: false
) )
stub_feature_flags(optimize_sql_query_for_security_report: true)
expect do expect do
expect do expect do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment