Nmap Development mailing list archives

Re: [NSE][RFC] format.lua library


From: Daniel Miller <bonsaiviking () gmail com>
Date: Fri, 14 Sep 2012 13:42:04 -0500

On 09/12/2012 08:21 PM, David Fifield wrote:
On Wed, Aug 15, 2012 at 01:14:51PM -0500, Daniel Miller wrote:
List,

Since David merged the XML NSE output functionality, I am eager to
get started converting old scripts to the new format. To support
this, I'm proposing the attached library, which I've called "format"
for the moment.

The idea is that there should be a collection of standardized ways
of formatting output, to make it easy for script authors to take
advantage of the structured output and to promote consistency in the
Normal output. The functions I've put into the library to start are
mostly focused around the __tostring way of formatting output, since
the simple "return a table and a string" way doesn't really need any
abstraction. Once this is committed, I'll commit a few of the
altered scripts that I've already worked on, to make it clear by
example how they are to be used.
This seems fine to me, though I haven't personally felt the need for any
of these functions. I'm interested in seeing how they would be used in
scripts first. Can you send some simple scripts using this library.

If we decide to keep this library, we would add the new
stdnse.format_timestamp and similar functions to it.

David Fifield

I've attached my current version of the format.lua lib, as well as 2 patches that enable structured output for nfs-ls and nbstat, respectively. These make use of some of the functions in format.lua. Note that the nfs-ls patch also modifies tab.lua to support embedding table output within outline-style text output, while keeping a structured XML serialization.

I realize that this is mostly geared around my original "tostring" method of doing structured output, whereas most of the scripts that have been converted so far use parallel structure and string outputs. I think that this library could work as a consolidation point for functions enabling both styles.

Once this is merged, I would move format_timestamp into format.lib as a separate commit.

Dan

Attachment: nfs-ls.patch
Description:

Attachment: nbstat.patch
Description:

Attachment: format.lua
Description:

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

Current thread: