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

Signed-off-by: NRémy Coutable <remy@rymai.me>
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册