Giter Site home page Giter Site logo

clamav.js's People

Contributors

davidbz avatar lirantal avatar nalbion avatar yongtang 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

Watchers

 avatar  avatar  avatar  avatar

clamav.js's Issues

race condition between socket.connect and input stream

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);

Why don't you use the callback on socket.complete?

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!

test-file.txt

add support for passing custom/external readstreams

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.

Allow to pass the file through the stream

Using the stream functionality, It would be awesome if I could pass the stream through the other side.

Example:

  1. Accept a read stream
  2. pass the read stream through clamav.js
  3. pass the now verified read stream to a gzip stream
  4. pass the gzipped stream through an encryption stream
  5. pass the stream to the write stream (external storage service like s3 or just the file system)

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?

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.