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

OISF / suricata / 22550902417

01 Mar 2026 07:32PM UTC coverage: 68.401% (-5.3%) from 73.687%
22550902417

Pull #14922

github

web-flow
github-actions: bump actions/upload-artifact from 6.0.0 to 7.0.0

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #14922: github-actions: bump actions/upload-artifact from 6.0.0 to 7.0.0

218243 of 319063 relevant lines covered (68.4%)

3284926.58 hits per line

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

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

23
#include "lua.h"
24
#include "lauxlib.h"
25

26
static const char file_mt[] = "suricata:file:mt";
27

28
struct LuaFile {
29
    File *file;
30
};
31

32
static int LuaFileGetFile(lua_State *L)
33
{
×
34
    File *file = LuaStateGetFile(L);
×
35
    if (file == NULL) {
×
36
        return LuaCallbackError(L, "error: no file found");
×
37
    }
×
38

39
    struct LuaFile *lua_file = (struct LuaFile *)lua_newuserdata(L, sizeof(*lua_file));
×
40
    if (lua_file == NULL) {
×
41
        return LuaCallbackError(L, "error: fail to allocate user data");
×
42
    }
×
43
    lua_file->file = file;
×
44

45
    luaL_getmetatable(L, file_mt);
×
46
    lua_setmetatable(L, -2);
×
47

48
    return 1;
×
49
}
×
50

51
static int LuaFileGetFileId(lua_State *L)
52
{
×
53
    struct LuaFile *lua_file = luaL_checkudata(L, 1, file_mt);
×
54
    const File *file = lua_file->file;
×
55
    lua_pushinteger(L, file->file_store_id);
×
56

57
    return 1;
×
58
}
×
59

60
static int LuaFileGetTxId(lua_State *L)
61
{
×
62
    lua_Integer tx_id = LuaStateGetTxId(L);
×
63
    lua_pushinteger(L, tx_id);
×
64

65
    return 1;
×
66
}
×
67

68
static int LuaFileGetName(lua_State *L)
69
{
×
70
    struct LuaFile *lua_file = luaL_checkudata(L, 1, file_mt);
×
71
    const File *file = lua_file->file;
×
72
    lua_pushlstring(L, (char *)file->name, file->name_len);
×
73

74
    return 1;
×
75
}
×
76

77
static int LuaFileGetSize(lua_State *L)
78
{
×
79
    struct LuaFile *lua_file = luaL_checkudata(L, 1, file_mt);
×
80
    const File *file = lua_file->file;
×
81
    lua_pushinteger(L, FileTrackedSize(file));
×
82

83
    return 1;
×
84
}
×
85

86
static int LuaFileGetMagic(lua_State *L)
87
{
×
88
#ifdef HAVE_MAGIC
×
89
    struct LuaFile *lua_file = luaL_checkudata(L, 1, file_mt);
×
90
    const File *file = lua_file->file;
×
91
    if (file->magic != NULL) {
×
92
        lua_pushstring(L, file->magic);
×
93
    } else {
×
94
        lua_pushnil(L);
×
95
    }
×
96
#else
97
    lua_pushnil(L);
98
#endif
99

100
    return 1;
×
101
}
×
102

103
static void PushHex(lua_State *L, const uint8_t *buf, size_t len)
104
{
×
105
    /* Large enough for sha256. */
106
    char hex[65] = "";
×
107
    for (size_t i = 0; i < len; i++) {
×
108
        char one[3] = "";
×
109
        snprintf(one, sizeof(one), "%02x", buf[i]);
×
110
        strlcat(hex, one, sizeof(hex));
×
111
    }
×
112

113
    lua_pushstring(L, hex);
×
114
}
×
115

116
static int LuaFileGetMd5(lua_State *L)
117
{
×
118
    struct LuaFile *lua_file = luaL_checkudata(L, 1, file_mt);
×
119
    const File *file = lua_file->file;
×
120

121
    if (file->flags & FILE_MD5) {
×
122
        PushHex(L, file->md5, sizeof(file->md5));
×
123
    } else {
×
124
        lua_pushnil(L);
×
125
    }
×
126

127
    return 1;
×
128
}
×
129

130
static int LuaFileGetSha1(lua_State *L)
131
{
×
132
    struct LuaFile *lua_file = luaL_checkudata(L, 1, file_mt);
×
133
    const File *file = lua_file->file;
×
134

135
    if (file->flags & FILE_SHA1) {
×
136
        PushHex(L, file->sha1, sizeof(file->sha1));
×
137
    } else {
×
138
        lua_pushnil(L);
×
139
    }
×
140

141
    return 1;
×
142
}
×
143

144
static int LuaFileGetSha256(lua_State *L)
145
{
×
146
    struct LuaFile *lua_file = luaL_checkudata(L, 1, file_mt);
×
147
    const File *file = lua_file->file;
×
148

149
    if (file->flags & FILE_SHA256) {
×
150
        PushHex(L, file->sha256, sizeof(file->sha256));
×
151
    } else {
×
152
        lua_pushnil(L);
×
153
    }
×
154

155
    return 1;
×
156
}
×
157

158
static int LuaFileGetState(lua_State *L)
159
{
×
160
    struct LuaFile *lua_file = luaL_checkudata(L, 1, file_mt);
×
161
    const File *file = lua_file->file;
×
162

163
    const char *state = "UNKNOWN";
×
164
    switch (file->state) {
×
165
        case FILE_STATE_CLOSED:
×
166
            state = "CLOSED";
×
167
            break;
×
168
        case FILE_STATE_TRUNCATED:
×
169
            state = "TRUNCATED";
×
170
            break;
×
171
        case FILE_STATE_ERROR:
×
172
            state = "ERROR";
×
173
            break;
×
174
        case FILE_STATE_OPENED:
×
175
            state = "OPENED";
×
176
            break;
×
177
        case FILE_STATE_NONE:
×
178
            state = "NONE";
×
179
            break;
×
180
        case FILE_STATE_MAX:
×
181
            break;
×
182
    }
×
183

184
    lua_pushstring(L, state);
×
185

186
    return 1;
×
187
}
×
188

189
static int LuaFileIsStored(lua_State *L)
190
{
×
191
    struct LuaFile *lua_file = luaL_checkudata(L, 1, file_mt);
×
192
    const File *file = lua_file->file;
×
193
    lua_pushboolean(L, file->flags & FILE_STORED);
×
194

195
    return 1;
×
196
}
×
197

198
static const struct luaL_Reg filelib[] = {
199
    { "get_state", LuaFileGetState },
200
    { "is_stored", LuaFileIsStored },
201
    { "file_id", LuaFileGetFileId },
202
    { "tx_id", LuaFileGetTxId },
203
    { "name", LuaFileGetName },
204
    { "size", LuaFileGetSize },
205
    { "magic", LuaFileGetMagic },
206
    { "md5", LuaFileGetMd5 },
207
    { "sha1", LuaFileGetSha1 },
208
    { "sha256", LuaFileGetSha256 },
209
    { NULL, NULL },
210
};
211

212
static const struct luaL_Reg filemodlib[] = {
213
    { "get_file", LuaFileGetFile },
214
    { NULL, NULL },
215
};
216

217
int SCLuaLoadFileLib(lua_State *L)
218
{
×
219
    luaL_newmetatable(L, file_mt);
×
220
    lua_pushvalue(L, -1);
×
221
    lua_setfield(L, -2, "__index");
×
222
    luaL_setfuncs(L, filelib, 0);
×
223

224
    luaL_newlib(L, filemodlib);
×
225

226
    return 1;
×
227
}
×
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