suricata
util-lua-builtins.c
Go to the documentation of this file.
1
/* Copyright (C) 2025 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
#include "
suricata-common.h
"
19
#include "
util-lua-builtins.h
"
20
#include "
util-lua-base64lib.h
"
21
#include "
util-lua-dataset.h
"
22
#include "
util-lua-dnp3.h
"
23
#include "
util-lua-dns.h
"
24
#include "
util-lua-flowlib.h
"
25
#include "
util-lua-hashlib.h
"
26
#include "
util-lua-packetlib.h
"
27
28
#include "lauxlib.h"
29
30
static
const
luaL_Reg builtins[] = {
31
{
"suricata.base64"
,
SCLuaLoadBase64Lib
},
32
{
"suricata.dataset"
,
LuaLoadDatasetLib
},
33
{
"suricata.dnp3"
,
SCLuaLoadDnp3Lib
},
34
{
"suricata.dns"
,
SCLuaLoadDnsLib
},
35
{
"suricata.flow"
,
LuaLoadFlowLib
},
36
{
"suricata.hashlib"
,
SCLuaLoadHashlib
},
37
{
"suricata.packet"
,
LuaLoadPacketLib
},
38
{ NULL, NULL },
39
};
40
41
/**
42
* \brief Load a Suricata built-in module in a sand-boxed environment.
43
*/
44
bool
SCLuaLoadBuiltIns
(
lua_State
*L,
const
char
*
name
)
45
{
46
for
(
const
luaL_Reg *lib = builtins; lib->name; lib++) {
47
if
(strcmp(
name
, lib->name) == 0) {
48
lib->func(L);
49
return
true
;
50
}
51
}
52
return
false
;
53
}
54
55
/**
56
* \brief Register Suricata built-in modules for loading in a
57
* non-sandboxed environment.
58
*/
59
void
SCLuaRequirefBuiltIns
(
lua_State
*L)
60
{
61
for
(
const
luaL_Reg *lib = builtins; lib->name; lib++) {
62
luaL_requiref(L, lib->name, lib->func, 0);
63
lua_pop(L, 1);
64
}
65
}
LuaLoadPacketLib
int LuaLoadPacketLib(lua_State *luastate)
Definition:
util-lua-packetlib.c:273
util-lua-dataset.h
util-lua-builtins.h
SCLuaLoadHashlib
int SCLuaLoadHashlib(lua_State *L)
Definition:
util-lua-hashlib.c:409
util-lua-hashlib.h
SCLuaLoadBase64Lib
int SCLuaLoadBase64Lib(lua_State *L)
Definition:
util-lua-base64lib.c:113
LuaLoadDatasetLib
void LuaLoadDatasetLib(lua_State *luastate)
Definition:
util-lua-dataset.c:123
lua_State
struct lua_State lua_State
Definition:
suricata-common.h:515
SCLuaLoadDnp3Lib
int SCLuaLoadDnp3Lib(lua_State *L)
Definition:
util-lua-dnp3.c:202
util-lua-packetlib.h
util-lua-dnp3.h
name
const char * name
Definition:
tm-threads.c:2081
util-lua-flowlib.h
SCLuaRequirefBuiltIns
void SCLuaRequirefBuiltIns(lua_State *L)
Register Suricata built-in modules for loading in a non-sandboxed environment.
Definition:
util-lua-builtins.c:59
SCLuaLoadBuiltIns
bool SCLuaLoadBuiltIns(lua_State *L, const char *name)
Load a Suricata built-in module in a sand-boxed environment.
Definition:
util-lua-builtins.c:44
LuaLoadFlowLib
int LuaLoadFlowLib(lua_State *luastate)
Definition:
util-lua-flowlib.c:286
suricata-common.h
util-lua-dns.h
SCLuaLoadDnsLib
int SCLuaLoadDnsLib(lua_State *L)
Definition:
util-lua-dns.c:163
util-lua-base64lib.h
src
util-lua-builtins.c
Generated on Sat Mar 29 2025 23:30:37 for suricata by
1.8.18