mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Makes Lua::run const
This commit is contained in:
parent
3efc14bc08
commit
fc0fef3646
@ -121,7 +121,7 @@ const char *Lua::blob_reader(lua_State *L, void *ud, size_t *size) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int Lua::run(Transaction *t, const std::string &str) {
|
int Lua::run(Transaction *t, const std::string &str) const {
|
||||||
#ifdef WITH_LUA
|
#ifdef WITH_LUA
|
||||||
std::string luaRet;
|
std::string luaRet;
|
||||||
const char *a = NULL;
|
const char *a = NULL;
|
||||||
@ -138,10 +138,12 @@ int Lua::run(Transaction *t, const std::string &str) {
|
|||||||
luaL_setfuncs(L, mscLuaLib, 0);
|
luaL_setfuncs(L, mscLuaLib, 0);
|
||||||
lua_setglobal(L, "m");
|
lua_setglobal(L, "m");
|
||||||
|
|
||||||
|
LuaScriptBlob blob(m_blob);
|
||||||
|
|
||||||
#ifdef WITH_LUA_5_1
|
#ifdef WITH_LUA_5_1
|
||||||
int rc = lua_load(L, Lua::blob_reader, &m_blob, m_scriptName.c_str());
|
int rc = lua_load(L, Lua::blob_reader, &blob, m_scriptName.c_str());
|
||||||
#else
|
#else
|
||||||
int rc = lua_load(L, Lua::blob_reader, &m_blob, m_scriptName.c_str(),
|
int rc = lua_load(L, Lua::blob_reader, &blob, m_scriptName.c_str(),
|
||||||
NULL);
|
NULL);
|
||||||
#endif
|
#endif
|
||||||
if (rc != LUA_OK) {
|
if (rc != LUA_OK) {
|
||||||
|
@ -43,6 +43,14 @@ class LuaScriptBlob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LuaScriptBlob(const LuaScriptBlob &other) :
|
||||||
|
m_data(NULL),
|
||||||
|
m_len(other.m_len) {
|
||||||
|
m_data = (unsigned char *)std::malloc(m_len);
|
||||||
|
// FIXME: m_data NULL?
|
||||||
|
std::memcpy(m_data, other.m_data, m_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void write(const void *data, size_t len) {
|
void write(const void *data, size_t len) {
|
||||||
unsigned char *d = (unsigned char *)realloc((unsigned char *)m_data, len + m_len);
|
unsigned char *d = (unsigned char *)realloc((unsigned char *)m_data, len + m_len);
|
||||||
@ -68,7 +76,7 @@ class Lua {
|
|||||||
Lua() { }
|
Lua() { }
|
||||||
|
|
||||||
bool load(const std::string &script, std::string *err);
|
bool load(const std::string &script, std::string *err);
|
||||||
int run(Transaction *t, const std::string &str="");
|
int run(Transaction *t, const std::string &str="") const;
|
||||||
static bool isCompatible(const std::string &script, Lua *l, std::string *error);
|
static bool isCompatible(const std::string &script, Lua *l, std::string *error);
|
||||||
|
|
||||||
#ifdef WITH_LUA
|
#ifdef WITH_LUA
|
||||||
|
@ -46,8 +46,8 @@ functionStatic:headers/modsecurity/transaction.h:437
|
|||||||
duplicateBranch:src/audit_log/audit_log.cc:223
|
duplicateBranch:src/audit_log/audit_log.cc:223
|
||||||
unreadVariable:src/request_body_processor/multipart.cc:435
|
unreadVariable:src/request_body_processor/multipart.cc:435
|
||||||
stlcstrParam:src/audit_log/writer/parallel.cc:145
|
stlcstrParam:src/audit_log/writer/parallel.cc:145
|
||||||
functionStatic:src/engine/lua.h:70
|
functionStatic:src/engine/lua.h:78
|
||||||
functionStatic:src/engine/lua.h:71
|
functionStatic:src/engine/lua.h:79
|
||||||
functionConst:src/utils/geo_lookup.h:49
|
functionConst:src/utils/geo_lookup.h:49
|
||||||
useInitializationList:src/operators/rbl.h:69
|
useInitializationList:src/operators/rbl.h:69
|
||||||
constStatement:test/common/modsecurity_test.cc:82
|
constStatement:test/common/modsecurity_test.cc:82
|
||||||
|
Loading…
x
Reference in New Issue
Block a user