kylefarris / clamscan

A robust ClamAV virus scanning library supporting scanning files, directories, and streams with local sockets, local/remote TCP, and local clamscan/clamdscan binaries (with failover).
MIT License
236 stars 69 forks source link

Socket support #7

Closed nicolaspeixoto closed 5 years ago

nicolaspeixoto commented 9 years ago

What do you think about support scan using tcp socket?

kylefarris commented 9 years ago

I'm open to any ideas! Could you elaborate on exactly what you're looking for?

kylefarris commented 9 years ago

Ohhh... I think you mean supporting a remote clamscan server via TCP socket. I definitely think this could be possible but it would take a bit of work. Would you like to try and get this to work? If not, I can put this on the backburner as a really good idea that I don't exactly have time to work on at the moment.

kylefarris commented 9 years ago

I've made a new branch called sockets and committed some code to it. The idea was intriguing enough that I think I'll try and get this working sooner rather than later.

kylefarris commented 9 years ago

18 Commits in. Almost there. Just need to tweak a few things and write some tests.

nicolaspeixoto commented 9 years ago

Nice job Kyle! do you want help in anything?

kylefarris commented 9 years ago

Thanks! I've learned a lot—it's been fun. I think I've got it, though. I'll let you know when I I've lost completed it and you can clone it and test it in your environment to make sure it works as expected. I'll wait for your response before publishing to NPM.

kylefarris commented 9 years ago

I just wanted to say that I haven't given up on this, I've just been busy. They code is more or less done at this point, I'm just still working on the test cases and making sure it will work perfectly for everyone when it gets released.

Thanks for your patience--I'm doing this in between my job and other side projects.

nicolaspeixoto commented 9 years ago

There is no problem about it Kyle. Where did you stop? Could i help you?

kylefarris commented 9 years ago

Hey @nicolaspeixoto. Well, you got me motivated tonight so I finished writing the tests. Everything seems to be working. I haven't run it through any kind of rigorous real-world examples, yet, but, I think it should work just fine.

What you can do to help is checkout the sockets branch of the repository and see if you can run it through some real examples of how you're planning on using it and get back to me with any issues you might come across. I really want to make sure this is working perfectly before I merge back to Master and push out version 0.9.0 on NPM.

If you could do that, I'd be incredibly grateful. Don't test it on live stuff! :D

nicolaspeixoto commented 9 years ago

Hey @kylefarris, i started to test with a simple script:

var clam = require('./')({
    remove_infected: true, // Removes files if they are infected
    quarantine_infected: '~/infected/', // Move file here. remove_infected must be FALSE, though.
    scan_recursively: false, // Choosing false here will save some CPU cycles
    scan_log: '/var/log/node-clam', // You're a detail-oriented security professional.
    debug_mode: true, // This will put some debug info in your js console
    clamdscan: {
        host: '127.0.0.1', // If you want to connect locally but not through socket
        port: 3310, // Because, why not
    },
    preference: 'clamdscan' // If clamscan is found and active, it will be used by default
});

clam.scan_file('/home/nicolas/mytest.pdf', function(){
    console.log("callback");
});

But the scan_file function didn't call the callback function. I think it didn't send the file to the Clamav server too.

This is the log from execution:

node-clam: Initially testing socket/tcp connection to clamscan server.
1: node-clam: Socket connection created: test_availability
node-clam: using remote server: 127.0.0.1:3310
node-clam: Established connection to clamscan server for testing!
2: node-clam: Socket connection created: scan_stream
node-clam: using remote server: 127.0.0.1:3310
node-clam: PING-PONG!
3: node-clam: Socket connection closed: test_availability
4: node-clam: Socket connection closed: scan_stream
kylefarris commented 5 years ago

Version 1.0.0 is out and supports this feature. Finally.