Code Monkey home page Code Monkey logo

clamav-validator's People

Contributors

ashleyshenton avatar chrisleetw avatar damyon avatar guusleeuw-ign avatar hordijk avatar imgrant avatar levivb avatar marksalmon avatar sbine avatar sunspikes avatar thiagobbt avatar tudorrrrrr avatar tullaris avatar vigneshgurusamy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clamav-validator's Issues

Clamav-Validator fails every Upload

Hi,

I'm using Clamav-Validator on an Ubuntu-Machine with Laravel 5.2, but the Validator fails every Upload with the Standard-Error-Message from the Validator.

Do you have a hint to hunt the Problem down? ;-)

Thanks in Advance!
Carsten

i have bun in production server

[2021-07-23 14:10:31] local.ERROR: ClamAV scanner client failed with error "file_exists(): open_basedir restriction in effect. File(/var/run/clamav/clamd.ctl) is not within the allowed path(s): (/home/gandom/:/tmp/:/var/tmp/:/opt/alt/php74/usr/share/pear/:/dev/urandom:/usr/local/php74/lib/:/usr/local/php74/lib/:/usr/local/php73/lib/:/usr/local/lib/php/)" {"userId":1,"exception":"[object] (Sunspikes\ClamavValidator\ClamavValidatorException(code: 0): ClamAV scanner client failed with error "file_exists(): open_basedir restriction in effect. File(/var/run/clamav/clamd.ctl) is not within the allowed path(s): (/home/gandom/:/tmp/:/var/tmp/:/opt/alt/php74/usr/share/pear/:/dev/urandom:/usr/local/php74/lib/:/usr/local/php74/lib/:/usr/local/php73/lib/:/usr/local/lib/php/)" at /home/gandom/domains/gandom.click/public_html/vendor/sunspikes/clamav-validator/src/ClamavValidator/ClamavValidatorException.php:39)

i fallow this tutorial

https://techservicedoc.com/how-to-install-clamav-antivirus-tool-on-rhel-centos-7/

Access denied

Hello, I'm trying to use the Validator. But I'm getting a false positives. If i dd($result); inside of the validator, this is what I get:

array:3 [
  "filename" => "/tmp/php35EYkO"
  "reason" => "Access denied."
  "status" => "ERROR"
]

Would you know why? Thanks.

Add option for on-demand scan instead of daemon

Feature request:

Since the validation is an on-demand function, there is little value in using the daemon.

Calling clamav on instead on-demand follows a more coherent architecture.

This would reduce the idle memory footprint by ~250MB per instance for monolithic apps.

Eicar test signature and test sources folder

Hello,

We've been trying to use your package for ClamAV scanning in Laravel - which has been fantastic in helping us scan files automatically - but we've run into a few issues with the Eicar test signature being directly included in the package source.

This is often tripping out AV scanners both on developer machines when the package is pulled in and is likely to cause some frustration with IT security types receiving alerts for the test signature, and also triggering alerts on production servers when AV scanning and the package is deployed as part of a site.

Could you possibly consider perhaps exporting the package with the tests folder excluded (e.g. as Laravel does here in a .gitattributes with its tests folder - https://github.com/laravel/framework/blob/5.5/.gitattributes) so that the Eicar test signature isn't pulled down onto the machine when we use the package?

Open to any other suggestions also to help prevent the Eicar test signature from causing any false positives too.

Thanks for your help!

Publishing translation files doesn't work

Issue

Running php artisan vendor:publish --provider="Sunspikes\ClamavValidator\ClamavValidatorServiceProvider" --tag=lang does not publish the language translation file to the correct location.

To reproduce

  1. Install sunspikes/clamav-validator with Composer
  2. Publish the language file with the above Artisan invocation
  3. Observe that there is no clamav-validator directory under resources/lang/vendor

Expectation

The language file should be published to resources/lang/vendor/clamav-validator/en/validation.php.

Caveats

I already had a non-vendor translation file called validation.php in resources/lang/en — attempting to publish the language file for this package did not overwrite it, but I suspect that if it were not present, then the clamav-validator language file would have been copied here.

Errors should not always throw exceptions

Exceptions thrown from this validator hides related validation failures.

Example, user uploads a file that is too large for clamav (> 25Mb). ClamAV will close the
stream once it hits it's own configured limit. Throwing an exception in this case will show
the user a 500 internal error (production environment), instead of showing a useful message (the file size
validation error in the upload form).

Error when call test

  protected $translator;
   protected $clean_data;
   protected $virus_data;
   protected $error_data;
   protected $rules;
   protected $messages;
   public function setUp()
   {
       $this->translator = Mockery::mock(Translator::class);
       $this->translator->shouldReceive('get')->with('validation.custom.file.clamav')->andReturn('error');
       $this->translator->shouldReceive('get')->with('validation.attributes')->andReturn([]);
       $this->translator->shouldReceive('trans');
       $this->clean_data = [
           'file' => "/var/www/html/gardenannex/storage/logs/clamav_test.txt"
       ];
       $this->virus_data = [
           'file' => "/var/www/html/gardenannex/storage/logs/clamav_test.txt"
       ];
       $this->error_data = [
           'file' => "/var/www/html/gardenannex/storage/logs/clamav_test.txt"
       ];
       $this->messages = [];
       $config = new Config();
       $config->shouldReceive('get')->with('clamav.preferred_socket')->andReturn('unix_socket');
       $config->shouldReceive('get')->with('clamav.unix_socket')->andReturn('/var/run/clamd.scan/clamd.sock');
       $config->shouldReceive('get')->with('clamav.tcp_socket')->andReturn('tcp://127.0.0.1:3310');
       $config->shouldReceive('get')->with('clamav.socket_read_timeout')->andReturn(30);
       $config->shouldReceive('get')->with('clamav.skip_validation')->andReturn(false);
       $application = Mockery::mock(Application::class, ['make' => $config]);
       Facade::setFacadeApplication($application);
   }
 ```

public function scan() {
$this->setUp();
$validator = new ClamavValidator(
$this->translator,
$this->clean_data,
['file' => 'clamav'],
$this->messages
);
$this->assertTrue($validator->passes())
}

}

Error: 

`Fatal error: Uncaught Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_1_Illuminate_Config_Repository::get('app.debug', NULL). Either the method was unexpected or its arguments matched no expected argument list for this method in D:\EYEGLASSES\Source\gardenannex\vendor\mockery\mockery\library\Mockery\ExpectationDirector.php:92 Stack trace: #0 D:\EYEGLASSES\Source\gardenannex\vendor\mockery\mockery\library\Mockery\Loader\EvalLoader.php(34) : eval()'d code(868): Mockery\ExpectationDirector->call(Array) #1 D:\EYEGLASSES\Source\gardenannex\vendor\mockery\mockery\library\Mockery\Loader\EvalLoader.php(34) : eval()'d code(974): Mockery_1_Illuminate_Config_Repository->_mockery_handleMethodCall('get', Array) #2 D:\EYEGLASSES\Source\gardenannex\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php(283): Mockery_1_Illuminate_Config_Repository->get('app.debug', NULL) #3 D:\EYEGLASSES\Source\gardenannex\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(284): c in D:\EYEGLASSES\Source\gardenannex\vendor\mockery\mockery\library\Mockery\ExpectationDirector.php on line 92`

Add support for Laravel 10

Is it possible to add support for illuminate/validation and illuminate/support ^10.0 now that Laravel 10 was released?

Laravel 6.0 support

Hi,

Could you please update this package's dependency to Laravel 6.0. Current this package requires illuminate/validation ^5.0.
Best regards,

how i use this package out of validator ?

hi . i have file manager and i want use event uploaded file , in bellow code after file uploaded i want scan it with calmAv

please help me thank you

\Event::listen('Alexusmai\LaravelFileManager\Events\FilesUploaded',
    function ($event) {
        \Log::info('FilesUploaded:', [
            $event->disk(),
            $event->path(),
            $event->files(),
            $event->overwrite(),
        ]);
    }
);

top code return

[2021-07-21 15:02:43] local.INFO: FilesUploading: ["public","",[{"name":"WhatsApp Image 2021-07-06 at 19.22.59 (1).jpeg","path":"/WhatsApp Image 2021-07-06 at 19.22.59 (1).jpeg","extension":"jpg"}],false]

i have disk and path , then i can get full path of file , now i need to validate path of file with calmav-validator

not compatible with laravel 5.1.23

i get the following:

BadMethodCallException in compiled.php line 4972:
Call to undefined method [package]
in compiled.php line 4972
at ServiceProvider->__call('package', array('sunspikes/clamav-validator', 'clamav-validator')) in ClamavValidatorServiceProvider.php line 31
at ClamavValidatorServiceProvider->package('sunspikes/clamav-validator', 'clamav-validator') in ClamavValidatorServiceProvider.php line 31
at ClamavValidatorServiceProvider->boot()
at call_user_func_array(array(object(ClamavValidatorServiceProvider), 'boot'), array()) in compiled.php line 1181
at Container->call(array(object(ClamavValidatorServiceProvider), 'boot')) in compiled.php line 1799
at Application->bootProvider(object(ClamavValidatorServiceProvider)) in compiled.php line 1791
at Application->Illuminate\Foundation{closure}(object(ClamavValidatorServiceProvider), '23')
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(ControllerServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FormRequestServiceProvider), object(FoundationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ValidationServiceProvider), object(ViewServiceProvider), object(HoneypotServiceProvider), object(ValidationServiceProvider), object(EntrustServiceProvider), object(ServiceProvider), object(AppServiceProvider), object(AuthServiceProvider), object(EventServiceProvider), object(RouteServiceProvider), object(CashierServiceProvider), object(ClamavValidatorServiceProvider), object(TranslationServiceProvider)), object(Closure)) in compiled.php line 1792
at Application->boot() in compiled.php line 2133
at BootProviders->bootstrap(object(CmmApp)) in compiled.php line 1578
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in compiled.php line 2297
at Kernel->bootstrap() in compiled.php line 2250
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2234
at Kernel->handle(object(Request)) in index.php line 54

