jonjomckay / quahog

A PHP client library for the ClamAV clamd daemon
MIT License
80 stars 23 forks source link

Multiple uploaded files #40

Closed david-vde closed 5 years ago

david-vde commented 5 years ago

Hello

When I'm trying to check multiple uploaded files, the first one is scanned correctly but the second one give me an error :

PHP Warning: socket_last_error(): supplied resource is not a valid Socket resource in /***/vendor/clue/socket-raw/src/Exception.php on line 21

I also tried to check 2 times the same file and the second time I check it same error.

Looks like I can use clamav only on one file at time... why?

I'm using scanFile method

I can't use multiScanfile method as I don't want to scan a whole dir....

any idea?

SenseException commented 5 years ago

I need more information for this issue. Do you loop through the uploaded files using scanFile on each?

Or can you create an example to recreate this error behaviour or create a failing functional/integration test?

david-vde commented 5 years ago

Hello

This is working without errors :

$socket = (new \Socket\Raw\Factory())->createClient('unix:///***/clamd.ctl');
$quahog = new \Xenolope\Quahog\Client($socket, 30, PHP_NORMAL_READ);
$result = $quahog->scanFile(__DIR__.'/test.jpg');

This is NOT working, it fail when calling the second scanFile method (the both files exists):

$socket = (new \Socket\Raw\Factory())->createClient('unix:///***/clamd.ctl');
$quahog = new \Xenolope\Quahog\Client($socket, 30, PHP_NORMAL_READ);
$result = $quahog->scanFile(__DIR__.'/test.jpg');
$result = $quahog->scanFile(__DIR__.'/test2.jpg');

And this works too :

$socket = (new \Socket\Raw\Factory())->createClient('unix:///***/clamd.ctl');
$quahog = new \Xenolope\Quahog\Client($socket, 30, PHP_NORMAL_READ);
$result = $quahog->scanFile(__DIR__.'/test2.jpg');

So this is not even related to the fact that the files are uploaded or not.

Thank you very much for your help

david-vde commented 5 years ago

Doh.. Ok I got it.... I have to start a session using startSession

MassiveHiggsField commented 5 years ago

https://en.wikipedia.org/wiki/Rubber_duck_debugging :smiley:

david-vde commented 5 years ago

https://en.wikipedia.org/wiki/Rubber_duck_debugging 😃

Indeed haha

SenseException commented 5 years ago

I once told a colleague that I offer RaaS.