commit f1b30e1: [Minor] Add knobs to check if an archive was obfuscated

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Jan 13 20:56:04 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-01-13 20:44:37 +0000
URL: https://github.com/rspamd/rspamd/commit/f1b30e10fa54d5d01d7932ecc0dd42cbaa5600d0

[Minor] Add knobs to check if an archive was obfuscated

---
 src/lua/lua_task.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

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),
@@ -7130,6 +7133,23 @@ lua_archive_is_encrypted (lua_State *L)
 	return 1;
 }
 
+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)
 {


More information about the Commits mailing list