Unresolvable dependency error?

Is it just me? ! can't figure this out. When I try to validate, I get this error:

local.ERROR: Unresolvable dependency resolving [Parameter #1 [ <required> array $data ]] in class Sunspikes\ClamavValidator\ClamavValidator {"userId":1077,"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Unresolvable dependency resolving [Parameter #1 [ <required> array $data ]] in class Sunspikes\\ClamavValidator\\ClamavValidator at /Users/baconcheesefry/code/ib_laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php:1108)
[stacktrace]

Performance when scanning

This is not an issue as such, but I’m just curious... how long does it take to scan the uploaded file? I’m wondering about the performance impact.

Thanks!

Feature Request: enable/disable for different env

Hi,

could you please put in a little functionality that enables/disables it on certain environments, e.g. we don't need it on local. So maybe a flag in the config file like 'enabled' => env('CLAMAV_ENABLED', true) that we can set via the .env file.

Thanks!

Method [validateClamav] does not exist.

Am using Laravel 5.5, and get this error when trying to use clamav as a validator. I have installed the package, and added it to app/config.php as a provider.

Timeout error on clamav validator

We are facing intermittent issue. We are getting error as below.

ClamAV scanner client failed with error "Timeout waiting to read response"

Any idea what is reason behind it ? sometime its working fine and sometime we are getting above error.

Working with Laravel Vapor

Hi there!

Any chance someone figured out how to make it work on Vapor? I was able to install the Clamav packages on the server but not start the daemon.

I know this is not directly related to the package, but that seems to be the better place to talk about Clamav and Laravel.

Thanks !

Ed

It does not support multiple files in the same input

When I have an input that allows the upload of a single file it works fine, but when the input is multiple, it gives an error:
ErrorException: is_readable() expects parameter 1 to be a valid path, array given in /absolute/path/vendor/sunspikes/clamav-validator/src/ClamavValidator/ClamavValidator.php:52

Debian 9

I've installed Clamav using these Docker commands:

RUN freshclam
RUN service clamav-daemon start

However my Laravel code can't find the socket, even though I've told it to look at /var/run/clamav/clamd.ctl.

Laravel error: Socket operation failed: Connection refused (SOCKET_ECONNREFUSED)

Any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.