]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
lua: initial DNS logging support
authorVictor Julien <victor@inliniac.net>
Thu, 4 Jun 2015 08:46:26 +0000 (10:46 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 20 Jul 2015 09:49:14 +0000 (11:49 +0200)
src/output-lua.c

index fc075cd3149aff4a674657e9c00f9fcf351c9819..0f06450e9b6c70fbd2e1364afa4294c5368e1829 100644 (file)
@@ -56,6 +56,7 @@
 #include "util-lua.h"
 #include "util-lua-common.h"
 #include "util-lua-http.h"
+#include "util-lua-dns.h"
 
 #define MODULE_NAME "LuaLog"
 
@@ -514,6 +515,8 @@ static int LuaScriptInit(const char *filename, LogLuaScriptOptions *options) {
 
         if (strcmp(k,"protocol") == 0 && strcmp(v, "http") == 0)
             options->alproto = ALPROTO_HTTP;
+        else if (strcmp(k,"protocol") == 0 && strcmp(v, "dns") == 0)
+            options->alproto = ALPROTO_DNS;
         else if (strcmp(k, "type") == 0 && strcmp(v, "packet") == 0)
             options->packet = 1;
         else if (strcmp(k, "filter") == 0 && strcmp(v, "alerts") == 0)
@@ -532,7 +535,7 @@ static int LuaScriptInit(const char *filename, LogLuaScriptOptions *options) {
             SCLogInfo("unknown key and/or value: k='%s', v='%s'", k, v);
     }
 
-    if (options->alproto + options->packet + options->file > 1) {
+    if (((options->alproto != ALPROTO_UNKNOWN)) + options->packet + options->file > 1) {
         SCLogError(SC_ERR_LUA_ERROR, "invalid combination of 'needs' in the script");
         goto error;
     }
@@ -613,6 +616,7 @@ static lua_State *LuaScriptSetup(const char *filename)
     /* unconditionally register http function. They will only work
      * if the tx is registered in the state at runtime though. */
     LuaRegisterHttpFunctions(luastate);
+    LuaRegisterDnsFunctions(luastate);
 
     if (lua_pcall(luastate, 0, 0, 0) != 0) {
         SCLogError(SC_ERR_LUA_ERROR, "couldn't run script 'setup' function: %s", lua_tostring(luastate, -1));
@@ -756,6 +760,11 @@ static OutputCtx *OutputLuaLogInit(ConfNode *conf)
             om->TxLogFunc = LuaTxLogger;
             om->alproto = ALPROTO_HTTP;
             AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_HTTP);
+        } else if (opts.alproto == ALPROTO_DNS) {
+            om->TxLogFunc = LuaTxLogger;
+            om->alproto = ALPROTO_DNS;
+            AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_DNS);
+            AppLayerParserRegisterLogger(IPPROTO_UDP, ALPROTO_DNS);
         } else if (opts.packet && opts.alerts) {
             om->PacketLogFunc = LuaPacketLoggerAlerts;
             om->PacketConditionFunc = LuaPacketConditionAlerts;