Kubernetes runner outputs ENV variable name rather than values
Summary
When using a Kubernetes runner to execute any security analyzer, the runner logs which image it is using without interpolating the ENV variables.
For example, a Kubernetes DAST job logs:
Using Kubernetes executor with image $SECURE_ANALYZERS_PREFIX/dast:$DAST_VERSION ...
Whereas the docker runner logs:
Using Docker executor with image registry.gitlab.com/gitlab-org/security-products/dast:1 ...
Steps to reproduce
- Create a new project (The project can be based on https://gitlab.com/craigmsmith/craigmsmith-autodevops)
- Link to a Kubernetes cluster
- Install the Kubernetes runner
- Disable shared runners for the project (to ensure all the jobs run using the Kubernetes runner)
- run a build
- Once the build has completed, look at the DAST job log.
Example Project
https://gitlab.com/craigmsmith/craigmsmith-autodevops/-/jobs/559737224#L5
What is the current bug behavior?
Using Kubernetes executor with image $SECURE_ANALYZERS_PREFIX/dast:$DAST_VERSION ...
is output to the log
What is the expected correct behavior?
Using Kubernetes executor with image registry.gitlab.com/gitlab-org/security-products/dast:1 ...
should be output to the log
Relevant logs and/or screenshots
(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise.)
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
When the kubernetes runner displays the image, it does not consider the ENV variables. https://gitlab.com/gitlab-org/gitlab-runner/-/blob/master/executors/kubernetes/kubernetes.go#L186
The docker runner does: https://gitlab.com/gitlab-org/gitlab-runner/-/blob/9c9292b267a3132c41075ac09b968f3b5499ca68/executors/docker/docker.go#L1136 https://gitlab.com/gitlab-org/gitlab-runner/-/blob/9c9292b267a3132c41075ac09b968f3b5499ca68/executors/docker/docker.go#L952