Resolve cross join issue and dependencies for ee/app/models/concerns/vulnerability_scopes.rb
Summary
The vulnerability scopes concern has a built in mechanic that forces vulnerabilities scopes to implicitly exclude archived vulnerabilities. This functionality cannot work post sec-decomposition as we cannot implicitly join to projects to resolve the archival condition.
Unfortunately, this change impacts the functionality of GitLab significantly across many files, so fixing this will be non-arbitrary.
Further details
module VulnerabilityScopes
extend ActiveSupport::Concern
included do
scope :without_archived_projects, -> { joins(:project).merge(::Project.non_archived) }
scope :for_projects, ->(project_ids, include_archived = false) do
if include_archived
where(project_id: project_ids)
else
without_archived_projects.where(project_id: project_ids)
end
end
end
end
This concern is used by EE::Vulnerability
and Vulnerabilities::Read.
Proposal
Pass or pluck projects IDs instead of projects.
Edited by Fabien Catteau