Resolve cross DB issues in ee/app/models/instance_security_dashboard.rb
Summary
The instances security dashboard retrieves a bunch of information by their relationship to a project subset. Likely a variety of these will need to be fixed here.
Further details
def projects
Project.where(id: visible_users_security_dashboard_projects)
.with_feature_available_for_user(:security_and_compliance, user)
.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/485658')
end
def vulnerabilities
return Vulnerability.none if projects.empty?
Vulnerability.for_projects(projects).allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/485658')
end
Proposal
- Update
InstanceSecurityDashboardmethods that query vulnerability tables, and make them pluck project IDs to avoid a cross-join. - Other methods that query tables of the main schema
can still rely on the
#projectsmethod, which return a relation. - Remove
allow_cross_joins_across_databasesfrom#projects.
Edited by Fabien Catteau