Skip to content

Commit 251e775

Browse files
committed
warn recommended exclusion path for antivirus
It might be better that recommended exclusion path for antivirus because pos file or storage local file might be scanned by antivirus thus there might be possibility to be locked by them. Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
1 parent 9374788 commit 251e775

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

lib/fluent/supervisor.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,20 @@ def configure(supervisor: false)
814814
@conf += additional_conf
815815
end
816816

817+
if Fluent.windows?
818+
@conf.elements.each do |element|
819+
next unless element.name == 'source'
820+
if element['@type'] == 'tail' && element['pos_file']
821+
$log.warn("Recommend adding #{File.dirname(element['pos_file'])} to the exclusion path of your antivirus software on Windows")
822+
else
823+
storage = element.elements.select { |v| v.name == 'storage' and v['@type'] == 'local' and v['persistent'] == 'true' }.first
824+
if storage
825+
$log.warn("Recommend adding #{File.dirname(storage['path'])} to the exclusion path of your antivirus software on Windows")
826+
end
827+
end
828+
end
829+
end
830+
817831
@libs.each do |lib|
818832
require lib
819833
end

test/command/test_fluentd.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,4 +1679,38 @@ def create_config_include_dir_configuration(config_path, config_dir, yaml_format
16791679
end
16801680
end
16811681

1682+
sub_test_case "test suspicious harmful antivirus exclusion path" do
1683+
test "warn pos_file path" do
1684+
omit "skip recommendation warnings about exclusion path for antivirus" unless Fluent.windows?
1685+
create_conf_file("foo.conf", <<~EOF)
1686+
<source>
1687+
@type tail
1688+
tag t1
1689+
path #{@tmp_dir}/test.log
1690+
pos_file #{@tmp_dir}/test.pos
1691+
</source>
1692+
EOF
1693+
expected_warning_message = "[warn]: Recommend adding #{@tmp_dir} to the exclusion path of your antivirus software on Windows"
1694+
assert_log_matches(create_cmdline(conf_path, '--dry-run'),
1695+
expected_warning_message)
1696+
end
1697+
1698+
test "warn storage path" do
1699+
omit "skip recommendation warnings about exclusion path for antivirus" unless Fluent.windows?
1700+
create_conf_file("foo.conf", <<~EOF)
1701+
<source>
1702+
@type sample
1703+
tag t1
1704+
<storage>
1705+
@type local
1706+
persistent true
1707+
path #{@tmp_dir}/test.pos
1708+
</storage>
1709+
</source>
1710+
EOF
1711+
expected_warning_message = "[warn]: Recommend adding #{@tmp_dir} to the exclusion path of your antivirus software on Windows"
1712+
assert_log_matches(create_cmdline(conf_path, '--dry-run'),
1713+
expected_warning_message)
1714+
end
1715+
end
16821716
end

0 commit comments

Comments
 (0)