Commit fa35ea13 authored by Rémy Coutable's avatar Rémy Coutable

Strip leading & trailing whitespaces in CI/CD secret variable keys

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 24fadd7c
......@@ -16,6 +16,10 @@ module HasVariable
key: Gitlab::Application.secrets.db_key_base,
algorithm: 'aes-256-cbc'
def key=(new_key)
super(new_key.to_s.strip)
end
def to_runner_variable
{ key: key, value: value, public: false }
end
......
---
title: Strip leading & trailing whitespaces in CI/CD secret variable keys
merge_request: 15615
author:
type: fixed
......@@ -9,6 +9,24 @@ describe HasVariable do
it { is_expected.not_to allow_value('foo bar').for(:key) }
it { is_expected.not_to allow_value('foo/bar').for(:key) }
describe '#key=' do
context 'when the new key is nil' do
it 'strips leading and trailing whitespaces' do
subject.key = nil
expect(subject.key).to eq('')
end
end
context 'when the new key has leadind and trailing whitespaces' do
it 'strips leading and trailing whitespaces' do
subject.key = ' my key '
expect(subject.key).to eq('my key')
end
end
end
describe '#value' do
before do
subject.value = 'secret'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment