• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 22550237931

01 Mar 2026 06:56PM UTC coverage: 64.812% (-8.9%) from 73.687%
22550237931

Pull #14920

github

web-flow
Merge e05854a6d into 90823fa90
Pull Request #14920: draft: rust based configuration file parser and loader - v4

561 of 789 new or added lines in 4 files covered. (71.1%)

23225 existing lines in 498 files now uncovered.

131605 of 203055 relevant lines covered (64.81%)

2328818.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/util-lua-common.c
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

28
#include "threads.h"
29
#include "threadvars.h"
30

31
#include "output.h"
32
#include "util-conf.h"
33

34
#include "lua.h"
35

36
#include "util-lua.h"
37
#include "util-lua-common.h"
38

39
int LuaCallbackError(lua_State *luastate, const char *msg)
UNCOV
40
{
×
UNCOV
41
    lua_pushnil(luastate);
×
UNCOV
42
    lua_pushstring(luastate, msg);
×
UNCOV
43
    return 2;
×
UNCOV
44
}
×
45

46
const char *LuaGetStringArgument(lua_State *luastate, int idx)
UNCOV
47
{
×
48
    /* get argument */
UNCOV
49
    if (!lua_isstring(luastate, idx))
×
50
        return NULL;
×
UNCOV
51
    const char *str = lua_tostring(luastate, idx);
×
UNCOV
52
    if (str == NULL)
×
53
        return NULL;
×
UNCOV
54
    if (strlen(str) == 0)
×
55
        return NULL;
×
UNCOV
56
    return str;
×
UNCOV
57
}
×
58

59
void LuaPushTableKeyValueInt(lua_State *luastate, const char *key, int value)
UNCOV
60
{
×
UNCOV
61
    lua_pushstring(luastate, key);
×
UNCOV
62
    lua_pushnumber(luastate, value);
×
UNCOV
63
    lua_settable(luastate, -3);
×
UNCOV
64
}
×
65

66
void LuaPushTableKeyValueBoolean(lua_State *luastate, const char *key, bool value)
UNCOV
67
{
×
UNCOV
68
    lua_pushstring(luastate, key);
×
UNCOV
69
    lua_pushboolean(luastate, value);
×
UNCOV
70
    lua_settable(luastate, -3);
×
UNCOV
71
}
×
72

73
/** \brief Push a key plus string value to the stack
74
 *
75
 *  If value is NULL, string "(null")" will be put on the stack.
76
 */
77
void LuaPushTableKeyValueString(lua_State *luastate, const char *key, const char *value)
78
{
×
79
    lua_pushstring(luastate, key);
×
80
    lua_pushstring(luastate, value ? value : "(null)");
×
81
    lua_settable(luastate, -3);
×
82
}
×
83

84
/** \brief Push a key plus string value with length to the stack.
85
 */
86
void LuaPushTableKeyValueLString(
87
        lua_State *luastate, const char *key, const char *value, size_t len)
UNCOV
88
{
×
UNCOV
89
    lua_pushstring(luastate, key);
×
UNCOV
90
    lua_pushlstring(luastate, value, len);
×
UNCOV
91
    lua_settable(luastate, -3);
×
UNCOV
92
}
×
93

94
void LuaPushTableKeyValueArray(
95
        lua_State *luastate, const char *key, const uint8_t *value, size_t len)
96
{
×
97
    lua_pushstring(luastate, key);
×
98
    LuaPushStringBuffer(luastate, value, len);
×
99
    lua_settable(luastate, -3);
×
100
}
×
101

102
int LuaStateNeedProto(lua_State *luastate, AppProto alproto)
UNCOV
103
{
×
UNCOV
104
    AppProto flow_alproto = 0;
×
UNCOV
105
    Flow *flow = LuaStateGetFlow(luastate);
×
UNCOV
106
    if (flow == NULL)
×
107
        return LuaCallbackError(luastate, "internal error: no flow");
×
108

UNCOV
109
    flow_alproto = flow->alproto;
×
110

UNCOV
111
    return (alproto == flow_alproto);
×
UNCOV
112
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc