sunspikes/clamav-validator
Composer 安装命令:
composer require sunspikes/clamav-validator
包简介
Custom Laravel anti-virus validator for file uploads using ClamAV.
README 文档
README
A custom Laravel virus validator based on ClamAV anti-virus scanner for file uploads.
Requirements
- PHP >= 8.0
- Laravel 9.x, 10.x, 11.x, 12.x, or 13.x
- ClamAV anti-virus scanner running on the server
You can see the ClamAV installation instructions on the official ClamAV documentation.
For example on an Ubuntu machine, you can do:
# Install clamav virus scanner sudo apt-get update && sudo apt-get install -y clamav-daemon # Update virus definitions sudo freshclam # Start the scanner service sudo systemctl enable --now clamav-daemon clamav-freshclam
This package is not tested on Windows, but if you have ClamAV running (usually on port 3310) it should work.
You will also need to have sockets extension installed and enabled (all executions without this module will fail with this error - "Use of undefined constant 'AF_INET'").
Installation
1. Install the package through Composer.
composer require sunspikes/clamav-validator
2. Publish assets from the vendor package
Config file
The default configuration file does use ENV to override the defaults. If you want to change the configuration file
anyway you run the following command to publish the package config file:
php artisan vendor:publish --provider="Sunspikes\ClamavValidator\ClamavValidatorServiceProvider" --tag=config
Once the command is finished you should have a config/clamav.php file that will be used as well.
Language files
If you want to customize the translation or add your own language you can run the following command to publish the language files to a folder you maintain:
php artisan vendor:publish --provider="Sunspikes\ClamavValidator\ClamavValidatorServiceProvider" --tag=lang
This will copy the language files to lang/vendor/clamav-validator.
Configuration
The package can be configured using environment variables:
| Environment Variable | Default | Description |
|---|---|---|
CLAMAV_PREFERRED_SOCKET |
unix_socket |
Socket type: unix_socket or tcp_socket |
CLAMAV_UNIX_SOCKET |
/var/run/clamav/clamd.ctl |
Path to the ClamAV unix socket |
CLAMAV_TCP_SOCKET |
tcp://127.0.0.1:3310 |
TCP socket connection string |
CLAMAV_SOCKET_CONNECT_TIMEOUT |
null |
Connection timeout in seconds (null = no limit) |
CLAMAV_SOCKET_READ_TIMEOUT |
30 |
Read timeout in seconds |
CLAMAV_CLIENT_EXCEPTIONS |
false |
Throw exceptions on scan failures instead of returning validation failure |
CLAMAV_SKIP_VALIDATION |
false |
Skip virus scanning entirely (useful for local development) |
Usage
Use it like any Validator rule:
$rules = [ 'file' => 'required|file|clamav', ];
Or in a Form Request:
class UploadRequest extends FormRequest { public function rules(): array { return [ 'file' => 'required|file|clamav', ]; } }
ClamavValidator will automatically run multiple files one-by-one through ClamAV in case file represents multiple uploaded files.
Author
Krishnaprasad MG [@sunspikes] and other awesome contributors
sunspikes/clamav-validator 适用场景与选型建议
sunspikes/clamav-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.09M 次下载、GitHub Stars 达 370, 最近一次更新时间为 2014 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「validator」 「laravel」 「virus」 「clamav」 「antivirus」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sunspikes/clamav-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sunspikes/clamav-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sunspikes/clamav-validator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
VirusTotal Public API v2.0 PHP Wrapper
Runn Me! Validation and Sanitization Library
Extension for Opis JSON Schema
AMWSCAN (Antimalware Scanner) is a php antimalware/antivirus scanner console script written in php for scan your project. This can work on php projects and a lot of others platform.
This repository provides a virus scan validator constraint for Symfony-based projects.
A Tissue adapter that implements the ClamAV virus-scanner
统计信息
- 总下载量: 2.09M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 371
- 点击次数: 31
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-04