Skip to content

Fix feature flags .enabled? check

Sanad Liaquat requested to merge qa-shl-fix-feature-flag-enabled-check into master

What does this MR do?

Fix feature flags .enabled? check by simplifying the logic and making it more readable.

The current implementation of feature && feature['state'] == 'on' || feature['state'] == 'conditional' && scopes.present? && enabled_scope?(feature['gates'], scopes) is incorrect. For example, if enabled_scope?(feature['gates'], scopes) returns false, we want the statement to return false but currently, it returns true:

2.7.2 :006 > true && true || false && true && false
 => true

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

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 Sanad Liaquat

Merge request reports