suricata
util-lua-common.c
Go to the documentation of this file.
1 /* Copyright (C) 2014-2021 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  *
23  * Common function for Lua Output
24  */
25 
26 #include "suricata-common.h"
27 #include "detect.h"
28 #include "pkt-var.h"
29 #include "conf.h"
30 
31 #include "threads.h"
32 #include "threadvars.h"
33 #include "tm-threads.h"
34 
35 #include "util-print.h"
36 #include "util-unittest.h"
37 
38 #include "util-debug.h"
39 
40 #include "output.h"
41 #include "app-layer-htp.h"
42 #include "app-layer.h"
43 #include "app-layer-parser.h"
44 #include "util-privs.h"
45 #include "util-buffer.h"
46 #include "util-proto-name.h"
47 #include "util-logopenfile.h"
48 #include "util-time.h"
49 #include "util-conf.h"
50 
51 #include "lua.h"
52 #include "lualib.h"
53 #include "lauxlib.h"
54 
55 #include "util-lua.h"
56 #include "util-lua-common.h"
57 #include "action-globals.h"
58 
59 int LuaCallbackError(lua_State *luastate, const char *msg)
60 {
61  lua_pushnil(luastate);
62  lua_pushstring(luastate, msg);
63  return 2;
64 }
65 
66 const char *LuaGetStringArgument(lua_State *luastate, int argc)
67 {
68  /* get argument */
69  if (!lua_isstring(luastate, argc))
70  return NULL;
71  const char *str = lua_tostring(luastate, argc);
72  if (str == NULL)
73  return NULL;
74  if (strlen(str) == 0)
75  return NULL;
76  return str;
77 }
78 
79 void LuaPushTableKeyValueInt(lua_State *luastate, const char *key, int value)
80 {
81  lua_pushstring(luastate, key);
82  lua_pushnumber(luastate, value);
83  lua_settable(luastate, -3);
84 }
85 
86 /** \brief Push a key plus string value to the stack
87  *
88  * If value is NULL, string "(null")" will be put on the stack.
89  */
90 void LuaPushTableKeyValueString(lua_State *luastate, const char *key, const char *value)
91 {
92  lua_pushstring(luastate, key);
93  lua_pushstring(luastate, value ? value : "(null)");
94  lua_settable(luastate, -3);
95 }
96 
97 void LuaPushTableKeyValueArray(lua_State *luastate, const char *key, const uint8_t *value, size_t len)
98 {
99  lua_pushstring(luastate, key);
100  LuaPushStringBuffer(luastate, value, len);
101  lua_settable(luastate, -3);
102 }
103 
104 /** \internal
105  * \brief fill lua stack with payload
106  * \param luastate the lua state
107  * \param p packet
108  * \retval cnt number of data items placed on the stack
109  *
110  * Places: payload (string), open (bool), close (bool), toserver (bool), toclient (bool)
111  */
112 static int LuaCallbackStreamingBufferPushToStack(lua_State *luastate, const LuaStreamingBuffer *b)
113 {
114  //PrintRawDataFp(stdout, (uint8_t *)b->data, b->data_len);
115  lua_pushlstring (luastate, (const char *)b->data, b->data_len);
116  lua_pushboolean (luastate, (b->flags & OUTPUT_STREAMING_FLAG_OPEN));
117  lua_pushboolean (luastate, (b->flags & OUTPUT_STREAMING_FLAG_CLOSE));
118  lua_pushboolean (luastate, (b->flags & OUTPUT_STREAMING_FLAG_TOSERVER));
119  lua_pushboolean (luastate, (b->flags & OUTPUT_STREAMING_FLAG_TOCLIENT));
120  return 5;
121 }
122 
123 /** \internal
124  * \brief Wrapper for getting payload into a lua script
125  * \retval cnt number of items placed on the stack
126  */
127 static int LuaCallbackStreamingBuffer(lua_State *luastate)
128 {
129  const LuaStreamingBuffer *b = LuaStateGetStreamingBuffer(luastate);
130  if (b == NULL)
131  return LuaCallbackError(luastate, "internal error: no buffer");
132 
133  return LuaCallbackStreamingBufferPushToStack(luastate, b);
134 }
135 
136 /** \internal
137  * \brief fill lua stack with signature info
138  * \param luastate the lua state
139  * \param s pointer to signature struct
140  * \retval cnt number of data items placed on the stack
141  *
142  * Places: sid (number), rev (number), gid (number)
143  */
144 static int LuaCallbackRuleIdsPushToStackFromSignature(lua_State *luastate, const Signature *s)
145 {
146  lua_pushinteger(luastate, s->id);
147  lua_pushinteger(luastate, s->rev);
148  lua_pushinteger(luastate, s->gid);
149  return 3;
150 }
151 
152 /** \internal
153  * \brief Wrapper for getting tuple info into a lua script
154  * \retval cnt number of items placed on the stack
155  *
156  * Info is pulled from PacketAlert if it exists in lua registry (true for logging scripts)
157  * otherwise pulled from Signature in lua registry (for match scripts)
158  */
159 static int LuaCallbackRuleIds(lua_State *luastate)
160 {
161  const Signature *s = NULL;
162  const PacketAlert *pa = LuaStateGetPacketAlert(luastate);
163  if (pa != NULL) {
164  s = pa->s;
165  } else {
166  s = LuaStateGetSignature(luastate);
167  if (s == NULL)
168  return LuaCallbackError(luastate, "internal error: no packet alert or signature");
169  }
170  return LuaCallbackRuleIdsPushToStackFromSignature(luastate, s);
171 }
172 
173 /** \internal
174  * \brief fill lua stack with signature info
175  * \param luastate the lua state
176  * \param s pointer to signature struct
177  * \retval cnt number of data items placed on the stack
178  *
179  * Places: action (string)
180  */
181 static int LuaCallbackRuleActionPushToStackFromSignature(lua_State *luastate, const Signature *s)
182 {
183  const char *action = "";
184  if (s->action & ACTION_PASS) {
185  action = "pass";
186  } else if ((s->action & ACTION_REJECT) || (s->action & ACTION_REJECT_BOTH) ||
187  (s->action & ACTION_REJECT_DST)) {
188  action = "reject";
189  } else if (s->action & ACTION_DROP) {
190  action = "drop";
191  } else if (s->action & ACTION_ALERT) {
192  action = "alert";
193  }
194  lua_pushstring(luastate, action);
195  return 1;
196 }
197 
198 /** \internal
199  * \brief Wrapper for getting tuple info into a lua script
200  * \retval cnt number of items placed on the stack
201  *
202  * Info is pulled from PacketAlert if it exists in lua registry (true for logging scripts)
203  * otherwise pulled from Signature in lua registry (for match scripts)
204  */
205 static int LuaCallbackRuleAction(lua_State *luastate)
206 {
207  const Signature *s = NULL;
208  const PacketAlert *pa = LuaStateGetPacketAlert(luastate);
209  if (pa != NULL) {
210  s = pa->s;
211  } else {
212  s = LuaStateGetSignature(luastate);
213  if (s == NULL)
214  return LuaCallbackError(luastate, "internal error: no packet alert or signature");
215  }
216  return LuaCallbackRuleActionPushToStackFromSignature(luastate, s);
217 }
218 
219 /** \internal
220  * \brief fill lua stack with signature info
221  * \param luastate the lua state
222  * \param s pointer to signature struct
223  * \retval cnt number of data items placed on the stack
224  *
225  * Places: msg (string)
226  */
227 static int LuaCallbackRuleMsgPushToStackFromSignature(lua_State *luastate, const Signature *s)
228 {
229  lua_pushstring(luastate, s->msg);
230  return 1;
231 }
232 
233 /** \internal
234  * \brief Wrapper for getting tuple info into a lua script
235  * \retval cnt number of items placed on the stack
236  *
237  * Info is pulled from PacketAlert if it exists in lua registry (true for logging scripts)
238  * otherwise pulled from Signature in lua registry (for match scripts)
239  */
240 static int LuaCallbackRuleMsg(lua_State *luastate)
241 {
242  const Signature *s = NULL;
243  const PacketAlert *pa = LuaStateGetPacketAlert(luastate);
244  if (pa != NULL) {
245  s = pa->s;
246  } else {
247  s = LuaStateGetSignature(luastate);
248  if (s == NULL)
249  return LuaCallbackError(luastate, "internal error: no packet alert or signature");
250  }
251  return LuaCallbackRuleMsgPushToStackFromSignature(luastate, s);
252 }
253 
254 /** \internal
255  * \brief fill lua stack with signature info
256  * \param luastate the lua state
257  * \param s pointer to signature struct
258  * \retval cnt number of data items placed on the stack
259  *
260  * Places: class (string), prio (number)
261  */
262 static int LuaCallbackRuleClassPushToStackFromSignature(lua_State *luastate, const Signature *s)
263 {
264  lua_pushstring(luastate, s->class_msg);
265  lua_pushinteger(luastate, s->prio);
266  return 2;
267 }
268 
269 /** \internal
270  * \brief Wrapper for getting tuple info into a lua script
271  * \retval cnt number of items placed on the stack
272  *
273  * Info is pulled from PacketAlert if it exists in lua registry (true for logging scripts)
274  * otherwise pulled from Signature in lua registry (for match scripts)
275  */
276 static int LuaCallbackRuleClass(lua_State *luastate)
277 {
278  const Signature *s = NULL;
279  const PacketAlert *pa = LuaStateGetPacketAlert(luastate);
280  if (pa != NULL) {
281  s = pa->s;
282  } else {
283  s = LuaStateGetSignature(luastate);
284  if (s == NULL)
285  return LuaCallbackError(luastate, "internal error: no packet alert or signature");
286  }
287  return LuaCallbackRuleClassPushToStackFromSignature(luastate, s);
288 }
289 
290 static int LuaCallbackLogPath(lua_State *luastate)
291 {
292  const char *ld = ConfigGetLogDirectory();
293  if (ld == NULL)
294  return LuaCallbackError(luastate, "internal error: no log dir");
295 
296  return LuaPushStringBuffer(luastate, (const uint8_t *)ld, strlen(ld));
297 }
298 
299 static int LuaCallbackLogDebug(lua_State *luastate)
300 {
301  const char *msg = LuaGetStringArgument(luastate, 1);
302  if (msg == NULL)
303  return LuaCallbackError(luastate, "1st argument missing, empty or wrong type");
304  SCLogDebug("%s", msg);
305  return 0;
306 }
307 
308 static int LuaCallbackLogInfo(lua_State *luastate)
309 {
310  const char *msg = LuaGetStringArgument(luastate, 1);
311  if (msg == NULL)
312  return LuaCallbackError(luastate, "1st argument missing, empty or wrong type");
313 
314  lua_Debug ar;
315  lua_getstack(luastate, 1, &ar);
316  lua_getinfo(luastate, "nSl", &ar);
317  const char *funcname = ar.name ? ar.name : ar.what;
318  SCLogInfoRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
319  return 0;
320 }
321 
322 static int LuaCallbackLogNotice(lua_State *luastate)
323 {
324  const char *msg = LuaGetStringArgument(luastate, 1);
325  if (msg == NULL)
326  return LuaCallbackError(luastate, "1st argument missing, empty or wrong type");
327 
328  lua_Debug ar;
329  lua_getstack(luastate, 1, &ar);
330  lua_getinfo(luastate, "nSl", &ar);
331  const char *funcname = ar.name ? ar.name : ar.what;
332  SCLogNoticeRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
333  return 0;
334 }
335 
336 static int LuaCallbackLogWarning(lua_State *luastate)
337 {
338  const char *msg = LuaGetStringArgument(luastate, 1);
339  if (msg == NULL)
340  return LuaCallbackError(luastate, "1st argument missing, empty or wrong type");
341 
342  lua_Debug ar;
343  lua_getstack(luastate, 1, &ar);
344  lua_getinfo(luastate, "nSl", &ar);
345  const char *funcname = ar.name ? ar.name : ar.what;
346  SCLogWarningRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
347  return 0;
348 }
349 
350 static int LuaCallbackLogError(lua_State *luastate)
351 {
352  const char *msg = LuaGetStringArgument(luastate, 1);
353  if (msg == NULL)
354  return LuaCallbackError(luastate, "1st argument missing, empty or wrong type");
355  lua_Debug ar;
356  lua_getstack(luastate, 1, &ar);
357  lua_getinfo(luastate, "nSl", &ar);
358  const char *funcname = ar.name ? ar.name : ar.what;
359  SCLogErrorRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
360  return 0;
361 }
362 
363 /** \internal
364  * \brief fill lua stack with file info
365  * \param luastate the lua state
366  * \param pa pointer to packet alert struct
367  * \retval cnt number of data items placed on the stack
368  *
369  * Places: fileid (number), txid (number), name (string),
370  * size (number), magic (string), md5 in hex (string),
371  * sha1 (string), sha256 (string)
372  */
373 static int LuaCallbackFileInfoPushToStackFromFile(lua_State *luastate, const File *file)
374 {
375  char *md5ptr = NULL;
376  char *sha1ptr = NULL;
377  char *sha256ptr = NULL;
378 
379  char md5[33] = "";
380  md5ptr = md5;
381  if (file->flags & FILE_MD5) {
382  size_t x;
383  for (x = 0; x < sizeof(file->md5); x++) {
384  char one[3] = "";
385  snprintf(one, sizeof(one), "%02x", file->md5[x]);
386  strlcat(md5, one, sizeof(md5));
387  }
388  }
389  char sha1[41] = "";
390  sha1ptr = sha1;
391  if (file->flags & FILE_SHA1) {
392  size_t x;
393  for (x = 0; x < sizeof(file->sha1); x++) {
394  char one[3] = "";
395  snprintf(one, sizeof(one), "%02x", file->sha1[x]);
396  strlcat(sha1, one, sizeof(sha1));
397  }
398  }
399  char sha256[65] = "";
400  sha256ptr = sha256;
401  if (file->flags & FILE_SHA256) {
402  size_t x;
403  for (x = 0; x < sizeof(file->sha256); x++) {
404  char one[3] = "";
405  snprintf(one, sizeof(one), "%02x", file->sha256[x]);
406  strlcat(sha256, one, sizeof(sha256));
407  }
408  }
409 
410  lua_Integer tx_id = LuaStateGetTxId(luastate);
411  lua_pushinteger(luastate, file->file_store_id);
412  lua_pushinteger(luastate, tx_id);
413  lua_pushlstring(luastate, (char *)file->name, file->name_len);
414  lua_pushinteger(luastate, FileTrackedSize(file));
415  lua_pushstring (luastate,
416 #ifdef HAVE_MAGIC
417  file->magic
418 #else
419  "nomagic"
420 #endif
421  );
422  lua_pushstring(luastate, md5ptr);
423  lua_pushstring(luastate, sha1ptr);
424  lua_pushstring(luastate, sha256ptr);
425  return 8;
426 }
427 
428 /** \internal
429  * \brief Wrapper for getting tuple info into a lua script
430  * \retval cnt number of items placed on the stack
431  */
432 static int LuaCallbackFileInfo(lua_State *luastate)
433 {
434  const File *file = LuaStateGetFile(luastate);
435  if (file == NULL)
436  return LuaCallbackError(luastate, "internal error: no file");
437 
438  return LuaCallbackFileInfoPushToStackFromFile(luastate, file);
439 }
440 
441 /** \internal
442  * \brief fill lua stack with file info
443  * \param luastate the lua state
444  * \param pa pointer to packet alert struct
445  * \retval cnt number of data items placed on the stack
446  *
447  * Places: state (string), stored (bool)
448  */
449 static int LuaCallbackFileStatePushToStackFromFile(lua_State *luastate, const File *file)
450 {
451  const char *state = "UNKNOWN";
452  switch (file->state) {
453  case FILE_STATE_CLOSED:
454  state = "CLOSED";
455  break;
457  state = "TRUNCATED";
458  break;
459  case FILE_STATE_ERROR:
460  state = "ERROR";
461  break;
462  case FILE_STATE_OPENED:
463  state = "OPENED";
464  break;
465  case FILE_STATE_NONE:
466  state = "NONE";
467  break;
468  case FILE_STATE_MAX:
469  break;
470  }
471 
472  lua_pushstring (luastate, state);
473  lua_pushboolean (luastate, file->flags & FILE_STORED);
474  return 2;
475 }
476 
477 /** \internal
478  * \brief Wrapper for getting tuple info into a lua script
479  * \retval cnt number of items placed on the stack
480  */
481 static int LuaCallbackFileState(lua_State *luastate)
482 {
483  const File *file = LuaStateGetFile(luastate);
484  if (file == NULL)
485  return LuaCallbackError(luastate, "internal error: no file");
486 
487  return LuaCallbackFileStatePushToStackFromFile(luastate, file);
488 }
489 
490 /** \internal
491  * \brief fill lua stack with thread info
492  * \param luastate the lua state
493  * \param pa pointer to packet alert struct
494  * \retval cnt number of data items placed on the stack
495  *
496  * Places: thread id (number), thread name (string, thread group name (string)
497  */
498 static int LuaCallbackThreadInfoPushToStackFromThreadVars(lua_State *luastate, const ThreadVars *tv)
499 {
500  unsigned long tid = SCGetThreadIdLong();
501  lua_pushinteger (luastate, (lua_Integer)tid);
502  lua_pushstring (luastate, tv->name);
503  lua_pushstring (luastate, tv->thread_group_name);
504  return 3;
505 }
506 
507 /** \internal
508  * \brief Wrapper for getting tuple info into a lua script
509  * \retval cnt number of items placed on the stack
510  */
511 static int LuaCallbackThreadInfo(lua_State *luastate)
512 {
513  const ThreadVars *tv = LuaStateGetThreadVars(luastate);
514  if (tv == NULL)
515  return LuaCallbackError(luastate, "internal error: no tv");
516 
517  return LuaCallbackThreadInfoPushToStackFromThreadVars(luastate, tv);
518 }
519 
521 {
522  /* registration of the callbacks */
523  lua_pushcfunction(luastate, LuaCallbackStreamingBuffer);
524  lua_setglobal(luastate, "SCStreamingBuffer");
525 
526  lua_pushcfunction(luastate, LuaCallbackLogPath);
527  lua_setglobal(luastate, "SCLogPath");
528 
529  lua_pushcfunction(luastate, LuaCallbackLogDebug);
530  lua_setglobal(luastate, "SCLogDebug");
531  lua_pushcfunction(luastate, LuaCallbackLogInfo);
532  lua_setglobal(luastate, "SCLogInfo");
533  lua_pushcfunction(luastate, LuaCallbackLogNotice);
534  lua_setglobal(luastate, "SCLogNotice");
535  lua_pushcfunction(luastate, LuaCallbackLogWarning);
536  lua_setglobal(luastate, "SCLogWarning");
537  lua_pushcfunction(luastate, LuaCallbackLogError);
538  lua_setglobal(luastate, "SCLogError");
539 
540 
541  lua_pushcfunction(luastate, LuaCallbackRuleIds);
542  lua_setglobal(luastate, "SCRuleIds");
543  lua_pushcfunction(luastate, LuaCallbackRuleAction);
544  lua_setglobal(luastate, "SCRuleAction");
545  lua_pushcfunction(luastate, LuaCallbackRuleMsg);
546  lua_setglobal(luastate, "SCRuleMsg");
547  lua_pushcfunction(luastate, LuaCallbackRuleClass);
548  lua_setglobal(luastate, "SCRuleClass");
549 
550  lua_pushcfunction(luastate, LuaCallbackFileInfo);
551  lua_setglobal(luastate, "SCFileInfo");
552  lua_pushcfunction(luastate, LuaCallbackFileState);
553  lua_setglobal(luastate, "SCFileState");
554 
555  lua_pushcfunction(luastate, LuaCallbackThreadInfo);
556  lua_setglobal(luastate, "SCThreadInfo");
557  return 0;
558 }
559 
560 int LuaStateNeedProto(lua_State *luastate, AppProto alproto)
561 {
562  AppProto flow_alproto = 0;
563  Flow *flow = LuaStateGetFlow(luastate);
564  if (flow == NULL)
565  return LuaCallbackError(luastate, "internal error: no flow");
566 
567  flow_alproto = flow->alproto;
568 
569  return (alproto == flow_alproto);
570 }
tm-threads.h
len
uint8_t len
Definition: app-layer-dnp3.h:2
LuaStateGetStreamingBuffer
LuaStreamingBuffer * LuaStateGetStreamingBuffer(lua_State *luastate)
Definition: util-lua.c:254
PacketAlert_::s
const struct Signature_ * s
Definition: decode.h:243
ThreadVars_::name
char name[16]
Definition: threadvars.h:65
util-lua-common.h
LuaPushTableKeyValueInt
void LuaPushTableKeyValueInt(lua_State *luastate, const char *key, int value)
Definition: util-lua-common.c:79
LuaStreamingBuffer_
Definition: util-lua.h:34
SCLogWarningRaw
#define SCLogWarningRaw(file, func, line,...)
Definition: util-debug.h:251
FILE_SHA256
#define FILE_SHA256
Definition: util-file.h:52
ACTION_PASS
#define ACTION_PASS
Definition: action-globals.h:34
ACTION_REJECT
#define ACTION_REJECT
Definition: action-globals.h:31
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
LuaStateGetSignature
Signature * LuaStateGetSignature(lua_State *luastate)
get signature pointer from the lua state
Definition: util-lua.c:207
util-lua.h
AppProto
uint16_t AppProto
Definition: app-layer-protos.h:85
LuaCallbackError
int LuaCallbackError(lua_State *luastate, const char *msg)
Definition: util-lua-common.c:59
action-globals.h
threads.h
FILE_STATE_OPENED
@ FILE_STATE_OPENED
Definition: util-file.h:70
Flow_
Flow data structure.
Definition: flow.h:354
File_::state
FileState state
Definition: util-file.h:82
File_::file_store_id
uint32_t file_store_id
Definition: util-file.h:85
util-privs.h
FILE_STATE_TRUNCATED
@ FILE_STATE_TRUNCATED
Definition: util-file.h:73
File_::sha1
uint8_t sha1[SC_SHA1_LEN]
Definition: util-file.h:96
util-unittest.h
lua_State
struct lua_State lua_State
Definition: suricata-common.h:515
Signature_::gid
uint32_t gid
Definition: detect.h:650
File_::name_len
uint16_t name_len
Definition: util-file.h:81
ACTION_REJECT_DST
#define ACTION_REJECT_DST
Definition: action-globals.h:32
LuaStateGetThreadVars
ThreadVars * LuaStateGetThreadVars(lua_State *luastate)
get tv pointer from the lua state
Definition: util-lua.c:102
app-layer-htp.h
File_::md5
uint8_t md5[SC_MD5_LEN]
Definition: util-file.h:94
util-debug.h
strlcat
size_t strlcat(char *, const char *src, size_t siz)
Definition: util-strlcatu.c:45
util-print.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
pkt-var.h
FileTrackedSize
uint64_t FileTrackedSize(const File *file)
get the size of the file
Definition: util-file.c:343
util-time.h
app-layer-parser.h
Signature_::action
uint8_t action
Definition: detect.h:629
ACTION_ALERT
#define ACTION_ALERT
Definition: action-globals.h:29
conf.h
ThreadVars_::thread_group_name
char * thread_group_name
Definition: threadvars.h:67
FILE_STATE_MAX
@ FILE_STATE_MAX
Definition: util-file.h:76
File_::name
uint8_t * name
Definition: util-file.h:88
util-proto-name.h
SCGetThreadIdLong
#define SCGetThreadIdLong(...)
Definition: threads.h:255
Signature_::class_msg
char * class_msg
Definition: detect.h:675
ACTION_REJECT_BOTH
#define ACTION_REJECT_BOTH
Definition: action-globals.h:33
File_::flags
uint16_t flags
Definition: util-file.h:80
FILE_STATE_CLOSED
@ FILE_STATE_CLOSED
Definition: util-file.h:71
File_
Definition: util-file.h:79
LuaPushTableKeyValueArray
void LuaPushTableKeyValueArray(lua_State *luastate, const char *key, const uint8_t *value, size_t len)
Definition: util-lua-common.c:97
util-conf.h
LuaStateGetTxId
uint64_t LuaStateGetTxId(lua_State *luastate)
get tx id from the lua state
Definition: util-lua.c:143
suricata-common.h
OUTPUT_STREAMING_FLAG_OPEN
#define OUTPUT_STREAMING_FLAG_OPEN
Definition: output-streaming.h:29
LuaStreamingBuffer_::data_len
uint32_t data_len
Definition: util-lua.h:36
LuaStateGetPacketAlert
PacketAlert * LuaStateGetPacketAlert(lua_State *luastate)
get packet alert pointer from the lua state
Definition: util-lua.c:191
LuaStreamingBuffer_::data
const uint8_t * data
Definition: util-lua.h:35
FILE_STORED
#define FILE_STORED
Definition: util-file.h:56
ACTION_DROP
#define ACTION_DROP
Definition: action-globals.h:30
FILE_MD5
#define FILE_MD5
Definition: util-file.h:48
Signature_::rev
uint32_t rev
Definition: detect.h:651
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
File_::sha256
uint8_t sha256[SC_SHA256_LEN]
Definition: util-file.h:98
Signature_::prio
int prio
Definition: detect.h:652
threadvars.h
ConfigGetLogDirectory
const char * ConfigGetLogDirectory(void)
Definition: util-conf.c:38
OUTPUT_STREAMING_FLAG_TOSERVER
#define OUTPUT_STREAMING_FLAG_TOSERVER
Definition: output-streaming.h:31
str
#define str(s)
Definition: suricata-common.h:300
SCLogNoticeRaw
#define SCLogNoticeRaw(file, func, line,...)
Definition: util-debug.h:239
util-logopenfile.h
Signature_::id
uint32_t id
Definition: detect.h:649
LuaStateGetFile
File * LuaStateGetFile(lua_State *luastate)
get file pointer from the lua state
Definition: util-lua.c:223
util-buffer.h
Signature_
Signature container.
Definition: detect.h:614
LuaStateGetFlow
Flow * LuaStateGetFlow(lua_State *luastate)
get flow pointer from lua state
Definition: util-lua.c:161
OUTPUT_STREAMING_FLAG_CLOSE
#define OUTPUT_STREAMING_FLAG_CLOSE
Definition: output-streaming.h:30
FILE_SHA1
#define FILE_SHA1
Definition: util-file.h:50
OUTPUT_STREAMING_FLAG_TOCLIENT
#define OUTPUT_STREAMING_FLAG_TOCLIENT
Definition: output-streaming.h:32
SCLogInfoRaw
#define SCLogInfoRaw(file, func, line,...)
Definition: util-debug.h:225
PacketAlert_
Definition: decode.h:239
LuaGetStringArgument
const char * LuaGetStringArgument(lua_State *luastate, int argc)
Definition: util-lua-common.c:66
LuaPushTableKeyValueString
void LuaPushTableKeyValueString(lua_State *luastate, const char *key, const char *value)
Push a key plus string value to the stack.
Definition: util-lua-common.c:90
Signature_::msg
char * msg
Definition: detect.h:672
SCLogErrorRaw
#define SCLogErrorRaw(file, func, line,...)
Definition: util-debug.h:263
msg
const char * msg
Definition: app-layer-htp.c:559
Flow_::alproto
AppProto alproto
application level protocol
Definition: flow.h:448
FILE_STATE_ERROR
@ FILE_STATE_ERROR
Definition: util-file.h:75
LuaRegisterFunctions
int LuaRegisterFunctions(lua_State *luastate)
Definition: util-lua-common.c:520
LuaStateNeedProto
int LuaStateNeedProto(lua_State *luastate, AppProto alproto)
Definition: util-lua-common.c:560
LuaStreamingBuffer_::flags
uint8_t flags
Definition: util-lua.h:37
output.h
FILE_STATE_NONE
@ FILE_STATE_NONE
Definition: util-file.h:69
LuaPushStringBuffer
int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len)
Definition: util-lua.c:319
app-layer.h