From 4d0dbd44f47502911bcfb5c46e684a9c5ce4d5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20B=C4=82LTEANU?= Date: Mon, 24 Aug 2026 23:36:32 +0300 Subject: [PATCH 2/2] Adds key parameter to the list of filter_parameters (#43881). Patch by Bogdan Egikov (user:sledyuk). --- config/application.rb | 2 +- test/unit/lib/parameter_filtering_test.rb | 48 +++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 test/unit/lib/parameter_filtering_test.rb diff --git a/config/application.rb b/config/application.rb index 51c479b89..1e643bd70 100644 --- a/config/application.rb +++ b/config/application.rb @@ -65,7 +65,7 @@ module RedmineApp config.encoding = "utf-8" # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password, :salt, :twofa_totp_key] + config.filter_parameters += [:password, :salt, :twofa_totp_key, /\Akey\z/] config.action_mailer.perform_deliveries = false diff --git a/test/unit/lib/parameter_filtering_test.rb b/test/unit/lib/parameter_filtering_test.rb new file mode 100644 index 000000000..d7f47e462 --- /dev/null +++ b/test/unit/lib/parameter_filtering_test.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +# Redmine - project management software +# Copyright (C) 2006- Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require_relative '../../test_helper' + +class ParameterFilteringTest < ActiveSupport::TestCase + def filter(params) + ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters).filter(params) + end + + test "the key parameter should be filtered from logs" do + filtered = filter('key' => '1234567890abcdef1234567890abcdef12345678') + assert_equal '[FILTERED]', filtered['key'] + end + + test "passwords should be filtered from logs" do + assert_equal '[FILTERED]', filter('password' => 'secret')['password'] + assert_equal '[FILTERED]', filter('sudo_password' => 'secret')['sudo_password'] + end + + test "salt should be filtered from logs" do + assert_equal '[FILTERED]', filter('salt' => 'secret')['salt'] + end + + test "twofa_totp_key should be filtered from logs" do + assert_equal '[FILTERED]', filter('twofa_totp_key' => 'secret')['twofa_totp_key'] + end + + test "parameters merely containing key should not be over-filtered" do + assert_equal 'fixes', filter('keywords' => 'fixes')['keywords'] + end +end -- 2.50.1 (Apple Git-155)