di/clamav-validator

Custom Laravel 5 anti-virus validator for file uploads.
2,287
Install
composer require di/clamav-validator
Latest Version:1.3.2
PHP:>=5.5.0
License:MIT
Last Updated:Dec 9, 2023
Links: GitHub  ·  Packagist
Maintainer: matrunchyk

ClamAV Validator For Laravel 5

SensioLabsInsight Code Coverage Code Quality Build Status Latest Stable Version License

Custom Laravel 5 anti-virus validator for file uploads.

Requirements

You must have ClamAV anti-virus scanner running on the server to make this package work.

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 clamav-daemon

# Update virus definitions
sudo freshclam

# Start the scanner service
sudo service clamav-daemon start

This package is not tested on windows, but if you have ClamAV running (usually on port 3310) it should work.

Installation

1. Install the package through Composer.

$ composer require di/clamav-validator

2. Add the service provider (for Laravel 5.4 or below)

This package supports Laravel new Package Discovery.

If you are using Laravel < 5.5, you need to add DI\ClamavValidator\ClamavValidatorServiceProvider::class to your providers array in config/app.php:

'providers' => array(
	// ...

	DI\ClamavValidator\ClamavValidatorServiceProvider::class,
),

Usage

Use it like any Validator rule:

$rules = array(
	'my_file_field' => 'clamav',
);

Configuration

By default the package will try to connect the clamav daemon via the default socket file (/var/run/clamav/clamd.ctl) and if it fails it will try the tcp port (127.0.0.1:3310)

But you can set the CLAMAV_UNIX_SOCKET (socket file path) or CLAMAV_TCP_SOCKET (host:port) environment variables to override this.

Credits

Krishnaprasad MG [@sunspikes]

Related Packages

sunspikes/clamav-validator

Custom Laravel anti-virus validator for file uploads using ClamAV.

2,331,672 377
tylercd100/laravel-validator-color

Validate that a certain value is a valid CSS color string in Laravel 5

81,503 15
proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rul...

2,445,464 1,140
rap2hpoutre/laravel-credit-card-validator

Laravel credit card validator

132,950 21
tylercd100/laravel-validator-phone

Validate that a phone number is in the correct format

4,377 3