Nmap Development mailing list archives
Re: XML structured script output (storing results per script instance)
From: Daniel Miller <bonsaiviking () gmail com>
Date: Wed, 01 Aug 2012 17:15:18 -0500
On 08/01/2012 02:17 PM, Patrick Donnelly wrote:
On Tue, Jul 31, 2012 at 10:56 PM, David Fifield <david () bamsoftware com> wrote:So what's the recommended way to do this? Previously set_output immediately converted a Lua string to a std::string, with no need to hold on to a lua_State. Now set_output can receive more generally a table, which I suggested keeping in the Lua registry rather than converting to a C++ representation of the same table.Ideally, have nse_main.lua generate an XML representation (or nse_main.cc) and save that in addition to normal output. Otherwise, use luaL_Ref instead of coroutine pointer string keys. You should use L_NSE static variable for ScriptResult manipulation instead of whatever is calling cnse.set_output(). These calls need to be wrapped in appropriate protected calls (lua_pcall) so errors don't crash Nmap.
Patrick,I think I understand the idea of luaL_ref, so I've attached a patch to use that instead of a stringified pointer. I'd appreciate a look to see if I'm doing it right (my testing shows no problems).
Can you explain better how I could use the L_NSE state instead of the one passed to cnse.set_output()? Obviously if script output was a light userdata object then I could pass that from one lua_State to another with lua_touserdata and lua_pushlightuserdata, but I can't see how to do that with a table. Plus, we (I?) wanted to get away from yet another data structure representation of the output. This gets to the same issue with wrapping the calls in lua_pcall: in order to push the arguments, they all need to be in the same lua_State. Or am I missing something?
Thanks for your help. I can't help but feel I'm cargo-cult programming when I do lua-C work.
Dan
Attachment:
luaL_ref.patch
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:
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 19)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 19)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) Patrick Donnelly (Jul 20)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 20)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) Patrick Donnelly (Jul 20)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 20)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 20)
- Re: XML structured script output (storing results per script instance) David Fifield (Jul 31)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Jul 31)
- Re: XML structured script output (storing results per script instance) David Fifield (Jul 31)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Aug 01)
- Re: XML structured script output (storing results per script instance) Daniel Miller (Aug 01)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Aug 01)
- Re: XML structured script output (storing results per script instance) Daniel Miller (Aug 02)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Aug 03)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Jul 31)