Perl、ClamAV、扫描流中的病毒

Perl, ClamAV, scan a stream for viruses

我有一个 perl 应用程序。我需要对一些文件进行病毒扫描。

我可以使用 ClamAV 和模块 File::Scan::ClamAV。 如果我需要扫描存储在磁盘上的某些文件或将文件加载到内存(到某个变量),它就可以工作。

但是我的应用程序没有完整的文件。它只有一个输入流(打开的套接字)。它从此套接字读取并写入其他输出流。

我可以通过 ClamAV 以某种方式传递流吗?想将我的输入流转发到 clamav 并从中读取数据但最后得到一些扫描结果?

模块ClamAV::Client seems to provide a means to scan streams with the scan_stream method.

以下是我认为文档中令人困惑的工作原理:

use ClamAV::Client;

# Try using socket options from clamd.conf, or use default socket:
my $scanner = ClamAV::Client->new();

# Scan a stream, i.e. read from an I/O handle:
my $result = $scanner->scan_stream($handle);

# $result is the name of a virus signature, or undef
die "infected" if $result;

请注意,我还没有尝试过。