Skip to content

Wrap arguments in Arel.sql in queue_background_migration_jobs_by_range_at_intervals

While working on !17993 (merged) I noticed that there is deprecation warning printed when queue_background_migration_jobs_by_range_at_intervals is used:

DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "MIN(id), MAX(id)". Non-attribute arguments will be disallowed in Rails 6.0. This method should not be called with user-provided values, such as request parameters or model attributes. Known-safe values can be passed by wrapping them in Arel.sql(). (called from block in queue_background_migration_jobs_by_range_at_intervals at ee/gitlab/lib/gitlab/database/migration_helpers.rb:1021

This MR wraps the 'MIN(id), MAX(id)' in Arel.sql to remove the warning.

TL;DR:

-          start_id, end_id = relation.pluck('MIN(id), MAX(id)').first
+          start_id, end_id = relation.pluck(Arel.sql('MIN(id), MAX(id)')).first

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Krasimir Angelov

Merge request reports