Adds support for libMaxMind

This commit is contained in:
Felipe Zimmerle
2018-03-21 19:48:52 -03:00
parent 7bff76d794
commit df169ea108
20 changed files with 845 additions and 115 deletions

View File

@@ -43,6 +43,7 @@ unit_tests_LDADD = \
$(top_builddir)/src/.libs/libmodsecurity.a \
$(CURL_LDADD) \
$(GEOIP_LDADD) \
$(MAXMIND_LDADD) \
$(GLOBAL_LDADD) \
$(LIBXML2_LDADD) \
$(LMDB_LDADD) \
@@ -54,6 +55,7 @@ unit_tests_LDADD = \
unit_tests_LDFLAG = \
$(GEOIP_LDFLAGS) \
$(MAXMIND_LDFLAGS) \
$(LMDB_LDFLAGS) \
$(LUA_LDFLAGS) \
$(SSDEEP_LDFLAGS) \
@@ -70,6 +72,7 @@ unit_tests_CPPFLAGS = \
$(CURL_CFLAGS) \
$(MODSEC_NO_LOGS) \
$(GEOIP_CFLAGS) \
$(MAXMIND_CFLAGS) \
$(GLOBAL_CPPFLAGS) \
$(LMDB_CFLAGS) \
$(PCRE_CFLAGS) \
@@ -91,6 +94,7 @@ regression_tests_LDADD = \
$(top_builddir)/src/.libs/libmodsecurity.a \
$(CURL_LDADD) \
$(GEOIP_LDADD) \
$(MAXMIND_LDADD) \
$(GLOBAL_LDADD) \
$(LIBXML2_LDADD) \
$(LMDB_LDADD) \
@@ -102,6 +106,7 @@ regression_tests_LDADD = \
regression_tests_LDFLAGS = \
$(GEOIP_LDFLAGS) \
$(MAXMIND_LDFLAGS) \
$(YAJL_LDFLAGS) \
$(LMDB_LDFLAGS) \
$(SSDEEP_LDFLAGS) \
@@ -118,6 +123,7 @@ regression_tests_CPPFLAGS = \
$(CURL_CFLAGS) \
$(MODSEC_NO_LOGS) \
$(GEOIP_CFLAGS) \
$(MAXMIND_CFLAGS) \
$(GLOBAL_CPPFLAGS) \
$(LMDB_CFLAGS) \
$(LUA_CFLAGS) \
@@ -138,6 +144,7 @@ rules_optimization_LDADD = \
$(top_builddir)/src/.libs/libmodsecurity.a \
$(CURL_LDADD) \
$(GEOIP_LDADD) \
$(MAXMIND_LDADD) \
$(GLOBAL_LDADD) \
$(LIBXML2_LDADD) \
$(LMDB_LDADD) \
@@ -148,6 +155,7 @@ rules_optimization_LDADD = \
rules_optimization_LDFLAGS = \
$(GEOIP_LDFLAGS) \
$(MAXMIND_LDFLAGS) \
$(LMDB_LDFLAGS) \
$(LUA_LDFLAGS) \
$(SSDEEP_LDFLAGS) \
@@ -163,6 +171,7 @@ rules_optimization_CPPFLAGS = \
$(CURL_CFLAGS) \
$(MODSEC_NO_LOGS) \
$(GEOIP_CFLAGS) \
$(MAXMIND_CFLAGS) \
$(GLOBAL_CPPFLAGS) \
$(LMDB_CFLAGS) \
$(LUA_CFLAGS) \

View File

@@ -9,6 +9,7 @@ benchmark_LDADD = \
$(top_builddir)/src/.libs/libmodsecurity.a \
$(CURL_LDADD) \
$(GEOIP_LDADD) \
$(MAXMIND_LDADD) \
$(PCRE_LDADD) \
$(YAJL_LDADD) \
$(LMDB_LDADD) \
@@ -20,6 +21,7 @@ benchmark_LDADD = \
benchmark_LDFLAGS = \
$(top_builddir)/src/.libs/libmodsecurity.a \
$(GEOIP_LDFLAGS) \
$(MAXMIND_LDFLAGS) \
$(YAJL_LDFLAGS) \
$(LMDB_LDFLAGS) \
$(SSDEEP_LDFLAGS) \

View File

