diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index 1857f3b277..ab12ea63ce 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -814,6 +814,20 @@ def configure(supervisor: false) @conf += additional_conf end + if Fluent.windows? + @conf.elements.each do |element| + next unless element.name == 'source' + if element['@type'] == 'tail' && element['pos_file'] + $log.warn("Recommend adding #{File.dirname(element['pos_file'])} to the exclusion path of your antivirus software on Windows") + else + storage = element.elements.find { |v| v.name == 'storage' and v['@type'] == 'local' } + if storage + $log.warn("Recommend adding #{File.dirname(storage['path'])} to the exclusion path of your antivirus software on Windows") + end + end + end + end + @libs.each do |lib| require lib end diff --git a/test/command/test_fluentd.rb b/test/command/test_fluentd.rb index 6fe1a1655f..b7b8095355 100644 --- a/test/command/test_fluentd.rb +++ b/test/command/test_fluentd.rb @@ -1679,4 +1679,37 @@ def create_config_include_dir_configuration(config_path, config_dir, yaml_format end end + sub_test_case "test suspicious harmful antivirus exclusion path" do + test "warn pos_file path" do + omit "skip recommendation warnings about exclusion path for antivirus" unless Fluent.windows? + conf_path = create_conf_file("foo.conf", <<~EOF) + + @type tail + tag t1 + path #{@tmp_dir}/test.log + pos_file #{@tmp_dir}/test.pos + + EOF + expected_warning_message = "[warn]: Recommend adding #{@tmp_dir} to the exclusion path of your antivirus software on Windows" + assert_log_matches(create_cmdline(conf_path, '--dry-run'), + expected_warning_message) + end + + test "warn storage path" do + omit "skip recommendation warnings about exclusion path for antivirus" unless Fluent.windows? + conf_path = create_conf_file("foo.conf", <<~EOF) + + @type sample + tag t1 + + @type local + path #{@tmp_dir}/test.pos + + + EOF + expected_warning_message = "[warn]: Recommend adding #{@tmp_dir} to the exclusion path of your antivirus software on Windows" + assert_log_matches(create_cmdline(conf_path, '--dry-run'), + expected_warning_message) + end + end end