Skip to content

Commit 6c188e5

Browse files
committed
warn recommended exclusion path for antivirus
It might be better to notify about recommended exclusion path for antivirus. Typically 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 dc7afab commit 6c188e5

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

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.find { |v| v.name == 'storage' and v['@type'] == 'local' and v['persistent'] == 'true' }
824+
if storage and storage['path']
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: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,4 +1679,63 @@ def create_config_include_dir_configuration(config_path, config_dir, yaml_format
16791679
end
16801680
end
16811681

1682+
sub_test_case "test problematic antivirus exclusion path on Windows" do
1683+
test "warn pos_file path" do
1684+
omit "skip antivirus exclusion path about in_tail pos_file (Windows)" unless Fluent.windows?
1685+
conf_path = create_conf_file("warn_pos_file_dir.conf", <<~EOF)
1686+
<system>
1687+
config_include_dir ""
1688+
</system>
1689+
<source>
1690+
@type tail
1691+
tag t1
1692+
path #{@tmp_dir}/test.log
1693+
pos_file #{@tmp_dir}/test.pos
1694+
</source>
1695+
EOF
1696+
expected_warning_message = "[warn]: Recommend adding #{@tmp_dir} to the exclusion path of your antivirus software on Windows"
1697+
assert_log_matches(create_cmdline(conf_path, '--dry-run'),
1698+
expected_warning_message)
1699+
end
1700+
1701+
test "warn storage path" do
1702+
omit "skip antivirus exclusion path about storage local (Windows)" unless Fluent.windows?
1703+
conf_path = create_conf_file("warn_storage_local_path.conf", <<~EOF)
1704+
<system>
1705+
config_include_dir ""
1706+
</system>
1707+
<source>
1708+
@type sample
1709+
tag t1
1710+
<storage>
1711+
@type local
1712+
persistent true
1713+
path #{@tmp_dir}/test.pos
1714+
</storage>
1715+
</source>
1716+
EOF
1717+
expected_warning_message = "[warn]: Recommend adding #{@tmp_dir} to the exclusion path of your antivirus software on Windows"
1718+
assert_log_matches(create_cmdline(conf_path, '--dry-run'),
1719+
expected_warning_message)
1720+
end
1721+
1722+
test "no warn storage local on memory" do
1723+
omit "skip antivirus exclusion path about memory storage local (Windows)" unless Fluent.windows?
1724+
conf_path = create_conf_file("no_warn_storage_local.conf", <<~EOF)
1725+
<system>
1726+
config_include_dir ""
1727+
</system>
1728+
<source>
1729+
@type sample
1730+
tag t1
1731+
<storage>
1732+
@type local
1733+
</storage>
1734+
</source>
1735+
EOF
1736+
expected_warning_message = "[warn]: Recommend adding #{@tmp_dir} to the exclusion path of your antivirus software on Windows"
1737+
assert_log_matches(create_cmdline(conf_path, '--dry-run'),
1738+
"Using on-memory store.", patterns_not_match: [expected_warning_message])
1739+
end
1740+
end
16821741
end

0 commit comments

Comments
 (0)