[Openvas-commits] r12230 - in trunk/openvas-libraries: . nasl

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 30 23:09:09 CET 2011


Author: hdoreau
Date: 2011-11-30 23:09:08 +0100 (Wed, 30 Nov 2011)
New Revision: 12230

Modified:
   trunk/openvas-libraries/ChangeLog
   trunk/openvas-libraries/nasl/nasl_init.c
   trunk/openvas-libraries/nasl/nasl_scanner_glue.c
   trunk/openvas-libraries/nasl/nasl_scanner_glue.h
Log:
Export a new function get_script_oid() to NASL.

* nasl/nasl_init.c: Add get_script_oid() to the list of the NASL
functions.

* nasl/nasl_scanner_glue.c (get_script_oid): New function.

* nasl/nasl_scanner_glue.h: Update header accordingly.


Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog	2011-11-30 18:08:51 UTC (rev 12229)
+++ trunk/openvas-libraries/ChangeLog	2011-11-30 22:09:08 UTC (rev 12230)
@@ -1,3 +1,14 @@
+2011-11-30  Henri Doreau <henri.doreau at greenbone.net>
+
+	Export a new function get_script_oid() to NASL.
+
+	* nasl/nasl_init.c: Add get_script_oid() to the list of the NASL
+	functions.
+
+	* nasl/nasl_scanner_glue.c (get_script_oid): New function.
+
+	* nasl/nasl_scanner_glue.h: Update header accordingly.
+
 2011-11-10  Michael Wiegand <michael.wiegand at greenbone.net>
 
 	* CMakeLists.txt: Adjust path of source file in install to point to

Modified: trunk/openvas-libraries/nasl/nasl_init.c
===================================================================
--- trunk/openvas-libraries/nasl/nasl_init.c	2011-11-30 18:08:51 UTC (rev 12229)
+++ trunk/openvas-libraries/nasl/nasl_init.c	2011-11-30 22:09:08 UTC (rev 12230)
@@ -96,6 +96,7 @@
   {"script_tag", script_tag, 0, {"name", "value", NULL}},
   {"get_preference", nasl_get_preference, 1, {NULL}},
   {"safe_checks", safe_checks, 0, {NULL}},
+  {"get_script_oid", get_script_oid, 0, {NULL}},
   {"replace_kb_item", replace_kb_item, 0, {"name", "value", NULL}},
   {"set_kb_item", set_kb_item, 0, {"name", "value", NULL}},
   {"get_kb_item", get_kb_item, 1, {NULL}},

Modified: trunk/openvas-libraries/nasl/nasl_scanner_glue.c
===================================================================
--- trunk/openvas-libraries/nasl/nasl_scanner_glue.c	2011-11-30 18:08:51 UTC (rev 12229)
+++ trunk/openvas-libraries/nasl/nasl_scanner_glue.c	2011-11-30 22:09:08 UTC (rev 12230)
@@ -634,6 +634,33 @@
   return retc;
 }
 
+/**
+ * @brief Return the OID of the current script.
+ *
+ * @param[in] lexic     NASL lexer.
+ *
+ * @return lex cell containing the OID as a string.
+ */
+tree_cell *
+get_script_oid (lex_ctxt * lexic)
+{
+  nvti_t *nvti = arg_get_value (lexic->script_infos, "NVTI");
+  char *oid;
+  tree_cell *retc;
+
+  retc = NULL;
+  oid = strdup (nvti_oid (nvti));
+
+  if (oid)
+    {
+      retc = alloc_typed_cell (CONST_DATA);
+      retc->x.str_val = oid;
+      retc->size = strlen (oid);
+    }
+
+  return retc;
+}
+
 /*--------------------[ KB ]---------------------------------------*/
 
 #define SECRET_KB_PREFIX	"Secret/"

Modified: trunk/openvas-libraries/nasl/nasl_scanner_glue.h
===================================================================
--- trunk/openvas-libraries/nasl/nasl_scanner_glue.h	2011-11-30 18:08:51 UTC (rev 12229)
+++ trunk/openvas-libraries/nasl/nasl_scanner_glue.h	2011-11-30 22:09:08 UTC (rev 12230)
@@ -47,6 +47,7 @@
 tree_cell *safe_checks (lex_ctxt *);
 tree_cell *scan_phase (lex_ctxt *);
 tree_cell *network_targets (lex_ctxt *);
+tree_cell *get_script_oid (lex_ctxt *);
 tree_cell *get_kb_item (lex_ctxt *);
 tree_cell *get_kb_fresh_item (lex_ctxt *);
 tree_cell *get_kb_list (lex_ctxt *);



More information about the Openvas-commits mailing list