Nmap Development mailing list archives
Re: [NSE][PATCH] only show script errors in verbose mode
From: David Fifield <david () bamsoftware com>
Date: Wed, 24 Sep 2008 15:03:03 -0600
On Wed, Sep 24, 2008 at 02:20:29PM -0600, David Fifield wrote:
You'll have to forgive me, I'm (still) pretty new to Lua. Is there a way to signal a special error code that would mean a module is missing, but it's an error that can be ignored? The error would be raised in the "else" branch of the "if" in Sven's example, or it could even be raised in an alternate compiled openssl module that didn't have any functions, just raised the error. Then this special error could be ignored, and normal require errors could continue to be reported.
Here's what I'm thinking:
Index: SSH-hostkey.nse
===================================================================
--- SSH-hostkey.nse (revision 10361)
+++ SSH-hostkey.nse (working copy)
@@ -32,12 +32,15 @@
require("stdnse")
require("shortport")
-require("openssl")
require("bin")
require("bit")
require("base64")
require("hash")
+if not pcall(require, "openssl") then
+ error(stdnse.quiet_error("The optional openssl module is not installed"))
+end
+
id = "SSH Hostkey"
author = "Sven Klemm <sven () c3d2 de>"
description = "Show SSH Hostkeys"
stdnse.quiet_error would return a type of object that NSE could check
for and avoid printing, unless debugging were enabled. Of course the
whole if..end could be bundled into its own function, something like
stdnse.quiet_require.
Another option is to raise the quiet error from within the compiled
openssl module, but I don't know if that would work as it appears the
compiled modules are loaded all at once.
David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org
Current thread:
- Re: [NSE][PATCH] only show script errors in verbose mode, (continued)
- Re: [NSE][PATCH] only show script errors in verbose mode Diman Todorov (Sep 23)
- Re: [NSE][PATCH] only show script errors in verbose mode Sven Klemm (Sep 23)
- Re: [NSE][PATCH] only show script errors in verbose mode Patrick Donnelly (Sep 23)
- Re: [NSE][PATCH] only show script errors in verbose mode Sven Klemm (Sep 23)
- Re: [NSE][PATCH] only show script errors in verbose mode David Fifield (Sep 23)
- Re: [NSE][PATCH] only show script errors in verbose mode Fyodor (Sep 23)
- Re: [NSE][PATCH] only show script errors in verbose mode Sven Klemm (Sep 24)
- Re: [NSE][PATCH] only show script errors in verbose mode David Fifield (Sep 24)
- Re: [NSE][PATCH] only show script errors in verbose mode Patrick Donnelly (Sep 24)
- Re: [NSE][PATCH] only show script errors in verbose mode David Fifield (Sep 24)
- Re: [NSE][PATCH] only show script errors in verbose mode David Fifield (Sep 24)
- Re: [NSE][PATCH] only show script errors in verbose mode Patrick Donnelly (Sep 25)
- Re: [NSE][PATCH] only show script errors in verbose mode David Fifield (Sep 25)
- Re: [NSE][PATCH] only show script errors in verbose mode Patrick Donnelly (Sep 25)
- Re: [NSE][PATCH] only show script errors in verbose mode David Fifield (Sep 25)
- Re: [NSE][PATCH] only show script errors in verbose mode Patrick Donnelly (Sep 25)
- Re: [NSE][PATCH] only show script errors in verbose mode David Fifield (Sep 26)
- Re: [NSE][PATCH] only show script errors in verbose mode Patrick Donnelly (Sep 26)
- Re: [NSE][PATCH] only show script errors in verbose mode David Fifield (Sep 26)
- Re: [NSE][PATCH] only show script errors in verbose mode Patrick Donnelly (Sep 26)
- Re: [NSE][PATCH] only show script errors in verbose mode Sven Klemm (Sep 24)
