Skip to content

Allow expanding variables in Rails by topologically sorting them

This MR is based on the pedropombeiro/26345-variable_inside_variable-scoped-FF branch, please change to master before merging

What does this MR do?

  1. Adds a expand_runner_variables function to ExpandVariables to perform a full expansion of a runner variable array, gated by the new project-scoped :variable_inside_variable feature flag. It will return the original variables if a cyclic reference is detected;
  2. Modifies the transform_variables/match_or_blank_value private functions to work with a hash of variables, instead of hash of variable values. This allows us to check for the :protected flag to make a decision on whether to expand the variable.
  3. Changes Sorted.each_variable_reference so that it doesn't take into consideration references to protected variables.
  4. Adds tests for new functionality for both feature flag disabled and enabled cases (cyclic reference detection, topological sorting expectations, variable expansion).
  5. Per Kamil's suggestion, removes code that handles Windows-style variable references (%).

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability 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

Part of gitlab-runner#26345 (closed)

Edited by Pedro Pombeiro

Merge request reports