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

OISF / suricata / 22553697083

01 Mar 2026 09:58PM UTC coverage: 75.673% (+2.0%) from 73.687%
22553697083

Pull #14925

github

web-flow
Merge 288827f07 into 90823fa90
Pull Request #14925: hs: false positive coverity warning in a reference string v1

241615 of 319288 relevant lines covered (75.67%)

1333554.73 hits per line

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

0.0
/src/util-lua-log.c
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-log.h"
20
#include "util-lua.h"
21
#include "util-debug.h"
22

23
#include "lauxlib.h"
24

25
static bool LuaGetAr(lua_State *L, lua_Debug *ar)
26
{
×
27
    if (lua_getstack(L, 1, ar) && lua_getinfo(L, "nSl", ar)) {
×
28
        return true;
×
29
    }
×
30
    return false;
×
31
}
×
32

33
static int LuaLogInfo(lua_State *L)
34
{
×
35
    const char *msg = luaL_checkstring(L, 1);
×
36
    lua_Debug ar;
×
37
    if (LuaGetAr(L, &ar)) {
×
38
        const char *funcname = ar.name ? ar.name : ar.what;
×
39
        SCLogInfoRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
40
    } else {
×
41
        SCLogInfo("%s", msg);
×
42
    }
×
43
    return 0;
×
44
}
×
45

46
static int LuaLogNotice(lua_State *L)
47
{
×
48
    const char *msg = luaL_checkstring(L, 1);
×
49
    lua_Debug ar;
×
50
    if (LuaGetAr(L, &ar)) {
×
51
        const char *funcname = ar.name ? ar.name : ar.what;
×
52
        SCLogNoticeRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
53
    } else {
×
54
        SCLogNotice("%s", msg);
×
55
    }
×
56

57
    return 0;
×
58
}
×
59

60
static int LuaLogWarning(lua_State *L)
61
{
×
62
    const char *msg = luaL_checkstring(L, 1);
×
63
    lua_Debug ar;
×
64
    if (LuaGetAr(L, &ar)) {
×
65
        const char *funcname = ar.name ? ar.name : ar.what;
×
66
        SCLogWarningRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
67
    } else {
×
68
        SCLogWarning("%s", msg);
×
69
    }
×
70
    return 0;
×
71
}
×
72

73
static int LuaLogError(lua_State *L)
74
{
×
75
    const char *msg = luaL_checkstring(L, 1);
×
76
    lua_Debug ar;
×
77
    if (LuaGetAr(L, &ar)) {
×
78
        const char *funcname = ar.name ? ar.name : ar.what;
×
79
        SCLogErrorRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
80
    } else {
×
81
        SCLogError("%s", msg);
×
82
    }
×
83
    return 0;
×
84
}
×
85

86
static int LuaLogDebug(lua_State *L)
87
{
×
88
#ifdef DEBUG
89
    const char *msg = luaL_checkstring(L, 1);
90
    lua_Debug ar;
91
    if (LuaGetAr(L, &ar)) {
92
        const char *funcname = ar.name ? ar.name : ar.what;
93
        SCLogDebugRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
94
    } else {
95
        SCLogDebug("%s", msg);
96
    }
97
#endif
98
    return 0;
×
99
}
×
100

101
static int LuaLogConfig(lua_State *L)
102
{
×
103
    const char *msg = luaL_checkstring(L, 1);
×
104
    lua_Debug ar;
×
105
    if (LuaGetAr(L, &ar)) {
×
106
        const char *funcname = ar.name ? ar.name : ar.what;
×
107
        SCLogConfigRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
108
    } else {
×
109
        SCLogConfig("%s", msg);
×
110
    }
×
111
    return 0;
×
112
}
×
113

114
static int LuaLogPerf(lua_State *L)
115
{
×
116
    const char *msg = luaL_checkstring(L, 1);
×
117
    lua_Debug ar;
×
118
    if (LuaGetAr(L, &ar)) {
×
119
        const char *funcname = ar.name ? ar.name : ar.what;
×
120
        SCLogPerfRaw(ar.short_src, funcname, ar.currentline, "%s", msg);
×
121
    } else {
×
122
        SCLogPerf("%s", msg);
×
123
    }
×
124
    return 0;
×
125
}
×
126

127
static const struct luaL_Reg loglib[] = {
128
    // clang-format off
129
    { "info", LuaLogInfo },
130
    { "notice", LuaLogNotice },
131
    { "warning", LuaLogWarning },
132
    { "error", LuaLogError },
133
    { "debug", LuaLogDebug },
134
    { "config", LuaLogConfig },
135
    { "perf", LuaLogPerf },
136
    { NULL, NULL }
137
    // clang-format on
138
};
139

140
int SCLuaLoadLogLib(lua_State *L)
141
{
×
142
    luaL_newlib(L, loglib);
×
143
    return 1;
×
144
}
×
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