Skip to content
Snippets Groups Projects
Verified Commit c39be12a authored by Gregory Havenga's avatar Gregory Havenga :two: Committed by GitLab
Browse files

Merge branch '515252-remove-without-archived-projects' into 'master'

parents 79c782f7 738d71de
No related branches found
No related tags found
4 merge requests!181325Fix ambiguous `created_at` in project.rb,!180727Resolve "Extend job archival mechanism to the whole pipeline",!180595Draft: 4 Get public-namespace-plan-info-card's planName from seats app,!179215Remove without_archived_projects and associated FF
Pipeline #1658420414 passed
......@@ -97,10 +97,7 @@ def filter_by_projects
return @vulnerability_reads = vulnerability_reads.by_projects(params[:project_id]) if vulnerability_is_a_group?
@vulnerability_reads = vulnerability_reads.for_projects(
params[:project_id],
params[:include_archived_projects]
)
@vulnerability_reads = vulnerability_reads.for_projects(params[:project_id])
end
def filter_by_report_types
......
......@@ -4,25 +4,8 @@ module VulnerabilityScopes
extend ActiveSupport::Concern
included do
scope :without_archived_projects, ->(project_ids = []) do
return none if project_ids.nil?
# no other actor available in this scope
if Feature.disabled?(:vulnerability_scope_disable_cross_join, Feature.current_request)
return joins(:project).merge(::Project.non_archived)
.where(project_id: project_ids)
.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/485658')
end
where(project_id: ::Project.non_archived.where(id: project_ids).pluck_primary_key)
end
scope :for_projects, ->(project_ids, include_archived = false) do
if include_archived
where(project_id: project_ids)
else
without_archived_projects(project_ids)
end
scope :for_projects, ->(project_ids) do
where(project_id: project_ids)
end
end
end
......@@ -40,7 +40,7 @@ def vulnerability_reads
return Vulnerabilities::Read.none if project_ids.empty?
Vulnerabilities::Read.for_projects(project_ids, true)
Vulnerabilities::Read.for_projects(project_ids)
end
def vulnerability_scanners
......
---
name: vulnerability_scope_disable_cross_join
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/499694
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/175951
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/504568
milestone: '17.8'
group: group::security infrastructure
type: gitlab_com_derisk
default_enabled: false
......@@ -6,7 +6,6 @@
describe 'scopes' do
let(:result_set_transformer) { transformer_method || :itself }
let(:archive_associated_objects) { archived_project.vulnerabilities.map(&result_set_transformer) }
let(:all_excluding_archive_associations) { all_vulns_for_params - archive_associated_objects }
let_it_be(:vulnerability) { create(:vulnerability, :with_finding, project: project) }
let_it_be(:archived_project) do
......@@ -16,9 +15,7 @@
describe '.for_projects' do
subject { described_class.for_projects(*params) }
let(:include_archived) { nil }
let(:params) { [[project.id, archived_project.id], include_archived].compact }
let(:params) { [[project.id, archived_project.id]] }
let(:all_vulns_for_params) do
(project.vulnerabilities + archived_project.vulnerabilities).map(&result_set_transformer)
end
......@@ -28,47 +25,8 @@
create(:vulnerability, :with_finding, project: create(:project))
end
context 'when including archived projects' do
let(:include_archived) { true }
context 'when vulnerability_scope_disable_cross_join is disabled' do
before do
stub_feature_flags(vulnerability_scope_disable_cross_join: false)
end
it 'returns objects related to the given project IDs' do
is_expected.to contain_exactly(*all_vulns_for_params)
end
end
it 'returns objects related to the given project IDs' do
is_expected.to contain_exactly(*all_vulns_for_params)
end
end
context 'when excluding archived projects' do
let(:include_archived) { false }
context 'when vulnerability_scope_disable_cross_join is disabled' do
before do
stub_feature_flags(vulnerability_scope_disable_cross_join: false)
skip_if_database_exists(:sec)
end
it 'returns objects related to the given project IDs' do
::Gitlab::Database.allow_cross_joins_across_databases(
url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/504568'
) do
is_expected.to contain_exactly(*all_excluding_archive_associations)
end
end
end
context 'when vulnerability_scope_disable_cross_join is enabled' do
it 'returns objects related to the given project IDs' do
is_expected.to contain_exactly(*all_excluding_archive_associations)
end
end
it 'returns objects related to the given project IDs' do
is_expected.to contain_exactly(*all_vulns_for_params)
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment