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
14 changes: 14 additions & 0 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions test/command/test_fluentd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<source>
@type tail
tag t1
path #{@tmp_dir}/test.log
pos_file #{@tmp_dir}/test.pos
</source>
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)
<source>
@type sample
tag t1
<storage>
@type local
path #{@tmp_dir}/test.pos
</storage>
</source>
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