From 2c114d3aed7124c0454535b4f7121312652b4bdd Mon Sep 17 00:00:00 2001 From: WGH Date: Fri, 25 Jan 2019 15:44:41 +0300 Subject: [PATCH 1/3] Enable LMDB in Travis CI configuration LMBD is not built by default since 6143eb9, so add explicit --with-lmdb configuration. Missing --with-lmdb build allowed a bug in PR #2003 to pass through, causing issue #2008. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a99d848057..0f7e924b3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ env: - OPTS="--without-curl $OPTS" - OPTS="--without-yajl $OPTS" - OPTS="--without-geoip $OPTS" - - OPTS="--without-lmdb $OPTS" + - OPTS="--with-lmdb $OPTS" - OPTS="--without-ssdeep $OPTS" - OPTS="--without-lua $OPTS" - OPTS="--without-maxmind $OPTS" @@ -36,6 +36,7 @@ before_script: - '[ "$TRAVIS_OS_NAME" != osx ] || brew update' - '[ "$TRAVIS_OS_NAME" != osx ] || brew install cppcheck' - '[ "$TRAVIS_OS_NAME" != osx ] || brew install libmaxminddb' + - '[ "$TRAVIS_OS_NAME" != osx ] || brew install lmdb' - '[ "$TRAVIS_OS_NAME" != linux ] || sudo add-apt-repository --yes ppa:maxmind/ppa' - '[ "$TRAVIS_OS_NAME" != linux ] || sudo apt-get update' - '[ "$TRAVIS_OS_NAME" != linux ] || sudo apt-cache search maxmind' From 9c5df15200975dc1df87680838f740eba4f26a81 Mon Sep 17 00:00:00 2001 From: WGH Date: Fri, 25 Jan 2019 16:27:01 +0300 Subject: [PATCH 2/3] Fix use of deleted Regex copy constructor in LMDB code Bug introduced in ad28de4f. Fixes #2008. --- src/collection/backend/lmdb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collection/backend/lmdb.cc b/src/collection/backend/lmdb.cc index 9a814875e2..2b8724c786 100644 --- a/src/collection/backend/lmdb.cc +++ b/src/collection/backend/lmdb.cc @@ -538,7 +538,7 @@ void LMDB::resolveRegularExpression(const std::string& var, MDB_cursor *cursor; size_t pos; - Utils::Regex r = Utils::Regex(var); + Utils::Regex r(var); rc = mdb_txn_begin(m_env, NULL, 0, &txn); lmdb_debug(rc, "txn", "resolveRegularExpression"); From 199c0b222a2ffc66e321811a40a5be04bcc25bea Mon Sep 17 00:00:00 2001 From: WGH Date: Fri, 25 Jan 2019 21:08:34 +0300 Subject: [PATCH 3/3] Fix test issue-1831.json on LMDB When LMDB is enabled, ModSecurity stores its persistent variables in "./modsec-shared-collections" file. Since this file wasn't cleared between tests, tests behaved differently on "in-memory per-process" and LMDB backend. This test never worked in LMDB configuration. It hasn't been discovered until now because Travis CI didn't test LMDB configuration when test was introduced. --- test/regression/regression.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/regression/regression.cc b/test/regression/regression.cc index f84f414c04..46da615e4a 100644 --- a/test/regression/regression.cc +++ b/test/regression/regression.cc @@ -15,6 +15,8 @@ #include +#include + #include #include #include @@ -136,6 +138,12 @@ void perform_unit_test(ModSecurityTest *test, continue; } +#ifdef WITH_LMDB + // some tests (e.g. issue-1831.json) don't like it when data persists between runs + unlink("./modsec-shared-collections"); + unlink("./modsec-shared-collections-lock"); +#endif + modsec = new modsecurity::ModSecurity(); modsec->setConnectorInformation("ModSecurity-regression v0.0.1-alpha" \ " (ModSecurity regression test utility)");