Re: Compile NASL Scripts

George Theall <[email protected]>
Newsgroups gmane.comp.security.nessus.devel,gmane.comp.security.nessus.general
Message-ID <[email protected]>
On Fri, May 30, 2003 at 04:12:24PM +0200, Michel Arboi wrote:

> No. But the change would be trivial.

Attached are patches to libnasl/nasl/exec.c and libnasl/nasl/nasl.c
to add an option to just parse a script.  I'd be thrilled if these
made it into the official distribution, especially after someone more
familiar with nasl reviewed them.

George
-- 
[email protected]
exec.c.diffs (text/plain, 533 B)
--- exec.c.orig	Wed May 21 10:40:10 2003
+++ exec.c	Fri May 30 12:53:30 2003
@@ -45,6 +45,8 @@
 #define NASL_DEBUG 0
 #endif
 
+extern int parse_only;
+
 int
 cell2bool(lex_ctxt* lexic, tree_cell* c)
 {
@@ -1680,6 +1682,13 @@
 #endif
  lexic = init_empty_lex_ctxt();
  lexic->script_infos = script_infos;
+ if (parse_only != 0)
+   {
+     nasl_perror(lexic, "\nParsing completed\n");
+     nasl_clean_ctx(&ctx);
+     chdir(old_dir);
+     return 0;
+   }
  
  str = arg_get_value(prefs, "checks_read_timeout");
  if( str != NULL )
nasl.c.diffs (text/plain, 1.3 KB)
--- nasl.c.orig	Mon Apr  7 06:16:25 2003
+++ nasl.c	Fri May 30 12:54:08 2003
@@ -55,6 +55,7 @@
 void exit_nasl(struct arglist *, int);
 
 
+int parse_only = 0;
 int safe_checks_only = 0;
 
 static struct arglist * 
@@ -109,8 +110,9 @@
 {
  printf("\nnasl -- Copyright (C) 1999 - 2003 Renaud Deraison <[email protected]>\n");
  printf("nasl -- Copyright (C) 2002 - 2003 Michel Arboi <[email protected]>\n\n");
- printf("Usage : nasl [-vh] [ -t target ] [-T trace_file] script_file ...\n");
+ printf("Usage : nasl [-vh] [-p] [ -t target ] [-T trace_file] script_file ...\n");
  printf("\t-h : shows this help screen\n");
+ printf("\t-p : just parse the script\n");
  printf("\t-t target : Execute the scripts against the target(s) host\n");
  printf("\t-T file : Trace actions into the file (or '-' for stderr)\n");
  printf("\t-s : specifies that the script should be run with 'safe checks' enabled\n");
@@ -136,7 +138,7 @@
  	Command-line options
   ---------------------------------------------*/
   
- while((i = getopt(argc, argv, "hvt:k:T:s"))!=EOF)
+ while((i = getopt(argc, argv, "hpvt:k:T:s"))!=EOF)
   switch(i)
   {
    case 't' :
@@ -172,6 +174,9 @@
 		usage();
 		exit(0);
 		}
+	break;
+ case 'p' :
+ 	parse_only ++;
 	break;
  case 'v' :
  	printf("nasl %s\n\n", nasl_version());
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+15Q17ZziPz0vGWERApS5AJ4zR2s4a1Hg3Pkas6IBq8dU1luw9gCfSHQq
SnJAScvQiu8IpL7wdlHBTkA=
=wfDG
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.