Nmap Development mailing list archives

Re: using the credentials database


From: Patrick Donnelly <batrick () batbytes com>
Date: Tue, 5 Jul 2011 16:40:58 -0400

On Tue, Jul 5, 2011 at 3:51 PM, Patrik Karlsson <patrik () cqure net> wrote:

On Jul 5, 2011, at 8:51 PM, Patrick Donnelly wrote:

On Mon, Jun 27, 2011 at 5:04 PM, Patrik Karlsson <patrik () cqure net> wrote:
I've added some documentation and a new function called getCredentials that will hopefully get you what you need.
Let me know if there's anything else you find missing :)

Sorry for being late to the party... I have a stylistic/efficiency
concern here. I'd prefer this function be an iterator [1,2] rather
than returning a potentially large table of tables. Something like:

for credential in c:credentials(creds.State.VALID) do
end

You can accomplish this quite naturally with coroutines [3,4].

[1] http://www.lua.org/pil/7.html
[2] http://www.lua.org/manual/5.1/manual.html#2.4.5
[3] http://www.lua.org/pil/9.3.html
[4] http://nmap.org/book/nse-parallelism.html#nse-parallelism-cm

--
- Patrick Donnelly


I modified the getCredentials function to return an iterator per your suggestion.
The attached patch contains my previous script argument patch as well as this change.

This still creates the table (self.storage:getAll()). I was thinking
that instead that the getAll method would call coroutine.yield instead
of building a table.

It may also be worthwhile to eliminate the tables completely by doing
something like:

for host, port, user, pass, state, service in c:getCredentials() do
end

Something to think about :). It will be much faster and more memory
efficient but may violate the object based design you were going for.
So it would be fine to keep the table in that case.

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