Implement CI syntax for secrets

Merged Krasimir Angelov requested to merge ci-secrets-syntax into master

What does this MR do?

This MR adds initial support for configuring job's secrets in CI yaml. Built on top of !31831 (closed) with the changes suggested in #218746 (closed).

This new syntax is hidden behind global (instance wide) feature flag named ci_secrets_syntax, disabled by default.

The syntax look like this:

deploy:
  stage: release
  secrets:
    DATABASE_PASSWORD:
      vault: production/db/password         # translates to secret `kv-v2/data/production/db`, field `password`
    SSL_PRIVATE_KEY:
      vault: production/ssl/private-key@ops # translates to secret `ops/data/production/ssl`, field `private-key`
    S3_SECRET_KEY:                          # translates to secret `aws/data/production/s3`, field `secret-key`
      vault:
        engine:
          name: kv-v2
          path: aws
        path: production/s3
        field: secret-key

Here is a test the cover the above forms of the syntax - https://gitlab.com/gitlab-org/gitlab/-/blob/f5cec6eda06b53be3461ab097a12e68278653750/ee/spec/lib/gitlab/ci/config/entry/job_spec.rb#L60-106.

The processed config will be returned to the runner (to be implemented in a subsequent MR) where it will be used to fetch the secrets from Vault, see gitlab-runner!2006 (closed).

This will be GitLab Premium feature, the license check will be added in a subsequent MR at the API level so that we can scope to a project.

Limitations

In this case vault is a static keyword that represents the secrets provider type. While it will allow us to add another type of provider in the future, it prevents us to have multiple providers of the same type, for example db-vault, ops-vault, etc, something that was supported with the syntax implemented in !31831 (closed).

Screenshots

ci_secrets_syntax feature flag disabled

image

ci_secrets_syntax feature flag enabled

image

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
Edited by Krasimir Angelov