Download the PHP package jodeveloper/upload-file-scanner without Composer
On this page you can find all versions of the php package jodeveloper/upload-file-scanner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jodeveloper/upload-file-scanner
More information about jodeveloper/upload-file-scanner
Files in jodeveloper/upload-file-scanner
Package upload-file-scanner
Short Description A Laravel package for scanning uploaded files using ClamAV
License MIT
Homepage https://github.com/jodeveloper/upload-file-scanner
Informations about the package upload-file-scanner
Laravel ClamAV Upload Scanner
A clean, Laravel-native way to scan uploaded files using ClamAV. This package provides a simple API for virus scanning in your file upload validation and storage pipelines.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Requirements
- PHP 8.3 or higher
- Laravel 11.0 or 12.0
- ClamAV installed on your server (clamscan binary)
Installing ClamAV
macOS
After installation, you may need to update the virus definitions:
Ubuntu/Debian
Update virus definitions:
CentOS/RHEL
Update virus definitions:
From Source
For detailed instructions on installing ClamAV from source, see the official ClamAV documentation.
Verifying Installation
After installation, verify that ClamAV is accessible:
This should display ClamAV version information.
Usage
Using the Facade (Recommended)
Using the Validation Rule
The package provides a Laravel validation rule for easy integration:
Simple approach (recommended):
For more control, use the object-based approach:
Example Controller
Configuration
ClamAV Binary Path
By default, the package assumes clamscan is in your system PATH. If you have a custom installation:
Scan Timeout
The default timeout is 30 seconds. Adjust for large files:
Scan Options
Add additional options to pass to clamscan in the config file:
Warning: Use caution with options like --remove which will delete infected files.
Security Philosophy
This Package is a Secondary Defense
This package provides virus scanning as a secondary security layer. It should not be your only defense against malicious file uploads.
Required Additional Security Measures
- Re-encoding Images: Always re-encode uploaded images to strip potential embedded payloads
- File Type Validation: Validate MIME types and file extensions
- Content Inspection: Inspect file contents, not just extensions
- Storage Location: Store uploads outside of the public web root
- Access Control: Implement proper authentication and authorization
SVG Files are Unsafe
SVG files can contain JavaScript and should be treated with extreme caution. Always sanitize SVG files before storage or serving.
Public Storage is Dangerous
Never store user uploads in publicly accessible directories without proper access controls. Use Laravel's Storage::disk('local') or implement signed URLs for public access.
Exception Handling
The package throws ScanFailedException when:
- ClamAV binary is not found
- Process crashes or fails to execute
- Timeout occurs
- Other execution errors occur
Infected files do not throw exceptions. They return a ScanResult where hasVirus() returns true.
API Reference
Facade
Contract
ScanResult
The ScanResult object is immutable and exposes readonly properties:
Helper methods are also available:
CleanFile Rule
Implements Illuminate\Contracts\Validation\Rule. Can be used as an object or string rule (clean_file).
Testing
The test suite mocks all ClamAV execution - no actual scanning occurs during tests.
Limitations
- This package does not provide automatic scanning of all uploads
- No UI is included
- No opinionated storage logic is provided
- ClamAV must be installed and accessible on your server
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Joe Developer
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of upload-file-scanner with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0
symfony/process Version ^7.0