Nmap Development mailing list archives
Re: [NSE] Syntax error messages and help finding them.
From: Brandon Enright <bmenrigh () ucsd edu>
Date: Thu, 7 Aug 2008 03:15:48 +0000
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Comment inline. On Thu, 07 Aug 2008 03:53:00 +0100 or thereabouts jah <jah () zadkiel plus com> wrote:
Hello,
If one makes a syntax error that prevents an NSE script from loading
one would see the following:
SCRIPT ENGINE: error while initializing script rules:
'C:\Program Files\Nmap\dev\foo.nse' could not be loaded!
stack traceback:
[C]: ?
[C]: ?
Yeah you aren't alone here. I tend to learn a new language via trial and error rather than documentation. NSE is more like trial and unknown and trial and unknown and trial... ;-) I should just go read the Lua book.
SCRIPT ENGINE: Aborting script scan. This certainly applies to windows, I don't know if there's any more detail shown when this happens on other OSes. I've attached a quick script for those that would like to find out - it uses an assignment operator where it should use comparison.
It's the same on all of the OSes.
Using Nmap 4.53 the error message pointed to the actual mistake: LUA INTERPRETER in ..\nse_init.cc:760: C:\Program Files\Nmap\dev\foo.nse:11: 'end' expected (to close 'function' at line 10) near '=' SCRIPT ENGINE: Aborting script scan.
Yeah NSE/Lua seems to be able to catch lexical and syntactic errors but not semantic ones.
Both of these messages are helpful, but I've often spent ages hunting through lines of script trying to find the source of the error and have wished many times for that LUA INTERPRETER message to point me at a mistake.
Agreed. I sure hope is isn't a limitation of Lua. We are dealing with a language designed to be super compact though.
If these two messages could be combined I think it would be really beneficial and especially so for users who are new to NSE scripting. Regards, jah
Yeah it sure would be nice to see semantic errors. Even the line the error occurred on (if the parser keeps that information from the lexer) would be more useful than '[C]: ?'. Perhaps Patrick or Diman can chime in here? Brandon -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkiaaOoACgkQqaGPzAsl94IlAgCgv0txvvRwLAI4hX+19oyZybPo DnEAoJgJ1Lmc3knxFBZTKtFLAs8951Mc =QfqV -----END PGP SIGNATURE----- _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [NSE] Syntax error messages and help finding them. jah (Aug 06)
- Re: [NSE] Syntax error messages and help finding them. Brandon Enright (Aug 06)
- Re: [NSE] Syntax error messages and help finding them. Kris Katterjohn (Aug 06)
- Re: [NSE] Syntax error messages and help finding them. Patrick Donnelly (Aug 07)
- Re: [NSE] Syntax error messages and help finding them. Brandon Enright (Aug 06)
