Nmap Development mailing list archives

Re: CouchDB scripts


From: David Fifield <david () bamsoftware com>
Date: Fri, 29 Jan 2010 19:18:13 -0700

On Wed, Jan 27, 2010 at 09:17:41PM +0100, Martin Holst Swende wrote:
A Couchdb library and scripts is now finished(at least in alpha). It
consists of :
* json.lua - library for parsing json
* couchdb-databases.nse - script which get database info
* couchdb-get-stats.nse - script which get some runtime statistics from
the database.

Sample output is below (the bottom one may be a bit verbose - perhaps I
should compact that a bit.

The scripts can be found at the same place (or via hg pull ; hg update).
For future reference : would you rather I send files via email ?

Thanks. These scripts will be good ones to have. I tested it against
CouchDB installed fresh from MacPorts. The first time running after
starting the server I see

PORT     STATE SERVICE
5984/tcp open  unknown
|_couchdb-get-stats:
|_couchdb-databases:

The second and every following time I run the script, I get

PORT     STATE SERVICE
5984/tcp open  unknown
| couchdb-get-stats:
|   httpd_request_methods
|     GET
|       current = 2
|       description = number of HTTP GET requests
|   couchdb
|     request_time
|       current = 39
|       description = length of a request inside CouchDB without MochiWeb
|   httpd_status_codes
|     200
|       current = 2
|       description = number of HTTP 200 OK responses
|   httpd
|     requests
|       current = 2
|_      description = number of HTTP requests
|_couchdb-databases:

Do you know what couchdb-get-stats would fail the first time only?

I like that you have split JSON into a separate library. The library is
too verbose with -d. The very low level parsing debug messages like

NSE: Json:Parsed key a
NSE: Json:Parsing node value 1, b:2
NSE: Json:Parsed value 1
NSE: Json:Parsed key b
NSE: Json:Parsing node value 2
NSE: Json:Parsed value 2

should be pushed up to -d4, or removed altogether if they are no longer
needed.

I would like json.qtrim to handle backslash escapes, and signal an error
if it doesn't get a valid quoted string. It looks like fromJson can
silently return bad data in the case of an error. I added these to your
test cases:

        '() test ()',
        '1 / 2',
        '"gaz\\"onk"',
        '{foo:"gaz\\"onk", pi:3.14159,hello:{ wo:"rld"}}',
 
They decode and flatten to, respectively,

        () test (),
        1 / 2,
        gaz\,
        {hello={wo=rld,},pi=3.14159,foo=gaz\,}

I would expect an error in the first two cases and

        gaz"onk
        {hello={wo=rld,},pi=3.14159,foo=gaz"onk,}

for the last two. I like the flatten functionality, but you should make
it return JSON so that the library can be used to encode as well as
decode. If you just want a quick look at a Lua table, use
nsedebug.tostr.

http://nmap.org/nsedoc/lib/nsedebug.html#tostr

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: