Nmap Development mailing list archives

Re: NSE Script Arguments (Was: Script selection - Gsoc)


From: Patrick Donnelly <batrick () batbytes com>
Date: Mon, 5 Apr 2010 01:13:56 -0400

On Mon, Apr 5, 2010 at 12:37 AM, Kris Katterjohn <katterjohn () gmail com> wrote:
On 04/04/2010 11:14 PM, Patrick Donnelly wrote:
I'm undecided on whether we should strip some "identifier" for script
arguments in the above code snippet. Something like this:

arg["ldap-brute.username"] = arg["ldap-brute.username"] or "foo"

versus

arg["username"] = arg["username"] or "foo" -- the ldap-brute prefix is
inferred by nse_main.lua

I think I prefer the former because many scripts "share" the same argument.


I don't like the former, since it's uglier than the latter and seems redundant
to have the script name prefix in the argument name given to that script.

I say just have the arguments with the script id in the name take precedence
over the same argument without the explicit prefix.  This is what I thought it
was used for anyway, and to allow (as you said) for scripts to share args.

The showing below assumes a user runs a script "script" and the evaluations
take place in the context of "script".

If a user specifies "script.user=kris" then

arg["user"] => "kris"

and if a user specifies "user=kris" then

arg["user"] => "kris"

but if a user specifies "script.user=patrick,user=kris" then

arg["user"] => "patrick"

since the prefixed argument takes precedence over the other when used in the
context of the script "script".  So the use of the explicit script prefix is
transparent to the script, and I don't see a problem with this aspect.

Do we have scripts that would benefit from this inheritance structure?

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

Current thread: