Nmap Development mailing list archives

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


From: Kris Katterjohn <katterjohn () gmail com>
Date: Mon, 05 Apr 2010 00:40:25 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/05/2010 12:13 AM, Patrick Donnelly wrote:
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?


I thought there would be more, but here's what I see off-hand:

ipidseq
qscan
whois
dns-fuzz

I don't understand why all script aren't processing args like this (I assumed
they were).  Users don't know one script to the next which ones require the
script name prefix, which don't, and which can have args which are shared.

And I don't consider this inheritance more so than simple scoping, as I've
called it since apparently mid-2008 [1].  I guess I'm one of only just a few
who views it this way?

So really I think all scripts can benefit from this, because the inconsistency
in the script prefix requirements in the argument name seems like something to
fix.

Cheers,
Kris Katterjohn

[1] http://seclists.org/nmap-dev/2008/q2/565

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJLuXfIAAoJEEQxgFs5kUfu5fEQAIClBz6S2DL3oeVWfVI7lPNa
qxZj5b2SowVf2wdtICUtP01nfy/SCJTtXj8/wXVakIrEiNtyTHt3BmL9C+ium45e
bEEQPfrOzN9sBa5h4fYtbEctHpdv+2l9NaLH0R3in6nfxzVl7kgW/MkIyFKYzmoY
jCM5nJCijNFRXlTbzJaEqYN1stmkxXoopjS4HjArEzNIhR7Xp7PWojnW/NnU5a72
UDG70XxZrghy56WNDCd8/H90ZOJg1VscSbxhJSuW4Q8515wntMQuMrp/BqvyR3UU
rVcJueAMhjnBpzn20fhybkz7C820otEa+7QjT0cWpk6DTyZ9FBKIlVu7ctGRFZx8
c3ak7rgZbmWHa5M14Hmn2EXgg4DzgVGJUslffGgVXR+jD689TzDLoTSWICftlPl2
aAyS/wLn5VL0PR6ZikwjTrtsgbxjX4FxxErILiLuE5dadpAYJzvv/u9HCpgjTyo7
yFt8tpIEBKVOxyGVcDCmyXZnYSt8thGK+74gZgcj8dbOgaTE3gT/FQYhAW9YwqMc
6KV/TpnVX7uBlOziEnJcGsKDCj7vb8xo7U5Sj36vzQiFFuTnsX4J6BWs5dr8jD1Q
yqUKHy8ZLyw6YpRVnYdPvXR/sKgpowNAjbsU6U4JwdDLnZkzjj4F7TUq5cQElJm1
dqHZZByeB29aKzLZ6xBS
=OS5M
-----END PGP SIGNATURE-----
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: