From 462308be7409b69ba75b382a7bf05c8cbc2d9907 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Wed, 11 Feb 2015 11:02:53 -0800 Subject: [PATCH] Improves the accuracy of version identification on status calls Trying to differentiate among IIS, Apache, NGINX, and Standalone builds. --- apache2/msc_status_engine.c | 4 +- tests/regression/misc/20-status-engine.t | 50 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/apache2/msc_status_engine.c b/apache2/msc_status_engine.c index 27202b63..834ecc3e 100644 --- a/apache2/msc_status_engine.c +++ b/apache2/msc_status_engine.c @@ -349,8 +349,10 @@ int DSOLOCAL msc_beacon_string (char *beacon_string, int beacon_string_max_len) #endif libxml = LIBXML_DOTTED_VERSION; modsec = MODSEC_VERSION; -#ifdef IIS_VERSION +#ifdef VERSION_IIS apache = "IIS"; +#elif VERSION_NGINX + apache = "nginx"; #else apache = real_server_signature; #endif diff --git a/tests/regression/misc/20-status-engine.t b/tests/regression/misc/20-status-engine.t index 4ca1da94..a8ec6f3e 100644 --- a/tests/regression/misc/20-status-engine.t +++ b/tests/regression/misc/20-status-engine.t @@ -70,4 +70,54 @@ "arg1=val1&arg2=val2", ), }, +# On and SecServerSignature +{ + type => "misc", + comment => "SecStatusEngine On/SecServerSignature - checking signature", + conf => qq( + SecRuleEngine On + SecServerSignature "SpiderServer v0.1a" + SecStatusEngine On + ), + match_log => { + error => { + apache => [ qr/StatusEngine call: \"[0-9]+.[0-9]+.[0-9]+[-RC]*[0-9]*\,Apache/, 1], + nginx => [ qr/StatusEngine call: \"[0-9]+.[0-9]+.[0-9]+[-RC]*[0-9]*\,nginx/, 1], + } + }, + match_response => { + status => qr/^200$/, + }, + request => new HTTP::Request( + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", + [ + "Content-Type" => "application/x-www-form-urlencoded", + ], + "arg1=val1&arg2=val2", + ), +}, +# On and SecServerSignature +{ + type => "misc", + comment => "SecStatusEngine On - checking signature", + conf => qq( + SecStatusEngine On + ), + match_log => { + error => { + apache => [ qr/StatusEngine call: \"[0-9]+.[0-9]+.[0-9]+[-RC]*[0-9]*\,Apache/, 1], + nginx => [ qr/StatusEngine call: \"[0-9]+.[0-9]+.[0-9]+[-RC]*[0-9]*\,nginx/, 1], + } + }, + match_response => { + status => qr/^200$/, + }, + request => new HTTP::Request( + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", + [ + "Content-Type" => "application/x-www-form-urlencoded", + ], + "arg1=val1&arg2=val2", + ), +},