suricata
detect-transform-luaxform.c
Go to the documentation of this file.
1 /* Copyright (C) 2024 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 Jeff Lucovsky <jlucovsky@oisf.net>
22  *
23  * Implements the luxaform transform keyword
24  */
25 
26 #include "suricata-common.h"
27 
28 #include "detect.h"
29 #include "detect-engine.h"
30 #include "detect-engine-buffer.h"
31 #include "detect-parse.h"
32 #include "detect-lua.h"
34 #include "detect-lua-extensions.h"
35 
36 #include "util-lua.h"
37 #include "util-lua-common.h"
38 #include "util-lua-builtins.h"
39 
40 static int DetectTransformLuaxformSetup(DetectEngineCtx *, Signature *, const char *);
41 static void DetectTransformLuaxformFree(DetectEngineCtx *de_ctx, void *ptr);
42 static void TransformLuaxform(
43  DetectEngineThreadCtx *det_ctx, InspectionBuffer *buffer, const void *options);
44 
45 #define LUAXFORM_MAX_ARGS 10
46 
47 /* rate-limit the transform error warning to one per thread per type.
48  * tlua is a DetectLuaThreadData, shared with the lua rule path - one
49  * flags namespace: 0-4 option bits, 23-26 that path's sticky bits,
50  * so the luaxform sticky bits take 27-30 */
51 #define LFLAG_ERROR_LOGGED BIT_U32(27)
52 #define LFLAG_BLOCKED_FUNCTION_LOGGED BIT_U32(28)
53 #define LFLAG_INSTRUCTION_LIMIT_LOGGED BIT_U32(29)
54 #define LFLAG_MEMORY_LIMIT_LOGGED BIT_U32(30)
55 
56 typedef struct DetectLuaxformData {
59  int arg_count;
60  uint64_t alloc_limit;
62  const char *filename;
63  char *copystr;
64  const char *id_data;
65  uint32_t id_data_len;
66  const char *args[LUAXFORM_MAX_ARGS];
68 
69 typedef struct DetectLuaxformThreadData {
72 
73 static void DetectTransformLuaxformId(const uint8_t **data, uint32_t *length, const void *context)
74 {
75  if (context) {
76  DetectLuaxformData *lua = (DetectLuaxformData *)context;
77  *data = (uint8_t *)lua->id_data;
78  *length = lua->id_data_len;
79  }
80 }
81 
82 static void DetectTransformLuaxformFree(DetectEngineCtx *de_ctx, void *ptr)
83 {
84  if (ptr != NULL) {
86 
87  if (lua->filename)
88  SCFree((void *)lua->filename);
89 
90  if (lua->copystr)
91  SCFree((void *)lua->copystr);
92 
93  if (lua->id_data)
94  SCFree((void *)lua->id_data);
95 
96  if (de_ctx) {
97  DetectUnregisterThreadCtxFuncs(de_ctx, lua, "luaxform");
98  }
99 
100  SCFree(lua);
101  }
102 }
103 
104 static int DetectTransformLuaxformSetupPrime(
106 {
108  if (luastate == NULL)
109  return -1;
110  if (ld->allow_restricted_functions) {
111  luaL_openlibs(luastate);
112  SCLuaRequirefBuiltIns(luastate);
113  } else {
114  SCLuaSbLoadLibs(luastate);
115  }
116 
117  int status = luaL_loadfile(luastate, ld->filename);
118  if (status) {
119  SCLogError("couldn't load file: %s", lua_tostring(luastate, -1));
120  goto error;
121  }
122 
123  /* prime the script (or something) */
124  if (lua_pcall(luastate, 0, 0, 0) != 0) {
125  SCLogError("couldn't prime file: %s", lua_tostring(luastate, -1));
126  goto error;
127  }
128 
129  lua_getglobal(luastate, "transform");
130  if (lua_type(luastate, -1) != LUA_TFUNCTION) {
131  SCLogError("no transform function in script");
132  goto error;
133  }
134  lua_pop(luastate, 1);
135 
136  SCLuaSbStateClose(luastate);
137  return 0;
138 
139 error:
140  SCLuaSbStateClose(luastate);
141  return -1;
142 }
143 
144 static DetectLuaxformData *DetectLuaxformParse(DetectEngineCtx *de_ctx, const char *optsstr)
145 {
146  DetectLuaxformData *lua = NULL;
147 
148  /* We have a correct lua option */
149  lua = SCCalloc(1, sizeof(DetectLuaxformData));
150  if (unlikely(lua == NULL)) {
151  FatalError("unable to allocate memory for Lua transform: %s", optsstr);
152  }
153 
154  lua->copystr = strdup(optsstr);
155  lua->id_data = strdup(optsstr);
156  if (unlikely(lua->copystr == NULL || lua->id_data == NULL)) {
157  FatalError("unable to allocate memory for Lua transform: %s", optsstr);
158  }
159 
160  lua->id_data_len = (uint32_t)strlen(lua->id_data);
161 
162  int count = 0;
163  char *saveptr = NULL;
164  char *token = strtok_r(lua->copystr, ",", &saveptr);
165  while (token != NULL && count < LUAXFORM_MAX_ARGS) {
166  lua->args[count++] = token;
167  token = strtok_r(NULL, ",", &saveptr);
168  }
169 
170  if (count == 0) {
171  SCLogError("Lua script name not supplied");
172  goto error;
173  }
174 
175  lua->arg_count = count - 1;
176 
177  /* get full filename */
179  if (lua->filename == NULL) {
180  goto error;
181  }
182 
183  return lua;
184 
185 error:
186  if (lua != NULL)
187  DetectTransformLuaxformFree(de_ctx, lua);
188  return NULL;
189 }
190 
191 static void *DetectLuaxformThreadInit(void *data)
192 {
193  /* Note: This will always be non-null as alloc errors are checked before registering callback */
194  DetectLuaxformData *lua = (DetectLuaxformData *)data;
195 
197  if (unlikely(t == NULL)) {
198  FatalError("unable to allocate luaxform context memory");
199  }
200 
202  if (t->luastate == NULL) {
203  SCLogError("luastate pool depleted");
204  goto error;
205  }
206 
207  if (lua->allow_restricted_functions) {
208  luaL_openlibs(t->luastate);
210  } else {
212  }
213 
214  int status = luaL_loadfile(t->luastate, lua->filename);
215  if (status) {
216  SCLogError("couldn't load file: %s", lua_tostring(t->luastate, -1));
217  goto error;
218  }
219 
220  /* setup calls get a fresh instruction budget so a low max-instructions
221  * bounds per-packet work, not engine start or reload */
223  /* prime the script (or something) */
224  if (lua_pcall(t->luastate, 0, 0, 0) != 0) {
225  SCLogError("couldn't prime file: %s", lua_tostring(t->luastate, -1));
226  goto error;
227  }
228 
229  /* when present: thread_init call */
230  lua_getglobal(t->luastate, "thread_init");
231  if (lua_isfunction(t->luastate, -1)) {
233  if (lua_pcall(t->luastate, 0, 0, 0) != 0) {
234  SCLogError("couldn't run script 'thread_init' function: %s",
235  lua_tostring(t->luastate, -1));
236  goto error;
237  }
238  } else {
239  lua_pop(t->luastate, 1);
240  }
241 
242  return (void *)t;
243 
244 error:
245  if (t->luastate != NULL)
247  SCFree(t);
248  return NULL;
249 }
250 
251 static void DetectLuaxformThreadFree(void *ctx)
252 {
253  if (ctx != NULL) {
255  if (t->luastate != NULL)
257  SCFree(t);
258  }
259 }
260 
261 /**
262  * \internal
263  * \brief Apply the luaxform keyword to the last pattern match
264  * \param de_ctx detection engine ctx
265  * \param s signature
266  * \param str lua filename and optional args
267  * \retval 0 ok
268  * \retval -1 failure
269  */
270 static int DetectTransformLuaxformSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optsstr)
271 {
272  SCEnter();
273 
274  /* First check if Lua rules are enabled, by default Lua in rules
275  * is disabled. */
276  int enabled = 0;
277  if (SCConfGetBool("security.lua.allow-rules", &enabled) == 1 && !enabled) {
278  SCLogError("Lua rules disabled by security configuration: security.lua.allow-rules");
279  SCReturnInt(-1);
280  }
281 
282  DetectLuaxformData *lua = DetectLuaxformParse(de_ctx, optsstr);
283  if (lua == NULL)
284  goto error;
285 
286  /* Load lua sandbox configurations */
287  intmax_t lua_alloc_limit = DEFAULT_LUA_ALLOC_LIMIT;
288  intmax_t lua_instruction_limit = DEFAULT_LUA_INSTRUCTION_LIMIT;
289  int allow_restricted_functions = 0;
290  (void)SCConfGetInt("security.lua.max-bytes", &lua_alloc_limit);
291  (void)SCConfGetInt("security.lua.max-instructions", &lua_instruction_limit);
292  (void)SCConfGetBool("security.lua.allow-restricted-functions", &allow_restricted_functions);
293 
294  /* a negative value would wrap the cap below the baseline and fail
295  * every call silently; 0 means unlimited */
296  if (lua_alloc_limit < 0) {
297  SCLogError("security.lua.max-bytes must be non-negative (got %" PRIdMAX "), "
298  "use 0 for no limit",
299  lua_alloc_limit);
300  goto error;
301  }
302 
303  lua->alloc_limit = lua_alloc_limit;
304  lua->instruction_limit = lua_instruction_limit;
305  lua->allow_restricted_functions = allow_restricted_functions;
306 
307  if (DetectTransformLuaxformSetupPrime(de_ctx, lua, s) == -1) {
308  goto error;
309  }
310 
312  de_ctx, "luaxform", DetectLuaxformThreadInit, (void *)lua, DetectLuaxformThreadFree, 0);
313  if (lua->thread_ctx_id == -1)
314  goto error;
315 
317  SCReturnInt(0);
318 
319 error:
320 
321  if (lua != NULL)
322  DetectTransformLuaxformFree(de_ctx, lua);
323  SCReturnInt(-1);
324 }
325 
326 static void TransformLuaxform(
327  DetectEngineThreadCtx *det_ctx, InspectionBuffer *buffer, const void *options)
328 {
329  if (buffer->inspect_len == 0) {
330  return;
331  }
332 
333  const DetectLuaxformData *lua = options;
334  DetectLuaThreadData *tlua =
336  if (tlua == NULL) {
337  return;
338  }
339 
340  lua_getglobal(tlua->luastate, "transform");
341 
342  const uint8_t *input = buffer->inspect;
343  const uint32_t input_len = buffer->inspect_len;
344 
345  /* disable bytes limit temporarily to allow the setup of buffer and other data the script will
346  * use. */
347  const uint64_t cfg_limit = SCLuaSbResetBytesLimit(tlua->luastate);
348 
349  /* Lua script args are: buffer, rule args table */
350  LuaPushStringBuffer(tlua->luastate, input, (size_t)input_len);
351 
352  /*
353  * Add provided arguments for lua script (these are optionally
354  * provided by the rule writer).
355  *
356  * Start at offset 1 (arg[0] is the lua script filename)
357  */
358  lua_newtable(tlua->luastate);
359  for (int i = 1; i < lua->arg_count + 1; i++) {
360  LuaPushInteger(tlua->luastate, i);
361  lua_pushstring(tlua->luastate, lua->args[i]);
362  lua_settable(tlua->luastate, -3);
363  }
364 
365  /* restore configured bytes limit and account for the allocations done for the setup above. */
366  SCLuaSbRestoreBytesLimit(tlua->luastate, cfg_limit);
369 
370  if (LUA_OK != lua_pcall(tlua->luastate, 2, 2, 0)) {
371  const char *reason = lua_tostring(tlua->luastate, -1);
372  SCLuaSbState *context = SCLuaSbGetContext(tlua->luastate);
373  uint32_t flag = LFLAG_ERROR_LOGGED;
374  /* mirror DetectLuaRunMatch: the aggregate counts every failure,
375  * a sandbox failure adds its category counter */
376  StatsCounterIncr(&det_ctx->tv->stats, det_ctx->lua_transform_errors);
377  if (context->blocked_function_error) {
380  } else if (context->instruction_count_error) {
383  } else if (context->memory_limit_error) {
386  reason = "memory limit exceeded";
387  }
388  if (!(tlua->flags & flag)) {
389  SCLogWarning("luaxform '%s' failed to run successfully: %s "
390  "(buffer keeps the untransformed data)",
391  lua->filename, reason);
392  tlua->flags |= flag;
393  }
394  } else {
395  /* Lua transform functions must return 2 values: buffer and length */
396  int return_value_count = lua_gettop(tlua->luastate);
397  if (return_value_count != 2) {
398  StatsCounterIncr(&det_ctx->tv->stats, det_ctx->lua_transform_errors);
399  if (!(tlua->flags & LFLAG_ERROR_LOGGED)) {
400  SCLogWarning("luaxform '%s': expected 2 return values (buffer, length) "
401  "but got %d; keeping the untransformed buffer",
402  lua->filename, return_value_count);
403  tlua->flags |= LFLAG_ERROR_LOGGED;
404  }
405  goto error;
406  }
407 
408  if (lua_isstring(tlua->luastate, -2)) {
409  size_t real_len = 0;
410  const char *transformed_buffer = lua_tolstring(tlua->luastate, -2, &real_len);
411  int isnum = 0;
412  lua_Integer transformed_buffer_byte_count = lua_tointegerx(tlua->luastate, -1, &isnum);
413  /* the returned length is script-controlled: validate it against
414  * the real string length before copying. isnum keeps a missing
415  * second return (lua_pcall pads it with nil) from reading as a
416  * valid zero length */
417  if (transformed_buffer == NULL || !isnum || transformed_buffer_byte_count < 0 ||
418  (size_t)transformed_buffer_byte_count > real_len ||
419  (size_t)transformed_buffer_byte_count > UINT32_MAX) {
420  StatsCounterIncr(&det_ctx->tv->stats, det_ctx->lua_transform_errors);
421  if (!(tlua->flags & LFLAG_ERROR_LOGGED)) {
422  if (isnum) {
423  SCLogWarning("luaxform '%s' returned an invalid length "
424  "%" PRIi64 " (string len %zu); keeping the "
425  "untransformed buffer",
426  lua->filename, (int64_t)transformed_buffer_byte_count, real_len);
427  } else {
428  SCLogWarning("luaxform '%s' returned a non-numeric length; keeping "
429  "the untransformed buffer",
430  lua->filename);
431  }
432  tlua->flags |= LFLAG_ERROR_LOGGED;
433  }
434  } else if (transformed_buffer_byte_count > 0) {
435  /* 0 is a valid empty result: the buffer stays as it was. A
436  * zero-length copy would empty it only when the thread's
437  * buffer was expanded before (history dependent) */
438  InspectionBufferCopy(buffer, (uint8_t *)transformed_buffer,
439  (uint32_t)transformed_buffer_byte_count);
440  SCLogDebug("transform returns [nbytes %" PRIi64 "] \"%p\"",
441  (int64_t)transformed_buffer_byte_count, transformed_buffer);
442  }
443  } else {
444  StatsCounterIncr(&det_ctx->tv->stats, det_ctx->lua_transform_errors);
445  if (!(tlua->flags & LFLAG_ERROR_LOGGED)) {
446  SCLogWarning("luaxform '%s' returned a non-string buffer; keeping the "
447  "untransformed buffer",
448  lua->filename);
449  tlua->flags |= LFLAG_ERROR_LOGGED;
450  }
451  }
452  }
453 
454 error:
455  while (lua_gettop(tlua->luastate) > 0) {
456  lua_pop(tlua->luastate, 1);
457  }
458  SCLuaSbRestoreBytesLimit(tlua->luastate, cfg_limit);
459 }
460 
462 {
465  "pass inspection buffer to a Lua function along with "
466  "arguments supplied to the transform";
467  sigmatch_table[DETECT_TRANSFORM_LUAXFORM].url = "/rules/transforms.html#luaxform";
469  sigmatch_table[DETECT_TRANSFORM_LUAXFORM].Free = DetectTransformLuaxformFree;
470  sigmatch_table[DETECT_TRANSFORM_LUAXFORM].Setup = DetectTransformLuaxformSetup;
472  sigmatch_table[DETECT_TRANSFORM_LUAXFORM].TransformId = DetectTransformLuaxformId;
473 }
SigTableElmt_::url
const char * url
Definition: detect.h:1548
SCLuaSbState::memory_limit_error
bool memory_limit_error
Definition: util-lua-sandbox.h:66
LFLAG_MEMORY_LIMIT_LOGGED
#define LFLAG_MEMORY_LIMIT_LOGGED
Definition: detect-transform-luaxform.c:54
detect-engine.h
SigTableElmt_::desc
const char * desc
Definition: detect.h:1547
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:78
SCLuaSbUpdateBytesLimit
void SCLuaSbUpdateBytesLimit(lua_State *L)
Definition: util-lua-sandbox.c:429
util-lua-common.h
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1532
SigTableElmt_::name
const char * name
Definition: detect.h:1545
SCLuaSbResetBytesLimit
uint64_t SCLuaSbResetBytesLimit(lua_State *L)
Definition: util-lua-sandbox.c:408
DetectThreadCtxGetKeywordThreadCtx
void * DetectThreadCtxGetKeywordThreadCtx(DetectEngineThreadCtx *det_ctx, int id)
Retrieve thread local keyword ctx by id.
Definition: detect-engine.c:4072
InspectionBufferCopy
void InspectionBufferCopy(InspectionBuffer *buffer, uint8_t *buf, uint32_t buf_len)
Definition: detect-engine-inspect-buffer.c:251
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
SigTableElmt_::flags
uint32_t flags
Definition: detect.h:1536
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
SCLuaSbGetContext
SCLuaSbState * SCLuaSbGetContext(lua_State *L)
Definition: util-lua-sandbox.c:375
util-lua.h
DetectLuaxformData::arg_count
int arg_count
Definition: detect-transform-luaxform.c:59
InspectionBuffer
Definition: detect-engine-inspect-buffer.h:34
LFLAG_INSTRUCTION_LIMIT_LOGGED
#define LFLAG_INSTRUCTION_LIMIT_LOGGED
Definition: detect-transform-luaxform.c:53
SCLuaSbState
Definition: util-lua-sandbox.h:40
SIGMATCH_QUOTES_OPTIONAL
#define SIGMATCH_QUOTES_OPTIONAL
Definition: detect-engine-register.h:347
DetectLuaxformData::id_data_len
uint32_t id_data_len
Definition: detect-transform-luaxform.c:65
DetectLuaxformData::allow_restricted_functions
int allow_restricted_functions
Definition: detect-transform-luaxform.c:58
ctx
struct Thresholds ctx
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:966
DetectLuaxformData::thread_ctx_id
int thread_ctx_id
Definition: detect-transform-luaxform.c:57
detect-transform-luaxform.h
DEFAULT_LUA_INSTRUCTION_LIMIT
#define DEFAULT_LUA_INSTRUCTION_LIMIT
Definition: detect-lua.c:121
detect-lua.h
SCConfGetBool
int SCConfGetBool(const char *name, int *val)
Retrieve a configuration value as a boolean.
Definition: conf.c:523
SigTableElmt_::TransformId
void(* TransformId)(const uint8_t **data, uint32_t *length, const void *context)
Definition: detect.h:1524
DetectLuaxformData::filename
const char * filename
Definition: detect-transform-luaxform.c:62
util-lua-builtins.h
DetectEngineThreadCtx_::lua_transform_errors
StatsCounterId lua_transform_errors
Definition: detect.h:1459
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1527
DetectLuaThreadData::flags
uint32_t flags
Definition: detect-lua.h:32
DetectLuaThreadData::luastate
lua_State * luastate
Definition: detect-lua.h:31
lua_State
struct lua_State lua_State
Definition: suricata-common.h:527
LFLAG_ERROR_LOGGED
#define LFLAG_ERROR_LOGGED
Definition: detect-transform-luaxform.c:51
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:22
SCLuaSbRestoreBytesLimit
void SCLuaSbRestoreBytesLimit(lua_State *L, const uint64_t cfg_limit)
Definition: util-lua-sandbox.c:462
DetectEngineThreadCtx_
Definition: detect.h:1295
length
uint16_t length
Definition: decode-sctp.h:2
SCConfGetInt
int SCConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
Definition: conf.c:440
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
detect.h
DetectLuaxformData
Definition: detect-transform-luaxform.c:56
StatsCounterIncr
void StatsCounterIncr(StatsThreadContext *stats, StatsCounterId id)
Increments the local counter.
Definition: counters.c:163
DetectTransformLuaxformRegister
void DetectTransformLuaxformRegister(void)
Definition: detect-transform-luaxform.c:461
SCLogWarning
#define SCLogWarning(...)
Macro used to log WARNING messages.
Definition: util-debug.h:262
DetectEngineThreadCtx_::lua_transform_memory_limit_errors
StatsCounterId lua_transform_memory_limit_errors
Definition: detect.h:1468
DetectLuaxformData::copystr
char * copystr
Definition: detect-transform-luaxform.c:63
SCLuaSbStateClose
void SCLuaSbStateClose(lua_State *L)
Definition: util-lua-sandbox.c:384
SCLuaRequirefBuiltIns
void SCLuaRequirefBuiltIns(lua_State *L)
Register Suricata built-in modules for loading in a non-sandboxed environment.
Definition: util-lua-builtins.c:87
SCLuaSbState::blocked_function_error
bool blocked_function_error
Definition: util-lua-sandbox.h:64
DetectLuaThreadData
Definition: detect-lua.h:30
DetectEngineThreadCtx_::lua_transform_blocked_function_errors
StatsCounterId lua_transform_blocked_function_errors
Definition: detect.h:1462
SCLuaSbLoadLibs
void SCLuaSbLoadLibs(lua_State *L)
Definition: util-lua-sandbox.c:290
DetectLuaxformData
struct DetectLuaxformData DetectLuaxformData
DetectRegisterThreadCtxFuncs
int DetectRegisterThreadCtxFuncs(DetectEngineCtx *de_ctx, const char *name, void *(*InitFunc)(void *), void *data, void(*FreeFunc)(void *), int mode)
Register Thread keyword context Funcs.
Definition: detect-engine.c:4002
detect-lua-extensions.h
suricata-common.h
DEFAULT_LUA_ALLOC_LIMIT
#define DEFAULT_LUA_ALLOC_LIMIT
Definition: detect-lua.c:120
detect-engine-buffer.h
SCLuaSbResetInstructionCounter
void SCLuaSbResetInstructionCounter(lua_State *L)
Definition: util-lua-sandbox.c:473
DETECT_TRANSFORM_LUAXFORM
@ DETECT_TRANSFORM_LUAXFORM
Definition: detect-engine-register.h:283
DetectLuaxformThreadData
Definition: detect-transform-luaxform.c:69
FatalError
#define FatalError(...)
Definition: util-debug.h:517
DetectLuaxformData::args
const char * args[LUAXFORM_MAX_ARGS]
Definition: detect-transform-luaxform.c:66
DetectLuaxformData::instruction_limit
uint64_t instruction_limit
Definition: detect-transform-luaxform.c:61
InspectionBuffer::inspect_len
uint32_t inspect_len
Definition: detect-engine-inspect-buffer.h:37
InspectionBuffer::inspect
const uint8_t * inspect
Definition: detect-engine-inspect-buffer.h:35
DetectEngineThreadCtx_::tv
ThreadVars * tv
Definition: detect.h:1303
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
SCFree
#define SCFree(p)
Definition: util-mem.h:61
LUAXFORM_MAX_ARGS
#define LUAXFORM_MAX_ARGS
Definition: detect-transform-luaxform.c:45
detect-parse.h
Signature_
Signature container.
Definition: detect.h:663
DetectLuaxformData::id_data
const char * id_data
Definition: detect-transform-luaxform.c:64
SCDetectSignatureAddTransform
int SCDetectSignatureAddTransform(Signature *s, int transform, void *options)
Definition: detect-engine-buffer.c:178
SCLuaSbState::instruction_count_error
bool instruction_count_error
Definition: util-lua-sandbox.h:65
DetectLoadCompleteSigPath
char * DetectLoadCompleteSigPath(const DetectEngineCtx *de_ctx, const char *sig_file)
Create the path if default-rule-path was specified.
Definition: detect-engine-loader.c:108
SCLuaSbStateNew
lua_State * SCLuaSbStateNew(uint64_t alloclimit, uint64_t instructionlimit)
Allocate a new Lua sandbox.
Definition: util-lua-sandbox.c:342
DetectUnregisterThreadCtxFuncs
int DetectUnregisterThreadCtxFuncs(DetectEngineCtx *de_ctx, void *data, const char *name)
Remove Thread keyword context registration.
Definition: detect-engine.c:4054
DetectLuaxformThreadData::luastate
lua_State * luastate
Definition: detect-transform-luaxform.c:70
DetectLuaxformThreadData
struct DetectLuaxformThreadData DetectLuaxformThreadData
LFLAG_BLOCKED_FUNCTION_LOGGED
#define LFLAG_BLOCKED_FUNCTION_LOGGED
Definition: detect-transform-luaxform.c:52
DetectEngineThreadCtx_::lua_transform_instruction_limit_errors
StatsCounterId lua_transform_instruction_limit_errors
Definition: detect.h:1465
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
ThreadVars_::stats
StatsThreadContext stats
Definition: threadvars.h:120
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
SigTableElmt_::Transform
void(* Transform)(DetectEngineThreadCtx *, InspectionBuffer *, const void *context)
Definition: detect.h:1520
DetectLuaxformData::alloc_limit
uint64_t alloc_limit
Definition: detect-transform-luaxform.c:60
LuaPushInteger
int LuaPushInteger(lua_State *luastate, lua_Integer n)
Definition: util-lua.c:393
LuaPushStringBuffer
int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len)
Definition: util-lua.c:380