diff --git a/lib/logstash/config/mixin.rb b/lib/logstash/config/mixin.rb index b4237d135..f3d884c2a 100644 --- a/lib/logstash/config/mixin.rb +++ b/lib/logstash/config/mixin.rb @@ -110,6 +110,16 @@ module LogStash::Config::Mixin I18n.t("logstash.agent.configuration.invalid_plugin_settings") end + # We remove any config options marked as obsolete, + # no code should be associated to them and their values should not bleed + # to the plugin context. + # + # This need to be done after fetching the options from the parents classed + params.reject! do |name, value| + opts = self.class.get_config[name] + opts.include?(:obsolete) + end + # set instance variables like '@foo' for each config value given. params.each do |key, value| next if key[0, 1] == "@" diff --git a/spec/core/config_mixin_spec.rb b/spec/core/config_mixin_spec.rb index 87bbe074e..7c73b805d 100644 --- a/spec/core/config_mixin_spec.rb +++ b/spec/core/config_mixin_spec.rb @@ -115,6 +115,14 @@ describe LogStash::Config::Mixin do end end + context "when using an obsolete settings from the parent class" do + it "should cause a configuration error" do + expect { + plugin_class.new("debug" => true) + }.to raise_error(LogStash::ConfigurationError) + end + end + context "when not using an obsolete setting" do it "should not cause a configuration error" do expect { @@ -123,4 +131,24 @@ describe LogStash::Config::Mixin do end end end + + context "#params" do + let(:plugin_class) do + Class.new(LogStash::Filters::Base) do + config_name "fake" + config :password, :validate => :password + config :bad, :validate => :string, :default => "my default", :obsolete => "not here" + end + end + + subject { plugin_class.new({ "password" => "secret" }) } + + it "should not return the obsolete options" do + expect(subject.params).not_to include("bad") + end + + it "should include any other params" do + expect(subject.params).to include("password") + end + end end