Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: NSE argument table syntax
From: Kris Katterjohn <katterjohn () gmail com>
Date: Mon, 22 Jun 2009 22:44:22 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joao Correa wrote:
Also, there is one more problem. Using the new syntax requires
programmers to use nmap.registry.args['table.arg'] instead of
nmap.registry.args.table.arg. I don't know if everyone agrees, but I
think that it can make the code a little dirtier.


Eeww, really?

Forgive me for my lack of knowledge of Lua and the inner workings of NSE, but
why can't you just store the stuff in the same args.table.arg format instead
of the args['table.arg'] ?

I wrote the following quicky Ruby script (also without error checking clutter
of course) to show you what I mean.  I'm going from what could be an initial
argument set given on the command line (for example) to what could be the args
table the scripts can use.

table = {}

[
        "simple = 'string'",
        "one.two.three = 4",
        "one.skip = 5",
        "and.also.a.really.super.duper.deep.deep.deep.one = []"
].each do |test|
        a = table

        ents, val = test.split(/\s*=\s*/)
        items = ents.split(".")

        items.each_with_index do |item, index|
                break if index == items.size - 1
                a[item] ||= {}
                a = a[item]
        end

        a[items.last] = eval val
end

After that, table is as follows (pp):

 {"simple"=>"string",
  "and"=>
   {"also"=>
     {"a"=>
       {"really"=>
         {"super"=>{"duper"=>{"deep"=>{"deep"=>{"deep"=>{"one"=>[]}}}}}}}}},
  "one"=>{"two"=>{"three"=>4}, "skip"=>5}}


So if it was done like this in Lua, I think you could just do

table.one.two.three

and get 4, right?  Isn't that how tables and stuff work in Lua?

Or am I just completely mistaken?  That's certainly in the realm of possibility...


Thank you
Joao Correa


Thanks,
Kris Katterjohn

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIcBAEBAgAGBQJKQE+VAAoJEEQxgFs5kUfuTowP/A53PeJYqvcKRaUW0SCguTIS
2WVloWnWr2BK9o7H9D1X0WiqAtqZ6yFOZrGZ/9L0Xb94NcRZDOy8x7Gf5IJAoB7L
vC5quaRjcVtXhJ93YgFkqKA8YhfSktWrZNv7MadAaMFT0AK0MYprbZdejLQXZDg6
GOIUEmVq7BOthwGKZJ79nyKa0YE67nhSnbjpWjO4YxpnYK5ykHOReCRnMZp8yhR0
Qlvhk/IOgAcPzxMc+w1byzB2m5IFTI+ZP3xWaP09ATvAlMlHGAB+lwzQMuGE3aIp
YAbbUsO7g1QNeKAlXUocJLRzUxayUTACh3A+z1cdlS/OtsBTQ/tp/SKKOb3sqhwK
lL5GT/hdZOx20Az8hPDOeRB3fL2sPP8iDsA6lqgSfbUOYPVDf4zSqUd8Phxa1STs
/vrOquxJbCGF5AffsnpFs5U/GYyB9XrbKH7JGggFG7lzdi/h0YWnSI5nORxpqHgt
TMsERRQFQK9BufMOsNKlEXsQWTqatzm5S97+G9WB2GrRCCAOASQ9pEkQjR36xH4h
/LQ7KrzjOcUQhshM7W3TvI4XbzyTL2VJxKz6KVm1jV+/uk5zrzI+R/fyrgBTmgHQ
hDPHUKuOnFUj652Qo2vpzDAJtWLcgrypKUOXA4d7wofum2kxk9jbmDDf/fQ5kQlo
HkOk35vI2+naPgMB0zKq
=KW5z
-----END PGP SIGNATURE-----

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


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
AlienVault