Nmap Development mailing list archives

Re: NSE structured output--normal output formatting


From: Patrick Donnelly <batrick () batbytes com>
Date: Fri, 20 Jul 2012 10:39:21 -0400

On Thu, Jul 19, 2012 at 6:49 PM, David Fifield <david () bamsoftware com> wrote:
We have discussed how scripts should be able to return a table with nice
structured semantic fields, and also the need to provide less robotic
output for humans reading -oN.

We've discussed some possible options for producing normal output. These
include
* requiring the script to give to NSE a function that converts its
  output table to a string,
* requiring the script to annotate its returned table with metadata that
  describe how the table should be converted to a string, and
* returning a string along with the table.

I want to strongly suggest that we adopt the technique of just returning
string alongside the table. These are the benefits I see to this approach:

* Lower complexity.
* Every existing script is already capable of producing such a string.
* Lower complexity.
* Scripts know their own verbosity and already tailor their output for it.
* Lower complexity.

Old scripts that don't understand structured output will do

        return my_output_string

New scripts that don't need any fancy formatting will do

        return my_output_table

Scripts that need to control their normal output will do

        return my_output_table, my_output_string

What say you?

I think ScriptOutput tables (objects) would be the "future", having a
__tostring metamethod or some method for changing the table to a
string for normal output. I don't see the value in having scripts
continue to make a string version of their output alongside the table
version.

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