Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/hammer_cli/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.data_filters
end

# add password filter: *password => "***"
Logging::LogEvent.add_data_filter(/(password(\e\[0;\d{2}m|\e\[0m|\s|=>|")+\")[^\"]*\"/, '\1***"')
Logging::LogEvent.add_data_filter(/(password(\e\[0;\d{2}m|\e\[0m|\s|=>|:|")+\")[^\"]*\"/, '\1***"')

module HammerCLI
module Logger
Expand Down
18 changes: 15 additions & 3 deletions test/unit/abstract_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ def execute
it "should have logger.watch output without colors" do
test_command = Class.new(TestLogCmd4).new("")
test_command.run []
_(@log_output.read).must_include "DEBUG TestLogCmd4 : Test\n{\n :a => \"a\"\n}"
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1') # TODO: remove when Ruby 3.0 is not supported
_(@log_output.read).must_include "DEBUG TestLogCmd4 : Test\n{\n :a => \"a\"\n}"
else
_(@log_output.read).must_include "DEBUG TestLogCmd4 : Test\n{\n a: \"a\"\n}"
end
end

class TestLogCmd5 < HammerCLI::AbstractCommand
Expand All @@ -162,7 +166,11 @@ def execute
HammerCLI::Settings.clear
HammerCLI::Settings.load(:watch_plain => true)
test_command.run []
_(@log_output.read).must_include "DEBUG TestLogCmd5 : Test\n{\n :a => \"a\"\n}"
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1') # TODO: remove when Ruby 3.0 is not supported
_(@log_output.read).must_include "DEBUG TestLogCmd5 : Test\n{\n :a => \"a\"\n}"
else
_(@log_output.read).must_include "DEBUG TestLogCmd5 : Test\n{\n a: \"a\"\n}"
end
end

class TestLogCmd6 < HammerCLI::AbstractCommand
Expand All @@ -177,7 +185,11 @@ def execute
HammerCLI::Settings.clear
HammerCLI::Settings.load(:watch_plain => true)
test_command.run []
_(@log_output.read).must_include "DEBUG TestLogCmd6 : Test\n{\n :password => \"***\",\n \"password\" => \"***\"\n}"
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1') # TODO: remove when Ruby 3.0 is not supported
_(@log_output.read).must_include "DEBUG TestLogCmd6 : Test\n{\n :password => \"***\",\n \"password\" => \"***\"\n}"
else
_(@log_output.read).must_include "DEBUG TestLogCmd6 : Test\n{\n password: \"***\",\n \"password\" => \"***\"\n}"
end
end

it "password parameters should be hidden in logs" do
Expand Down