diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2022-01-13 20:44:37 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2022-01-13 20:44:37 +0000 |
commit | f1b30e10fa54d5d01d7932ecc0dd42cbaa5600d0 (patch) | |
tree | 3c92bdab14a2de208d1b9783cdef818b2f03049b /src/lua/lua_task.c | |
parent | 2d1c4a34ebdd334679d5f7954b6e34688c69f273 (diff) | |
download | rspamd-f1b30e10fa54d5d01d7932ecc0dd42cbaa5600d0.tar.gz rspamd-f1b30e10fa54d5d01d7932ecc0dd42cbaa5600d0.zip |
[Minor] Add knobs to check if an archive was obfuscated
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r-- | src/lua/lua_task.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 5ca9b4417..3fb61f9d4 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -1356,7 +1356,9 @@ static const struct luaL_reg imagelib_m[] = { LUA_FUNCTION_DEF (archive, get_type); LUA_FUNCTION_DEF (archive, get_files); LUA_FUNCTION_DEF (archive, get_files_full); +/* TODO: Export archive flags as integers to use bitops for that */ LUA_FUNCTION_DEF (archive, is_encrypted); +LUA_FUNCTION_DEF (archive, is_obfuscated); LUA_FUNCTION_DEF (archive, is_unreadable); LUA_FUNCTION_DEF (archive, get_filename); LUA_FUNCTION_DEF (archive, get_size); @@ -1366,6 +1368,7 @@ static const struct luaL_reg archivelib_m[] = { LUA_INTERFACE_DEF (archive, get_files), LUA_INTERFACE_DEF (archive, get_files_full), LUA_INTERFACE_DEF (archive, is_encrypted), + LUA_INTERFACE_DEF (archive, is_obfuscated), LUA_INTERFACE_DEF (archive, is_unreadable), LUA_INTERFACE_DEF (archive, get_filename), LUA_INTERFACE_DEF (archive, get_size), @@ -7131,6 +7134,23 @@ lua_archive_is_encrypted (lua_State *L) } static gint +lua_archive_is_obfuscated (lua_State *L) +{ + LUA_TRACE_POINT; + struct rspamd_archive *arch = lua_check_archive (L); + + if (arch != NULL) { + lua_pushboolean (L, + (arch->flags & RSPAMD_ARCHIVE_HAS_OBFUSCATED_FILES) ? true : false); + } + else { + return luaL_error (L, "invalid arguments"); + } + + return 1; +} + +static gint lua_archive_is_unreadable (lua_State *L) { LUA_TRACE_POINT; |