suricata
detect-lua.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2022 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 
24 #ifndef SURICATA_DETECT_LUA_H
25 #define SURICATA_DETECT_LUA_H
26 
27 #include "util-lua.h"
28 #include "util-lua-sandbox.h"
29 
30 typedef struct DetectLuaThreadData {
32  uint32_t flags;
34 
35 #define DETECT_LUA_MAX_FLOWVARS 15
36 #define DETECT_LUA_MAX_FLOWINTS 15
37 #define DETECT_LUA_MAX_BYTEVARS 15
38 
40  char *name;
41  uint32_t id;
43 
44 typedef struct DetectLuaData {
46  int negated;
47  char *filename;
48  const Signature *signature; /* the exact sig pointer passed to init();
49  * bytevar.map() must match it */
50  uint32_t flags;
51  char *buffername; /* buffer name in case of a single buffer */
53  uint16_t flowints;
54  uint16_t flowvars;
56  uint16_t bytevars;
58  uint64_t alloc_limit;
60  bool register_in_init; /* set around the init() call: register()
61  * mutates the shared ld, so it is only
62  * allowed there */
64 
65 /* prototypes */
66 void DetectLuaRegister (void);
68  const Signature *s, const SigMatchData *smd,
69  const uint8_t *buffer, uint32_t buffer_len, uint32_t offset,
70  Flow *f);
71 
72 void LuaDumpStack(lua_State *state, const char *prefix);
73 
74 #endif /* SURICATA_DETECT_LUA_H */
DetectLuaData::bytevars
uint16_t bytevars
Definition: detect-lua.h:56
DetectLuaData
Definition: detect-lua.h:44
offset
uint64_t offset
Definition: util-streaming-buffer.h:0
DetectLuaData::signature
const Signature * signature
Definition: detect-lua.h:48
DetectLuaDataBytevarEntry_::name
char * name
Definition: detect-lua.h:40
DetectLuaData::flags
uint32_t flags
Definition: detect-lua.h:50
util-lua.h
DetectLuaDataBytevarEntry_
Definition: detect-lua.h:39
Flow_
Flow data structure.
Definition: flow.h:360
DETECT_LUA_MAX_FLOWVARS
#define DETECT_LUA_MAX_FLOWVARS
Definition: detect-lua.h:35
DetectLuaData
struct DetectLuaData DetectLuaData
DetectLuaData::flowvar
uint32_t flowvar[DETECT_LUA_MAX_FLOWVARS]
Definition: detect-lua.h:55
SigMatchData_
Data needed for Match()
Definition: detect.h:340
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
DetectLuaData::register_in_init
bool register_in_init
Definition: detect-lua.h:60
DetectLuaMatchBuffer
int DetectLuaMatchBuffer(DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, const uint8_t *buffer, uint32_t buffer_len, uint32_t offset, Flow *f)
Definition: detect-lua.c:230
DetectLuaData::buffername
char * buffername
Definition: detect-lua.h:51
DetectLuaData::negated
int negated
Definition: detect-lua.h:46
DetectLuaDataBytevarEntry
struct DetectLuaDataBytevarEntry_ DetectLuaDataBytevarEntry
DetectEngineThreadCtx_
Definition: detect.h:1295
DetectLuaData::thread_ctx_id
int thread_ctx_id
Definition: detect-lua.h:45
DetectLuaData::instruction_limit
uint64_t instruction_limit
Definition: detect-lua.h:59
DETECT_LUA_MAX_BYTEVARS
#define DETECT_LUA_MAX_BYTEVARS
Definition: detect-lua.h:37
DETECT_LUA_MAX_FLOWINTS
#define DETECT_LUA_MAX_FLOWINTS
Definition: detect-lua.h:36
DetectLuaData::bytevar
DetectLuaDataBytevarEntry bytevar[DETECT_LUA_MAX_BYTEVARS]
Definition: detect-lua.h:57
DetectLuaData::alloc_limit
uint64_t alloc_limit
Definition: detect-lua.h:58
DetectLuaData::flowints
uint16_t flowints
Definition: detect-lua.h:53
DetectLuaData::flowint
uint32_t flowint[DETECT_LUA_MAX_FLOWINTS]
Definition: detect-lua.h:52
DetectLuaThreadData
Definition: detect-lua.h:30
util-lua-sandbox.h
LuaDumpStack
void LuaDumpStack(lua_State *state, const char *prefix)
dump stack from lua state to screen
Definition: detect-lua.c:124
DetectLuaData::flowvars
uint16_t flowvars
Definition: detect-lua.h:54
Signature_
Signature container.
Definition: detect.h:663
DetectLuaThreadData
struct DetectLuaThreadData DetectLuaThreadData
DetectLuaDataBytevarEntry_::id
uint32_t id
Definition: detect-lua.h:41
DetectLuaData::filename
char * filename
Definition: detect-lua.h:47
DetectLuaRegister
void DetectLuaRegister(void)
Registration function for keyword: lua.
Definition: detect-lua.c:82
f
Flow f
Definition: fuzz_dataset.c:32