Nmap Development mailing list archives

Re: [NSE] Patch to get_args for deprecation


From: David Fifield <david () bamsoftware com>
Date: Thu, 23 Sep 2010 19:42:34 -0700

On Thu, Sep 23, 2010 at 09:29:27PM -0500, Kris Katterjohn wrote:
On 09/23/2010 09:08 PM, Ron wrote:
I was getting ready to convert my smb_* stuff to use stdnse.get_script_args(), but I realized that my script-args 
don't really follow the conventional format of script.name or library.name. I'd like to, for example, change 
'smbuser' and 'smbpass' to 'smb.user' and 'smb.pass'. With the patch attached, you'd be able to do this:

local smbuser, smbpass, domain = stdnse.get_script_args({'smb.user', 'smbuser'}, {'smb.pass', 'smbpass'}, 'domain')

Basically, each argument can, optionally, be an array. If it's an array, the first element is the proper one and 
all remaining are deprecated. They'll still be accepted, but the user will get a warning:
NSE: WARNING: Option 'smbuser' is deprecated; use 'smb.user' instead.
NSE: WARNING: Option 'smbpass' is deprecated; use 'smb.pass' instead.

I tested the attached patch and it looks fine. Any feelings about this?


I haven't tested this yet, but here are my initial thoughts:

I think the warning message should be somehow configurable on a per-call or
per-script basis.  For example, using your patch I think I can update my
scripts which have args like probeport and ipidseq.probeport; however, as
discussed in previous threads I feel that neither is more preferred than the
other and so I don't want a warning printed if a user (like me) uses probeport.

Yes, that's a great idea. I think the default behavior (for scripts)
should also be to automatically add the script prefix, so

stdnse.get_script_args("path")

in http-whatever.nse would accept either of the arguments "path" or
"http-whatever.path". This matches the convention that Kris uses in his
scripts. And then scripts would automatically support the naming
convention instead of manually doing it.

I agree that it would be nice to have some other way to mark deprecation
than its position in the list. One idea I had is to use some reserved
character that we don't use in script argument names, like

stdnse.get_script_args({'smb.user', '!smbuser'}, {'smb.pass', '!smbpass'}, 'domain')

But that's not really so important, and if it's easy to keep supporting
the old names then there's no real reason to deprecate them.

Ron, go ahead and commit your change to allow arrays, and we can discuss
the deprecation question further.

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


Current thread: