Fix Deprecation Warning in has_environment_scope
What does this MR do?
Deprecation warnings like the following have started to appear in the test suite output when the code under test invokes the has_environment_scope
method:
DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "CASE environment_scope\n WHEN '*' THEN 0\n WHEN 'production' THEN 2\n ELSE 1\nEND ASC\n". 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().
This MR wraps the raw SQL in Arel.sql
, suppressing the deprecation warning.
This raw SQL uses values from user input. However, the values are quoted using ActiveRecord.connection.quote
:
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Performance and testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
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