Nmap Development mailing list archives

Re: [NSE] More library global problems


From: Patrick Donnelly <batrick () batbytes com>
Date: Mon, 8 Feb 2010 13:54:15 -0500

On Mon, Feb 8, 2010 at 1:28 PM, Patrik Karlsson <patrik () cqure net> wrote:
On 8 feb 2010, at 18.09, Patrick Donnelly wrote:
You should also note in the documentation somewhere that the library
has static per-thread data. (Usually data like this is kept in some
sort of state (a table you construct) by the caller that is passed to
your library's functions (see the html.lua pipeline functions for an
example). Your approach is probably ok so long as you document it.)

What are the benefits of keeping a state table and passing it to all library
functions over re-implementing the whole library as a class which is
instantiated by each script? The request-id would then be implemented as an
instance variable instead.

Well, if the script needs to start over for some reason, then it can.
Admittedly I haven't attempted to figure out what your library does or
what it's for. In general, scripts should be able to "restart" doing
some operation in a library. The "simplest" method is to discard the
state table and create a new one (from the script writer perspective).

-- 
- 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: