owasp-modsecurity / ModSecurity

ModSecurity is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx. It has a robust event-based programming language which provides protection from a range of attacks against web applications and allows for HTTP traffic monitoring, logging and real-time analysis.
https://www.modsecurity.org
Apache License 2.0
8.24k stars 1.61k forks source link

configure: error: LUA was explicitly referenced but it was not found #1617

Closed AnoopAlias closed 6 years ago

AnoopAlias commented 7 years ago

ModSecurity V3/master branch

I see that lua support is now available. on a centos7 I am getting

configure: LUA support was marked as mandatory by the utilization of --with-lua=yes
*** LOOKING AT PATH:  /usr/lib
*** LOOKING AT PATH:  /usr/local/lib
*** LOOKING AT PATH:  /usr/local/lua
*** LOOKING AT PATH:  /usr/local/liblua
*** LOOKING AT PATH:  /usr/local
*** LOOKING AT PATH:  /opt
*** LOOKING AT PATH:  /usr
*** LOOKING AT PATH:  /usr/lib64
configure: LUA library found at: /usr/lib64//liblua.so
*** LOOKING AT PATH:  /opt/local
configure: LUA library found at: /usr/lib64//liblua.so
configure: error: LUA was explicitly referenced but it was not found

I have the lua rpm's installed

[root@autobuild ModSecurity]# rpm -qa|grep lua
luajit-2.0.4-3.el7.x86_64
lua-5.1.4-15.el7.x86_64
lua-devel-5.1.4-15.el7.x86_64
[root@autobuild ModSecurity]# 
AnoopAlias commented 6 years ago

Just tested this with the latest v3/master source and looks like its finding lua correctly now but i get compile error Host : CentOS7 x86_64

/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.  -std=c++11 -I.. -g -I../others -fPIC -O3 -I../headers -DWITH_GEOIP -I/usr/include/      -DWITH_YAJL    -DPCRE_HAVE_JIT -DWITH_SSDEEP -I/usr/include -DWITH_LUA -I/usr/include -I/usr/include/libxml2 -DWITH_LIBXML2   -g -O2 -MT engine/libmodsecurity_la-lua.lo -MD -MP -MF engine/.deps/libmodsecurity_la-lua.Tpo -c -o engine/libmodsecurity_la-lua.lo `test -f 'engine/lua.cc' || echo './'`engine/lua.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -std=c++11 -I.. -g -I../others -fPIC -O3 -I../headers -DWITH_GEOIP -I/usr/include/ -DWITH_YAJL -DPCRE_HAVE_JIT -DWITH_SSDEEP -I/usr/include -DWITH_LUA -I/usr/include -I/usr/include/libxml2 -DWITH_LIBXML2 -g -O2 -MT engine/libmodsecurity_la-lua.lo -MD -MP -MF engine/.deps/libmodsecurity_la-lua.Tpo -c engine/lua.cc  -fPIC -DPIC -o engine/.libs/libmodsecurity_la-lua.o
engine/lua.cc: In member function 'bool modsecurity::engine::Lua::load(std::string, std::string*)':
engine/lua.cc:86:75: error: too many arguments to function 'int lua_dump(lua_State*, lua_Writer, void*)'
     if (lua_dump(L, Lua::blob_keeper, reinterpret_cast<void *>(&m_blob), 0)) {
                                                                           ^
In file included from /usr/include/lua.hpp:6:0,
                 from ../src/engine/lua.h:17,
                 from engine/lua.cc:17:
/usr/include/lua.h:207:14: note: declared here
 LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
              ^
engine/lua.cc: In member function 'int modsecurity::engine::Lua::run(modsecurity::Transaction*)':
engine/lua.cc:136:34: error: 'luaL_setfuncs' was not declared in this scope
     luaL_setfuncs(L, mscLuaLib, 0);
                                  ^
engine/lua.cc:140:13: error: too many arguments to function 'int lua_load(lua_State*, lua_Reader, void*, const char*)'
         NULL);
             ^
In file included from /usr/include/lua.hpp:6:0,
                 from ../src/engine/lua.h:17,
                 from engine/lua.cc:17:
/usr/include/lua.h:204:16: note: declared here
 LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,
                ^
engine/lua.cc:141:15: error: 'LUA_OK' was not declared in this scope
     if (rc != LUA_OK) {
               ^
engine/lua.cc:151:18: error: 'LUA_ERRGCMM' was not declared in this scope
             case LUA_ERRGCMM:
                  ^
engine/lua.cc: In static member function 'static std::string modsecurity::engine::Lua::applyTransformations(lua_State*, modsecurity::Transaction*, int, std::string)':
engine/lua.cc:364:37: error: 'lua_rawlen' was not declared in this scope
         int i, n = lua_rawlen(L, idx);
                                     ^
make[2]: *** [engine/libmodsecurity_la-lua.lo] Error 1
AnoopAlias commented 6 years ago

Probably this has to do with the Lua version as the standard one in centos7 is 5.1 Ref: https://github.com/jeremyong/Selene/issues/108 So modsec v3 needs Lua 5.2+?

luengnat commented 6 years ago

It seems to need Lua 5.3. I find this is bad as there are only most of RHEL 7.X repo still have Lua 5.1.4 as the latest. See #1622

AnoopAlias commented 6 years ago

Is there a way we can probably embed the lua in the libmodsecurity.so ,so we dont have to ship the lua along with the binary instead of lua being a shared library?

victorhora commented 6 years ago

LUA 5.3 is currently required. A simplified rationale is here: https://github.com/SpiderLabs/ModSecurity/issues/1622#issuecomment-346687983

There's experimental support on LUA 5.2 at #1623.

If you want to manually disable LUA support use ./configure --without-lua or ./configure --with-lua=no