harryhorton / node-nmap

NPM package for interfacing with local NMAP installation
MIT License
67 stars 26 forks source link

Crashes if NMAP is not installed #24

Closed herrberk closed 7 years ago

herrberk commented 7 years ago

Hi John,

I've been using this module in my node application for a while and in overall it's pretty great! However there is one issue I'd like to mention here. It causes a crash when nmap is not installed locally. Here is the error message:

/home/.../node-nmap/index.js:66
            this.child.kill();
                      ^

TypeError: Cannot read property 'kill' of undefined
    at process.NmapScan.killChild (/home/.../node-nmap/index.js:66:23)
    at emitOne (events.js:96:13)
    at process.emit (events.js:188:7)
    at process._fatalException (bootstrap_node.js:296:26)

Is there a way of detecting if nmap is installed and returning an error message instead?

harryhorton commented 7 years ago

Hi,

Apologies for the late response. I can absolutely add something in to check for NMAP. The code for this was written quite a while ago, and is a bit messy relative to my current work, but if you'd want to make a pull request I'd happily test and accept. Otherwise I'll get around to it sometime this week.

harryhorton commented 7 years ago

Hi @herrberk,

I've added some error checking that will gracefully fail (via emitting an error event scan.on('error',(err)=>{})) This will return an error notifying you that nmap could not be found.

Let me know how this works out for you.

harryhorton commented 7 years ago

Added fix

herrberk commented 7 years ago

Hi John,

Sorry for the delayed response, it works great now. Thank you for the fix, I appreciate!