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

Unknown Command: PING! #38

Closed rohinadalja closed 5 years ago

rohinadalja commented 5 years ago

When checking the availability of the clamd service if socket or host/port are provided, the following code in index.js is executed: client.write('PING!');, expecting a response back: PONG.

However, the current version of clamd is looking for a PING command without the exclamation point. Hence, clamd seems to reject this as an "UNKNOWN COMMAND". Running the current test suite, we can see the following error in the debug logs each time:

Fri Sep 13 10:03:23 2019 -> Command PING has trailing garbage!
Fri Sep 13 10:03:23 2019 -> got command PING! (5, 0), argument:
Fri Sep 13 10:03:23 2019 -> Receive thread: closing conn (FD 9), group finished
Fri Sep 13 10:03:23 2019 -> Consumed entire command
kylefarris commented 5 years ago

Well, that's interesting. It's gonna make it difficult to write a test if they changed the command on us between versions..., ugh. I'll do some research to see what's going on.

kylefarris commented 5 years ago

After a quick Googling, it looks like there never should have been a "!" at the end of PING in the first place. I'm not sure why that was added but I did a git blame on that line and saw that it was added about 5 months ago. The concerning thing is that tests still passed so I'm going to be looking into the unit test(s) for that bit of code. I've also went ahead and removed the "!" from the command and will release the patch once tests are fixed as v1.0.6.

kylefarris commented 5 years ago

The new version will actually be v1.1.0 as I added a new private method _ping to the library so that it could be more-easily tested. It's been published to NPM. Thanks for the bug report!