yongtang / clamav.js Goto Github PK
View Code? Open in Web Editor NEWA node.js library for ClamAV
License: MIT License
A node.js library for ClamAV
License: MIT License
if clamav daemon is not running or the socket specified is incorrect, then i currently do not receive an error in my callback. here is a patch which fixes the issue: http://pastebin.com/WbhRqad6
I'm reading an object from S3 and streaming it to a ClamAV server from Lambda:
s3.getObject(params, (err, data) => {
if (!err) {
// `data.Body` is a Buffer, need a ReadableStream
let dataStream = new stream.PassThrough();
dataStream.end(data.Body);
let scanner = clamav.createScanner(3310, clamAvHost);
scanner.scan(data, (err, object, result) => {
console.info('scanned:', err, object, result);
callback(err, result);
});
}
});
Most of the time this works, the following clamav code is executed and my callback is called.
}).on('data', function(data) {
console.info('scanning data chunk...');
status += data;
if (data.toString().indexOf("\n") !== -1) {
...
callback(...
However, often I think my call to dataStream.end(data.Body);
triggers the following code. complete()
is a no-op, there's no handling of data and my callback is not called.
stream.pipe(channel).pipe(socket).on('end', function() {
complete(stream);
}
Interestingly, these two even handlers seem to be mutually exclusive - the clamav code above is not called when the file is scanned and my callback invoked.
If I delay the call to end
everything works more reliably, but it seems a bit hacky:
setTimeout(() => dataStream.end(data.Body), 2000);
Hello, I'm testing out using your node module to send streams to clamav. Sometimes it looks like the "data" event doesn't get called. But since your code doesn't use the callback for the "close" event on the socket, it just hangs and never completes the request. On the requests that do not hit the "data" event, I can see the stream being successfully scanned in the clamav logs. I can provide clamav logs and configuration if that is helpful. Thanks.
I was wondering if this happens on very small files. So I increased the size of the file to over 500k and I still saw the same results.
Next I was wondering if it might happen when clamav uses its cache to determine that a file has already been scanned. So I changed the DisableCache configuration to 'yes' and still saw the same thing.
I'm wondering if you are doing this for a specific reason or if it is a bug?
To help you I have uploaded the file that seems to hit the "data" event sometimes, but other times it just goes directly to the "close" event.
Thanks for your help!
Currently, it only supports locally stored files by passing a pathname
into scan(). It would be great if we can also pass a ReadStream
as well. This would allow us to check files stored with GridFS or something similar.
Using the stream functionality, It would be awesome if I could pass the stream through the other side.
Example:
The line of code I'm looking at is here: https://github.com/yongtang/clamav.js/blob/master/index.js#L120
It seems to be swallowing the callback I would need to reuse the stream. Or perhaps this is already supported?
while scanning a bunch of file one of the file was having an embedded .exe file
Shouldnt it be flagged ? or some other prompt should be displayed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.