sunspikes / clamav-validator

Laravel virus validator based on ClamAV anti-virus scanner

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Method Illuminate\Validation\Validator::validateClamav does not exist. (Laravel 7)

VShander opened this issue · comments

After update to Laravel 7 I'm get this error ( Method Illuminate\Validation\Validator::validateClamav does not exist.) Everything worked fine on laravel 6! Can you guess what the problem is?

@VShander I just tried the library with a fresh Laravel 7 installation and i see it works expected (see below), So i guess this has something to do with your application instead.

  1. Create a new project with Laravel 7
 ~/  composer create-project --prefer-dist laravel/laravel blog                                                                                                         2255ms < Wed Mar 11 10:23:24 2020
Creating a "laravel/laravel" project at "./blog"
Installing laravel/laravel (v7.0.0)
  - Installing laravel/laravel (v7.0.0): Downloading (100%)         
Created project in /Users/user1/dev/blog
....
  1. Install clamav validator (https://github.com/sunspikes/clamav-validator#installation)
 ~/blog  composer require sunspikes/clamav-validator                                                                                                                    
Using version ^2.2 for sunspikes/clamav-validator
./composer.json has been updated
....
  1. Create a new file upload route in routes/api.php
Route::post('/upload', function (Request $request) {
    try {
        $validatedData = $request->validate(['file' => 'clamav']);
    } catch (\Illuminate\Validation\ValidationException $e) {
        return $e->errors();
    }

    /** @var UploadedFile $file */
    $file = $validatedData['file'];

    return var_export($file->isValid(), true);
});

  1. Upload an infected file (https://en.wikipedia.org/wiki/EICAR_test_file)
 ~/d/blog  http -f POST 'http://127.0.0.1:8000/api/upload' file@virus.txt                                                                                                   
HTTP/1.1 200 OK

{
    "file": [
        "file contains virus."
    ]
}
  1. Upload a clean file
 ~/d/blog  http -f POST 'http://127.0.0.1:8000/api/upload' file@clean.txt                                                                                                  
HTTP/1.1 200 OK

true