Commit b2fb691e authored by Harsh Chouraria's avatar Harsh Chouraria Committed by Matthias Käppler

Permit symbols when loading mail_room.yml

The `YAML.safe_load` changes made by
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58042
broke the diagnostic rake task gitlab:incoming_email:check
due to use of symbols for keys inside the ERB template
file `config/mail_room.yml`.

This change adds an exclusion permitting loading of
Symbol classes when parsing the YAML syntax for this
specific file.

Fixes https://gitlab.com/gitlab-org/gitlab/-/issues/331683

Changelog: fixed
parent 174bbef0
...@@ -52,7 +52,7 @@ module SystemCheck ...@@ -52,7 +52,7 @@ module SystemCheck
def load_config def load_config
erb = ERB.new(File.read(mail_room_config_path)) erb = ERB.new(File.read(mail_room_config_path))
erb.filename = mail_room_config_path erb.filename = mail_room_config_path
config_file = YAML.safe_load(erb.result) config_file = YAML.safe_load(erb.result, permitted_classes: [Symbol])
config_file[:mailboxes] config_file[:mailboxes]
end end
......
# frozen_string_literal: true
require 'fast_spec_helper'
MAIL_ROOM_CONFIG_ENABLED_SAMPLE =
":mailboxes:\n"\
" \n"\
" -\n"\
" :host: \"gitlab.example.com\"\n"\
" :port: 143\n"\
""
RSpec.describe SystemCheck::IncomingEmail::ImapAuthenticationCheck do
subject(:system_check) { described_class.new }
describe '#load_config' do
subject { system_check.send(:load_config) }
context 'returns no mailbox configurations with mailroom default configuration' do
it { is_expected.to be_nil }
end
context 'returns an array of mailbox configurations with mailroom configured' do
before do
allow(File).to receive(:read).and_return(MAIL_ROOM_CONFIG_ENABLED_SAMPLE)
end
it { is_expected.to eq([{ host: "gitlab.example.com", port: 143 }]) }
end
end
end
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