@@ -20,6 +20,7 @@ afl_fuzzer_LDADD = \
$(PCRE_LDADD) \
$(YAJL_LDFLAGS) $(YAJL_LDADD) \
$(LMDB_LDFLAGS) $(LMDB_LDADD) \
$(MAXMIND_LDFLAGS) $(MAXMIND_LDADD) \
$(SSDEEP_LDFLAGS) $(SSDEEP_LDADD) \
$(LUA_LDFLAGS) $(LUA_LDADD) \
$(LIBXML2_LDADD) \
@@ -37,6 +38,7 @@ afl_fuzzer_CPPFLAGS = \
-g \
-I$(top_builddir)/headers \
$(GEOIP_CFLAGS) \
$(MAXMIND_CFLAGS) \
$(GLOBAL_CPPFLAGS) \
$(MODSEC_NO_LOGS) \
$(YAJL_CFLAGS) \

View File

@@ -426,9 +426,18 @@ int main(int argc, char **argv) {
int test_number = 0;
#endif
#ifdef WITH_GEOIP
#if defined(WITH_GEOIP) or defined(WITH_MAXMIND)
resources.push_back("geoip-or-maxmind");
#endif
#if defined(WITH_MAXMIND)
resources.push_back("maxmind");
#endif
#if defined(WITH_GEOIP)
resources.push_back("geoip");
#endif
#ifdef WITH_CURL
resources.push_back("curl");
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 MiB

View File

@@ -3,7 +3,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:LONGITUDE",
"title":"Testing Variables :: GEO:LONGITUDE [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -44,8 +44,8 @@
{
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:COUNTRY_NAME",
"resource":"maxmind",
"title":"Testing Variables :: GEO:COUNTRY_NAME [maxmind]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -78,7 +78,7 @@
},
"rules":[
"SecRuleEngine On",
"SecGeoLookupDb test-cases\/data\/geo\/GeoIPCity.dat",
"SecGeoLookupDb test-cases\/data\/geo\/GeoLite2-City.mmdb",
"SecRule REMOTE_ADDR \"@geoLookup\" \"id:1,pass,t:trim\"",
"SecRule GEO \"@contains test \" \"id:2,pass,t:trim\""
]
@@ -87,7 +87,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:LATITUDE",
"title":"Testing Variables :: GEO:LATITUDE [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -129,7 +129,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:COUNTRY_CODE3",
"title":"Testing Variables :: GEO:COUNTRY_CODE3 [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -171,7 +171,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:COUNTRY_CODE",
"title":"Testing Variables :: GEO:COUNTRY_CODE [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -213,7 +213,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:COUNTRY_CONTINENT",
"title":"Testing Variables :: GEO:COUNTRY_CONTINENT [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -255,7 +255,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:AREA_CODE",
"title":"Testing Variables :: GEO:AREA_CODE [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -297,7 +297,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:DMA_CODE",
"title":"Testing Variables :: GEO:DMA_CODE [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -339,7 +339,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:POSTAL_CODE",
"title":"Testing Variables :: GEO:POSTAL_CODE [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -381,7 +381,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:REGION",
"title":"Testing Variables :: GEO:REGION [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -423,7 +423,7 @@
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:CITY",
"title":"Testing Variables :: GEO:CITY [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
@@ -460,6 +460,301 @@
"SecRule REMOTE_ADDR \"@geoLookup\" \"id:1,pass,t:trim\"",
"SecRule GEO \"@contains test \" \"id:2,pass,t:trim\""
]
},
{
"enabled":1,
"version_min":300000,
"resource":"geoip",
"title":"Testing Variables :: GEO:LONGITUDE [GeoIP]",
"client":{
"ip":"64.17.254.216",
"port":123
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"response":{
"headers":{
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
"Content-Type":"text/html"
},
"body":[
"no need."
]
},
"expected":{
"debug_log":"Target value: \"-118.403999\" \\(Variable: GEO:LONGITUDE\\)"
},
"rules":[
"SecRuleEngine On",
"SecGeoLookupDb test-cases\/data\/geo\/GeoIPCity.dat",
"SecRule REMOTE_ADDR \"@geoLookup\" \"id:1,pass,t:trim\"",
"SecRule GEO \"@contains test \" \"id:2,pass,t:trim\""
]
},
{
"enabled":1,
"version_min":300000,
"resource":"maxmind",
"title":"Testing Variables :: GEO:COUNTRY_NAME [maxmind]",
"client":{
"ip":"64.17.254.216",
"port":123
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"response":{
"headers":{
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
"Content-Type":"text/html"
},
"body":[
"no need."
]
},
"expected":{
"debug_log":"Target value: \"United States\" \\(Variable: GEO:COUNTRY_NAME\\)"
},
"rules":[
"SecRuleEngine On",
"SecGeoLookupDb test-cases\/data\/geo\/GeoLite2-City.mmdb",
"SecRule REMOTE_ADDR \"@geoLookup\" \"id:1,pass,t:trim\"",
"SecRule GEO \"@contains test \" \"id:2,pass,t:trim\""
]
},
{
"enabled":1,
"version_min":300000,
"resource":"maxmind",
"title":"Testing Variables :: GEO:LATITUDE [maxmind]",
"client":{
"ip":"64.17.254.216",
"port":123
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"response":{
"headers":{
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
"Content-Type":"text/html"
},
"body":[
"no need."
]
},
"expected":{
"debug_log":"Target value: \"41.517100\" \\(Variable: GEO:LATITUDE\\)"
},
"rules":[
"SecRuleEngine On",
"SecGeoLookupDb test-cases\/data\/geo\/GeoLite2-City.mmdb",
"SecRule REMOTE_ADDR \"@geoLookup\" \"id:1,pass,t:trim\"",
"SecRule GEO \"@contains test \" \"id:2,pass,t:trim\""
]
},
{
"enabled":1,
"version_min":300000,
"resource":"maxmind",
"title":"Testing Variables :: GEO:COUNTRY_CODE [maxmind]",
"client":{
"ip":"64.17.254.216",
"port":123
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"response":{
"headers":{
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
"Content-Type":"text/html"
},
"body":[
"no need."
]
},
"expected":{
"debug_log":"Target value: \"US\" \\(Variable: GEO:COUNTRY_CODE\\)"
},
"rules":[
"SecRuleEngine On",
"SecGeoLookupDb test-cases\/data\/geo\/GeoLite2-City.mmdb",
"SecRule REMOTE_ADDR \"@geoLookup\" \"id:1,pass,t:trim\"",
"SecRule GEO \"@contains test \" \"id:2,pass,t:trim\""
]
},
{
"enabled":1,
"version_min":300000,
"resource":"maxmind",
"title":"Testing Variables :: GEO:COUNTRY_CONTINENT [maxmind]",
"client":{
"ip":"64.17.254.216",
"port":123
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"response":{
"headers":{
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
"Content-Type":"text/html"
},
"body":[
"no need."
]
},
"expected":{
"debug_log":"Target value: \"North America\" \\(Variable: GEO:COUNTRY_CONTINENT\\)"
},
"rules":[
"SecRuleEngine On",
"SecGeoLookupDb test-cases\/data\/geo\/GeoLite2-City.mmdb",
"SecRule REMOTE_ADDR \"@geoLookup\" \"id:1,pass,t:trim\"",
"SecRule GEO \"@contains test \" \"id:2,pass,t:trim\""
]
},
{
"enabled":1,
"version_min":300000,
"resource":"maxmind",
"title":"Testing Variables :: GEO:POSTAL_CODE [maxmind]",
"client":{
"ip":"64.17.254.216",
"port":123
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"response":{
"headers":{
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
"Content-Type":"text/html"
},
"body":[
"no need."
]
},
"expected":{
"debug_log":"Target value: \"02842\" \\(Variable: GEO:POSTAL_CODE\\)"
},
"rules":[
"SecRuleEngine On",
"SecGeoLookupDb test-cases\/data\/geo\/GeoLite2-City.mmdb",
"SecRule REMOTE_ADDR \"@geoLookup\" \"id:1,pass,t:trim\"",
"SecRule GEO \"@contains test \" \"id:2,pass,t:trim\""
]
},
{
"enabled":1,
"version_min":300000,
"resource":"maxmind",
"title":"Testing Variables :: GEO:CITY [maxmind]",
"client":{
"ip":"64.17.254.216",
"port":123
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"response":{
"headers":{
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
"Content-Type":"text/html"
},
"body":[
"no need."
]
},
"expected":{
"debug_log":"Target value: \"Middletown\" \\(Variable: GEO:CITY\\)"
},
"rules":[
"SecRuleEngine On",
"SecGeoLookupDb test-cases\/data\/geo\/GeoLite2-City.mmdb",
"SecRule REMOTE_ADDR \"@geoLookup\" \"id:1,pass,t:trim\"",
"SecRule GEO \"@contains test \" \"id:2,pass,t:trim\""
]
}
]

View File

@@ -122,9 +122,18 @@ int main(int argc, char **argv) {
ModSecurityTest<UnitTest> test;
ModSecurityTestResults<UnitTest> results;
#ifdef WITH_GEOIP
#if defined(WITH_GEOIP) or defined(WITH_MAXMIND)
resources.push_back("geoip-or-maxmind");
#endif
#if defined(WITH_MAXMIND)
resources.push_back("maxmind");
#endif
#if defined(WITH_GEOIP)
resources.push_back("geoip");
#endif
#ifdef WITH_CURL
resources.push_back("curl");
#endif