mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
Fix password support for Modules
Module settings should use value field for setting password in Elasticsearch output config, not the implicit, obfuscated to_s value. Fixes #8226
This commit is contained in:
parent
5ad11dacc7
commit
1ceda5a27f
2 changed files with 12 additions and 2 deletions
|
@ -69,7 +69,7 @@ module LogStash module Modules class LogStashConfig
|
|||
password = @settings["var.elasticsearch.password"]
|
||||
lines = ["hosts => #{hosts}", "index => \"#{index}\""]
|
||||
lines.push(user ? "user => \"#{user}\"" : nil)
|
||||
lines.push(password ? "password => \"#{password}\"" : nil)
|
||||
lines.push(password ? "password => \"#{password_value(password)}\"" : nil)
|
||||
lines.push(type_string ? "document_type => #{type_string}" : nil)
|
||||
lines.push("ssl => #{@settings.fetch('var.elasticsearch.ssl.enabled', false)}")
|
||||
if cacert = @settings["var.elasticsearch.ssl.certificate_authority"]
|
||||
|
@ -84,6 +84,10 @@ elasticsearch {
|
|||
CONF
|
||||
end
|
||||
|
||||
def password_value(password)
|
||||
password.is_a?(LogStash::Util::Password) ? password.value : password
|
||||
end
|
||||
|
||||
def config_string
|
||||
# process the template and settings
|
||||
# send back as a string
|
||||
|
|
|
@ -3,7 +3,7 @@ require "logstash/modules/logstash_config"
|
|||
|
||||
describe LogStash::Modules::LogStashConfig do
|
||||
let(:mod) { instance_double("module", :directory => Stud::Temporary.directory, :module_name => "testing") }
|
||||
let(:settings) { {"var.logstash.testing.pants" => "fancy" }}
|
||||
let(:settings) { {"var.logstash.testing.pants" => "fancy", "var.elasticsearch.password" => LogStash::Util::Password.new('correct_horse_battery_staple') }}
|
||||
subject { described_class.new(mod, settings) }
|
||||
|
||||
describe "configured inputs" do
|
||||
|
@ -36,6 +36,12 @@ describe LogStash::Modules::LogStashConfig do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'elastic_search_config' do
|
||||
it 'should put the password in correctly' do
|
||||
expect(subject.elasticsearch_output_config()).to include("password => \"correct_horse_battery_staple\"")
|
||||
end
|
||||
end
|
||||
|
||||
describe "alias modules options" do
|
||||
let(:alias_table) do
|
||||
{ "var.logstash.testing" => "var.logstash.better" }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue