Nmap Development mailing list archives

Re: [NSE][PATCH] only show script errors in verbose mode


From: "Patrick Donnelly" <batrick.donnelly () gmail com>
Date: Thu, 25 Sep 2008 23:19:26 -0600

On Thu, Sep 25, 2008 at 10:52 PM, David Fifield <david () bamsoftware com> wrote:
Yes, now we're getting somewhere. Maybe we shouldn't use newproxy if
it's not documented, but the technique of using a userdata to represent
a unique type sounds perfect. I can't see the rest of the
implementation, so maybe you can provide a sketch of it.

Basically, I would see us having a register_error function somewhere
that would associate a string error identifier with the unique
userdata object. The package.errors table would have the string
associated with the userdata and vice versa, literally:

package.errors.MISSING_SYSTEM_DEPENDENCY = newproxy()
package.errors[package.errors.MISSING_SYSTEM_DEPENDENCY] =
"MISSING_SYSTEM_DEPENDENCY"

So, when we catch an error in C via pcall we can quickly identify the
type of error. Internally we may have a "degree of severity" (or
perhaps simply verbosity) which we use to notify the user.

Where does the error get raised and how?

The error would be raised by the C module (possibly by a script or Lua
module, doesn't matter too much). The module could quickly check if a
dependency is missing (e.g. OpenSSL) and raise the error.

Is there a way to associate a different string with each instance of an error?

Yes, as shown above.

The more I think about it, the more I think it would be good to display
the require errors whenever a script is requested specifically. So

nmap --script=default

would hide the SSH-hostkey error, while

nmap --script=SSH-hostkey.nse

would show it. Is there a nice way to differentiate between scripts
loaded by name (or directory) and scripts loaded implicitly through a
category? We might want to handle warnings for the two cases
differently. This isn't urgent, just something to think about.

In the current implementation of the script engine, this is a pretty
difficult thing to do (or rather, keep track of).

Cheers,

-- 
-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: