#clam-av #clamd #anitvirus

revolt_clamav-client

ClamAV 客户端库

2 个版本

0.1.5 2023年6月5日
0.1.4 2023年6月5日

#3 in #clamd

Download history 8/week @ 2024-04-08 5/week @ 2024-04-22 3/week @ 2024-04-29 8/week @ 2024-05-13 18/week @ 2024-05-20 13/week @ 2024-05-27 10/week @ 2024-06-03 12/week @ 2024-06-10 1/week @ 2024-06-17 129/week @ 2024-06-24 309/week @ 2024-07-01 312/week @ 2024-07-08 315/week @ 2024-07-15 29/week @ 2024-07-22

1,004 每月下载量

MIT 许可证

7KB
114

Rust ClamAV 客户端

一个简单的 ClamAV 客户端,可以将文件流式传输到 clamd 进行病毒扫描。

请注意:函数 ping_socketscan_socket 只在 Unix 平台上可用。

安装

将此内容添加到您的 Cargo.toml

[dependencies]
clamav-client = "0.1.3"

使用方法

通过ping服务器以获得响应来确保 ClamD 正在运行

let clamd_host_address = "localhost:3310";

let clamd_available = match clamav_client::ping_tcp(clamd_host_address) {
    Ok(ping_response) => ping_response == b"PONG\0",
    Err(_) => false,
};

if !clamd_available {
    println!("Cannot ping clamd at {}", clamd_host_address);
    return;
}

扫描文件以检测病毒

let file_path = "virus.txt";
let scan_response = clamav_client::scan_tcp(file_path, clamd_host_address, None).unwrap();
let file_clean = clamav_client::clean(&scan_response).unwrap();
if file_clean {
    println!("No virus found in {}", file_path);
} else {
    println!("The file {} is infected!", file_path);
}

从内存中扫描缓冲区

let buffer = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"
    .bytes()
    .collect::<Vec<u8>>();

let scan_response = clamav_client::scan_buffer_tcp(buffer, clamd_host_address, None).unwrap();
let file_clean = clamav_client::clean(&scan_response).unwrap();
assert!(!file_clean);

无运行时依赖