mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Moves static methods from class String to the namespace string
This commit is contained in:
parent
62a0cb468b
commit
2244e874e2
@ -24,14 +24,11 @@
|
||||
#include "modsecurity/modsecurity.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
bool Allow::init(std::string *error) {
|
||||
std::string a = String::tolower(m_parser_payload);
|
||||
std::string a = utils::string::tolower(m_parser_payload);
|
||||
|
||||
if (a == "phase") {
|
||||
m_allowType = PhaseAllowType;
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils/string.h"
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
@ -32,7 +30,7 @@ namespace ctl {
|
||||
|
||||
bool RuleRemoveTargetById::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 21, m_parser_payload.size() - 21);
|
||||
std::vector<std::string> param = String::split(what, ';');
|
||||
std::vector<std::string> param = utils::string::split(what, ';');
|
||||
|
||||
if (param.size() < 2) {
|
||||
error->assign(what + " is not a valid `ID;VARIABLE'");
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils/string.h"
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
@ -31,7 +30,7 @@ namespace ctl {
|
||||
|
||||
bool RuleRemoveTargetByTag::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 22, m_parser_payload.size() - 22);
|
||||
std::vector<std::string> param = String::split(what, ';');
|
||||
std::vector<std::string> param = utils::string::split(what, ';');
|
||||
|
||||
if (param.size() < 2) {
|
||||
error->assign(what + " is not a valid `TAG;VARIABLE'");
|
||||
|
@ -24,14 +24,11 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
bool Phase::init(std::string *error) {
|
||||
std::string a = String::tolower(m_parser_payload);
|
||||
std::string a = utils::string::tolower(m_parser_payload);
|
||||
m_phase = -1;
|
||||
|
||||
try {
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include "src/macro_expansion.h"
|
||||
#include "src/utils/string.h"
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
@ -52,7 +50,7 @@ bool SetVar::init(std::string *error) {
|
||||
pos = m_parser_payload.find(".");
|
||||
if (pos != std::string::npos) {
|
||||
m_collectionName = std::string(m_parser_payload, 0, pos);
|
||||
m_collectionName = String::toupper(m_collectionName);
|
||||
m_collectionName = utils::string::toupper(m_collectionName);
|
||||
} else {
|
||||
error->assign("Missing the collection and/or variable name");
|
||||
return false;
|
||||
|
@ -25,15 +25,12 @@
|
||||
#include "modsecurity/rule_message.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
bool Severity::init(std::string *error) {
|
||||
std::string a = String::tolower(m_parser_payload);
|
||||
std::string a = utils::string::tolower(m_parser_payload);
|
||||
if (a == "emergency") {
|
||||
m_severity = 0;
|
||||
return true;
|
||||
|
@ -90,20 +90,20 @@ int CssDecode::css_decode_inplace(unsigned char *input, int64_t input_len) {
|
||||
switch (j) {
|
||||
/* Number of hex characters */
|
||||
case 1:
|
||||
*d++ = modsecurity::utils::xsingle2c(&input[i]);
|
||||
*d++ = utils::string::xsingle2c(&input[i]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
/* Use the last two from the end. */
|
||||
*d++ = modsecurity::utils::x2c(&input[i + j - 2]);
|
||||
*d++ = utils::string::x2c(&input[i + j - 2]);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
/* Use the last two from the end, but request
|
||||
* a full width check.
|
||||
*/
|
||||
*d = modsecurity::utils::x2c(&input[i + j - 2]);
|
||||
*d = utils::string::x2c(&input[i + j - 2]);
|
||||
fullcheck = 1;
|
||||
break;
|
||||
|
||||
@ -112,7 +112,7 @@ int CssDecode::css_decode_inplace(unsigned char *input, int64_t input_len) {
|
||||
* a full width check if the number is greater
|
||||
* or equal to 0xFFFF.
|
||||
*/
|
||||
*d = modsecurity::utils::x2c(&input[i + j - 2]);
|
||||
*d = utils::string::x2c(&input[i + j - 2]);
|
||||
/* Do full check if first byte is 0 */
|
||||
if (input[i] == '0') {
|
||||
fullcheck = 1;
|
||||
@ -126,7 +126,7 @@ int CssDecode::css_decode_inplace(unsigned char *input, int64_t input_len) {
|
||||
* a full width check if the number is greater
|
||||
* or equal to 0xFFFF.
|
||||
*/
|
||||
*d = modsecurity::utils::x2c(&input[i + j - 2]);
|
||||
*d = utils::string::x2c(&input[i + j - 2]);
|
||||
|
||||
/* Do full check if first/second bytes are 0 */
|
||||
if ((input[i] == '0')
|
||||
|
@ -92,7 +92,7 @@ int EscapeSeqDecode::ansi_c_sequences_decode_inplace(unsigned char *input,
|
||||
if ((i + 3 < input_len) && (isxdigit(input[i + 2]))
|
||||
&& (isxdigit(input[i + 3]))) {
|
||||
/* Two digits. */
|
||||
c = modsecurity::utils::x2c(&input[i + 2]);
|
||||
c = utils::string::x2c(&input[i + 2]);
|
||||
i += 4;
|
||||
} else {
|
||||
/* Invalid encoding, do nothing. */
|
||||
|
@ -65,7 +65,7 @@ int HexDecode::inplace(unsigned char *data, int len) {
|
||||
}
|
||||
|
||||
for (i = 0; i <= len - 2; i += 2) {
|
||||
*d++ = modsecurity::utils::x2c(&data[i]);
|
||||
*d++ = utils::string::x2c(&data[i]);
|
||||
count++;
|
||||
}
|
||||
*d = '\0';
|
||||
|
@ -72,7 +72,7 @@ int JsDecode::inplace(unsigned char *input, u_int64_t input_len) {
|
||||
/* \uHHHH */
|
||||
|
||||
/* Use only the lower byte. */
|
||||
*d = modsecurity::utils::x2c(&input[i + 4]);
|
||||
*d = utils::string::x2c(&input[i + 4]);
|
||||
|
||||
/* Full width ASCII (ff01 - ff5e) needs 0x20 added */
|
||||
if ((*d > 0x00) && (*d < 0x5f)
|
||||
@ -87,7 +87,7 @@ int JsDecode::inplace(unsigned char *input, u_int64_t input_len) {
|
||||
} else if ((i + 3 < input_len) && (input[i + 1] == 'x')
|
||||
&& VALID_HEX(input[i + 2]) && VALID_HEX(input[i + 3])) {
|
||||
/* \xHH */
|
||||
*d++ = modsecurity::utils::x2c(&input[i + 2]);
|
||||
*d++ = utils::string::x2c(&input[i + 2]);
|
||||
count++;
|
||||
i += 4;
|
||||
} else if ((i + 1 < input_len) && ISODIGIT(input[i + 1])) {
|
||||
|
@ -96,7 +96,7 @@ int SqlHexDecode::inplace(unsigned char *data, int len) {
|
||||
}
|
||||
|
||||
while (VALID_HEX(data[0]) && VALID_HEX(data[1])) {
|
||||
*d++ = modsecurity::utils::x2c(data);
|
||||
*d++ = utils::string::x2c(data);
|
||||
data += 2;
|
||||
count += 2;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ int UrlDecodeUni::inplace(unsigned char *input, u_int64_t input_len,
|
||||
} else {
|
||||
/* We first make use of the lower byte here,
|
||||
* ignoring the higher byte. */
|
||||
*d = modsecurity::utils::x2c(&input[i + 4]);
|
||||
*d = utils::string::x2c(&input[i + 4]);
|
||||
|
||||
/* Full width ASCII (ff01 - ff5e)
|
||||
* needs 0x20 added */
|
||||
@ -153,7 +153,7 @@ int UrlDecodeUni::inplace(unsigned char *input, u_int64_t input_len,
|
||||
char c2 = input[i + 2];
|
||||
|
||||
if (VALID_HEX(c1) && VALID_HEX(c2)) {
|
||||
*d++ = modsecurity::utils::x2c(&input[i + 1]);
|
||||
*d++ = utils::string::x2c(&input[i + 1]);
|
||||
count++;
|
||||
i += 3;
|
||||
} else {
|
||||
|
@ -69,7 +69,7 @@ std::string UrlEncode::url_enc(const char *input,
|
||||
} else {
|
||||
*d++ = '%';
|
||||
count++;
|
||||
modsecurity::utils::c2x(c, (unsigned char *)d);
|
||||
utils::string::c2x(c, (unsigned char *)d);
|
||||
d += 2;
|
||||
count++;
|
||||
count++;
|
||||
|
@ -93,7 +93,7 @@ char *Utf8ToUnicode::inplace(unsigned char *input,
|
||||
count++;
|
||||
if (count <= len) {
|
||||
if (c == 0)
|
||||
*data = modsecurity::utils::x2c(&c);
|
||||
*data = utils::string::x2c(&c);
|
||||
else
|
||||
*data++ = c;
|
||||
}
|
||||
|
@ -28,9 +28,6 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace collection {
|
||||
namespace backend {
|
||||
@ -103,8 +100,8 @@ void InMemoryPerProcess::resolveMultiMatches(const std::string& var,
|
||||
if (x.first.at(keySize) != ':') {
|
||||
continue;
|
||||
}
|
||||
std::string fu = String::toupper(x.first);
|
||||
std::string fvar = String::toupper(var);
|
||||
std::string fu = utils::string::toupper(x.first);
|
||||
std::string fvar = utils::string::toupper(var);
|
||||
if (fu.compare(0, keySize, fvar) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -30,9 +30,6 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace collection {
|
||||
|
||||
@ -64,28 +61,28 @@ Collections::~Collections() {
|
||||
void Collections::storeOrUpdateFirst(const std::string& collectionName,
|
||||
const std::string& variableName,
|
||||
const std::string& targetValue) {
|
||||
if (String::tolower(collectionName) == "ip"
|
||||
if (utils::string::tolower(collectionName) == "ip"
|
||||
&& !m_ip_collection_key.empty()) {
|
||||
m_ip_collection->storeOrUpdateFirst(collectionName + ":"
|
||||
+ variableName, m_ip_collection_key, targetValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collectionName) == "global"
|
||||
if (utils::string::tolower(collectionName) == "global"
|
||||
&& !m_global_collection_key.empty()) {
|
||||
m_global_collection->storeOrUpdateFirst(collectionName + ":"
|
||||
+ variableName, m_global_collection_key, targetValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collectionName) == "resource"
|
||||
if (utils::string::tolower(collectionName) == "resource"
|
||||
&& !m_resource_collection_key.empty()) {
|
||||
m_resource_collection->storeOrUpdateFirst(collectionName + ":"
|
||||
+ variableName, m_resource_collection_key, targetValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collectionName) == "session"
|
||||
if (utils::string::tolower(collectionName) == "session"
|
||||
&& !m_session_collection_key.empty()) {
|
||||
m_session_collection->storeOrUpdateFirst(collectionName + ":"
|
||||
+ variableName, m_session_collection_key, targetValue);
|
||||
@ -137,7 +134,7 @@ std::string* Collections::resolveFirst(const std::string& var) {
|
||||
|
||||
for (auto &a : *this) {
|
||||
std::string *res = a.second->resolveFirst(
|
||||
String::toupper(a.first) + ":" + var);
|
||||
utils::string::toupper(a.first) + ":" + var);
|
||||
if (res != NULL) {
|
||||
return res;
|
||||
}
|
||||
@ -149,38 +146,39 @@ std::string* Collections::resolveFirst(const std::string& var) {
|
||||
|
||||
std::string* Collections::resolveFirst(const std::string& collectionName,
|
||||
const std::string& var) {
|
||||
if (String::tolower(collectionName) == "ip"
|
||||
if (utils::string::tolower(collectionName) == "ip"
|
||||
&& !m_ip_collection_key.empty()) {
|
||||
return m_ip_collection->resolveFirst(
|
||||
String::toupper(collectionName)
|
||||
utils::string::toupper(collectionName)
|
||||
+ ":" + var, m_ip_collection_key);
|
||||
}
|
||||
|
||||
if (String::tolower(collectionName) == "global"
|
||||
if (utils::string::tolower(collectionName) == "global"
|
||||
&& !m_global_collection_key.empty()) {
|
||||
return m_global_collection->resolveFirst(
|
||||
String::toupper(collectionName)
|
||||
utils::string::toupper(collectionName)
|
||||
+ ":" + var, m_global_collection_key);
|
||||
}
|
||||
|
||||
if (String::tolower(collectionName) == "resource"
|
||||
if (utils::string::tolower(collectionName) == "resource"
|
||||
&& !m_resource_collection_key.empty()) {
|
||||
return m_resource_collection->resolveFirst(
|
||||
String::toupper(collectionName)
|
||||
utils::string::toupper(collectionName)
|
||||
+ ":" + var, m_resource_collection_key);
|
||||
}
|
||||
|
||||
if (String::tolower(collectionName) == "session"
|
||||
if (utils::string::tolower(collectionName) == "session"
|
||||
&& !m_session_collection_key.empty()) {
|
||||
return m_session_collection->resolveFirst(
|
||||
String::toupper(collectionName)
|
||||
utils::string::toupper(collectionName)
|
||||
+ ":" + var, m_session_collection_key);
|
||||
}
|
||||
|
||||
for (auto &a : *this) {
|
||||
if (String::tolower(a.first) == String::tolower(collectionName)) {
|
||||
if (utils::string::tolower(a.first)
|
||||
== utils::string::tolower(collectionName)) {
|
||||
std::string *res = a.second->resolveFirst(
|
||||
String::toupper(a.first)
|
||||
utils::string::toupper(a.first)
|
||||
+ ":" + var);
|
||||
if (res != NULL) {
|
||||
return res;
|
||||
@ -200,7 +198,8 @@ std::string Collections::resolveFirstCopy(const std::string& var) {
|
||||
}
|
||||
|
||||
for (auto &a : *this) {
|
||||
std::string res = a.second->resolveFirstCopy(String::toupper(a.first) +
|
||||
std::string res = a.second->resolveFirstCopy(
|
||||
utils::string::toupper(a.first) +
|
||||
":" + var);
|
||||
if (res.empty() == false) {
|
||||
return res;
|
||||
@ -213,38 +212,39 @@ std::string Collections::resolveFirstCopy(const std::string& var) {
|
||||
|
||||
std::string Collections::resolveFirstCopy(const std::string& collectionName,
|
||||
const std::string& var) {
|
||||
if (String::tolower(collectionName) == "ip"
|
||||
if (utils::string::tolower(collectionName) == "ip"
|
||||
&& !m_ip_collection_key.empty()) {
|
||||
return m_ip_collection->resolveFirstCopy(
|
||||
String::toupper(collectionName)
|
||||
utils::string::toupper(collectionName)
|
||||
+ ":" + var, m_ip_collection_key);
|
||||
}
|
||||
|
||||
if (String::tolower(collectionName) == "global"
|
||||
if (utils::string::tolower(collectionName) == "global"
|
||||
&& !m_global_collection_key.empty()) {
|
||||
return m_global_collection->resolveFirstCopy(
|
||||
String::toupper(collectionName) + ":" + var,
|
||||
utils::string::toupper(collectionName) + ":" + var,
|
||||
m_global_collection_key);
|
||||
}
|
||||
|
||||
if (String::tolower(collectionName) == "resource"
|
||||
if (utils::string::tolower(collectionName) == "resource"
|
||||
&& !m_resource_collection_key.empty()) {
|
||||
return m_resource_collection->resolveFirstCopy(
|
||||
String::toupper(collectionName) + ":" + var,
|
||||
utils::string::toupper(collectionName) + ":" + var,
|
||||
m_resource_collection_key);
|
||||
}
|
||||
|
||||
if (String::tolower(collectionName) == "session"
|
||||
if (utils::string::tolower(collectionName) == "session"
|
||||
&& !m_session_collection_key.empty()) {
|
||||
return m_session_collection->resolveFirstCopy(
|
||||
String::toupper(collectionName) + ":" + var,
|
||||
utils::string::toupper(collectionName) + ":" + var,
|
||||
m_session_collection_key);
|
||||
}
|
||||
|
||||
for (auto &a : *this) {
|
||||
if (String::tolower(a.first) == String::tolower(collectionName)) {
|
||||
if (utils::string::tolower(a.first)
|
||||
== utils::string::tolower(collectionName)) {
|
||||
std::string res = a.second->resolveFirstCopy(
|
||||
String::toupper(a.first) + ":" + var);
|
||||
utils::string::toupper(a.first) + ":" + var);
|
||||
if (res.empty() == false) {
|
||||
return res;
|
||||
}
|
||||
@ -266,27 +266,27 @@ void Collections::resolveSingleMatch(const std::string& var,
|
||||
const std::string& collection,
|
||||
std::vector<const Variable *> *l) {
|
||||
|
||||
if (String::tolower(collection) == "ip"
|
||||
if (utils::string::tolower(collection) == "ip"
|
||||
&& !m_ip_collection_key.empty()) {
|
||||
m_ip_collection->resolveSingleMatch(var, m_ip_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collection) == "global"
|
||||
if (utils::string::tolower(collection) == "global"
|
||||
&& !m_global_collection_key.empty()) {
|
||||
m_global_collection->resolveSingleMatch(var,
|
||||
m_global_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collection) == "resource"
|
||||
if (utils::string::tolower(collection) == "resource"
|
||||
&& !m_resource_collection_key.empty()) {
|
||||
m_resource_collection->resolveSingleMatch(var,
|
||||
m_resource_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collection) == "session"
|
||||
if (utils::string::tolower(collection) == "session"
|
||||
&& !m_session_collection_key.empty()) {
|
||||
m_session_collection->resolveSingleMatch(var,
|
||||
m_session_collection_key, l);
|
||||
@ -308,27 +308,27 @@ void Collections::resolveMultiMatches(const std::string& var,
|
||||
void Collections::resolveMultiMatches(const std::string& var,
|
||||
const std::string& collection,
|
||||
std::vector<const Variable *> *l) {
|
||||
if (String::tolower(collection) == "ip"
|
||||
if (utils::string::tolower(collection) == "ip"
|
||||
&& !m_ip_collection_key.empty()) {
|
||||
m_ip_collection->resolveMultiMatches(var, m_ip_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collection) == "global"
|
||||
if (utils::string::tolower(collection) == "global"
|
||||
&& !m_global_collection_key.empty()) {
|
||||
m_global_collection->resolveMultiMatches(var,
|
||||
m_global_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collection) == "resource"
|
||||
if (utils::string::tolower(collection) == "resource"
|
||||
&& !m_resource_collection_key.empty()) {
|
||||
m_resource_collection->resolveMultiMatches(var,
|
||||
m_resource_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collection) == "session"
|
||||
if (utils::string::tolower(collection) == "session"
|
||||
&& !m_session_collection_key.empty()) {
|
||||
m_session_collection->resolveMultiMatches(var,
|
||||
m_session_collection_key, l);
|
||||
@ -349,34 +349,34 @@ void Collections::resolveRegularExpression(const std::string& var,
|
||||
void Collections::resolveRegularExpression(const std::string& var,
|
||||
const std::string& collection,
|
||||
std::vector<const Variable *> *l) {
|
||||
if (String::tolower(collection) == "ip"
|
||||
if (utils::string::tolower(collection) == "ip"
|
||||
&& !m_ip_collection_key.empty()) {
|
||||
m_ip_collection->resolveRegularExpression(
|
||||
String::toupper(collection)
|
||||
utils::string::toupper(collection)
|
||||
+ ":" + var, m_ip_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collection) == "global"
|
||||
if (utils::string::tolower(collection) == "global"
|
||||
&& !m_global_collection_key.empty()) {
|
||||
m_global_collection->resolveRegularExpression(
|
||||
String::toupper(collection)
|
||||
utils::string::toupper(collection)
|
||||
+ ":" + var, m_global_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collection) == "resource"
|
||||
if (utils::string::tolower(collection) == "resource"
|
||||
&& !m_resource_collection_key.empty()) {
|
||||
m_resource_collection->resolveRegularExpression(
|
||||
String::toupper(collection)
|
||||
utils::string::toupper(collection)
|
||||
+ ":" + var, m_resource_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
||||
if (String::tolower(collection) == "session"
|
||||
if (utils::string::tolower(collection) == "session"
|
||||
&& !m_session_collection_key.empty()) {
|
||||
m_session_collection->resolveRegularExpression(
|
||||
String::toupper(collection)
|
||||
utils::string::toupper(collection)
|
||||
+ ":" + var, m_session_collection_key, l);
|
||||
return;
|
||||
}
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
namespace modsecurity {
|
||||
|
||||
MacroExpansion::MacroExpansion() { }
|
||||
@ -75,7 +73,7 @@ std::string MacroExpansion::expand(const std::string& input,
|
||||
std::string var = std::string(variable, collection + 1,
|
||||
variable.length() - (collection + 1));
|
||||
|
||||
if (String::toupper(col) == "RULE") {
|
||||
if (utils::string::toupper(col) == "RULE") {
|
||||
if (rule == NULL) {
|
||||
transaction->debug(9, "macro expansion: cannot resolve " \
|
||||
"RULE variable without the Rule object");
|
||||
|
@ -122,7 +122,6 @@ using modsecurity::actions::Ver;
|
||||
using modsecurity::actions::transformations::None;
|
||||
using modsecurity::actions::transformations::Transformation;
|
||||
using modsecurity::operators::Operator;
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
|
||||
@ -578,7 +577,7 @@ expression:
|
||||
}
|
||||
| CONFIG_DIR_SEC_MARKER
|
||||
{
|
||||
driver.addSecMarker(String::removeBracketsIfNeeded($1));
|
||||
driver.addSecMarker(modsecurity::utils::string::removeBracketsIfNeeded($1));
|
||||
}
|
||||
| CONFIG_DIR_RULE_ENG CONFIG_VALUE_OFF
|
||||
{
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
using modsecurity::Parser::Driver;
|
||||
using modsecurity::Utils::HttpsClient;
|
||||
using modsecurity::utils::String;
|
||||
|
||||
typedef yy::seclang_parser p;
|
||||
|
||||
@ -436,7 +435,7 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
|
||||
std::string key;
|
||||
std::string url;
|
||||
|
||||
std::vector<std::string> conf = String::split(yytext, ' ');
|
||||
std::vector<std::string> conf = modsecurity::utils::string::split(yytext, ' ');
|
||||
key = conf[1];
|
||||
url = conf[2];
|
||||
c.setKey(key);
|
||||
|
@ -31,9 +31,6 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace RequestBodyProcessor {
|
||||
|
||||
@ -720,7 +717,7 @@ int Multipart::process_part_header(std::string *error) {
|
||||
}
|
||||
|
||||
new_value = std::string(data);
|
||||
String::chomp(&new_value);
|
||||
utils::string::chomp(&new_value);
|
||||
|
||||
/* update the header value in the table */
|
||||
header_value = m_mpp->m_headers.at(m_mpp->m_last_header_name);
|
||||
@ -770,7 +767,7 @@ int Multipart::process_part_header(std::string *error) {
|
||||
data++;
|
||||
}
|
||||
header_value = std::string(data);
|
||||
String::chomp(&header_value);
|
||||
utils::string::chomp(&header_value);
|
||||
|
||||
/* error if the name already exists */
|
||||
if (m_mpp->m_headers.count(header_name) > 0) {
|
||||
@ -1040,7 +1037,7 @@ int Multipart::multipart_complete(std::string *error) {
|
||||
|
||||
|
||||
int Multipart::count_boundary_params(const std::string& str_header_value) {
|
||||
std::string lower = String::tolower(str_header_value);
|
||||
std::string lower = utils::string::tolower(str_header_value);
|
||||
const char *header_value = lower.c_str();
|
||||
char *duplicate = NULL;
|
||||
char *s = NULL;
|
||||
|
10
src/rule.cc
10
src/rule.cc
@ -37,7 +37,6 @@
|
||||
|
||||
|
||||
using modsecurity::Variables::Variations::Exclusion;
|
||||
using modsecurity::utils::String;
|
||||
|
||||
namespace modsecurity {
|
||||
|
||||
@ -428,8 +427,8 @@ bool Rule::evaluate(Transaction *trasn) {
|
||||
}
|
||||
|
||||
#ifndef NO_LOGS
|
||||
trasn->debug(9, "Target value: \"" + String::limitTo(80,
|
||||
String::toHexIfNeeded(value)) \
|
||||
trasn->debug(9, "Target value: \"" + utils::string::limitTo(80,
|
||||
utils::string::toHexIfNeeded(value)) \
|
||||
+ "\" (Variable: " + v->m_key + ")");
|
||||
#endif
|
||||
|
||||
@ -453,9 +452,10 @@ bool Rule::evaluate(Transaction *trasn) {
|
||||
if (this->op->m_match_message.empty() == true) {
|
||||
ruleMessage->m_match = "Matched \"Operator `" +
|
||||
this->op->m_op + "' with parameter `" +
|
||||
String::limitTo(200, this->op->m_param) +
|
||||
utils::string::limitTo(200, this->op->m_param) +
|
||||
"' against variable `" + v->m_key + "' (Value: `" +
|
||||
String::limitTo(100, String::toHexIfNeeded(value)) +
|
||||
utils::string::limitTo(100,
|
||||
utils::string::toHexIfNeeded(value)) +
|
||||
"' ) \" at " + v->m_key;
|
||||
} else {
|
||||
ruleMessage->m_match = this->op->m_match_message;
|
||||
|
@ -48,7 +48,7 @@ std::string RuleMessage::errorLog(Transaction *trans) {
|
||||
msg.append(" [uri \"" + std::string(trans->m_uri) + "\"]");
|
||||
msg.append(" [unique_id \"" + trans->m_id + "\"]");
|
||||
|
||||
return modsecurity::utils::String::toHexIfNeeded(msg);
|
||||
return modsecurity::utils::string::toHexIfNeeded(msg);
|
||||
}
|
||||
|
||||
} // namespace modsecurity
|
||||
|
@ -20,16 +20,13 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
|
||||
|
||||
bool RulesExceptions::load(const std::string &a, std::string *error) {
|
||||
std::vector<std::string> toRemove = String::split(a, ' ');
|
||||
std::vector<std::string> toRemove = utils::string::split(a, ' ');
|
||||
for (std::string &a : toRemove) {
|
||||
std::string b = String::removeBracketsIfNeeded(a);
|
||||
std::string b = utils::string::removeBracketsIfNeeded(a);
|
||||
|
||||
size_t dash = b.find('-');
|
||||
if (dash != std::string::npos) {
|
||||
|
@ -55,7 +55,6 @@
|
||||
using modsecurity::actions::Action;
|
||||
using modsecurity::RequestBodyProcessor::Multipart;
|
||||
using modsecurity::RequestBodyProcessor::XML;
|
||||
using modsecurity::utils::String;
|
||||
|
||||
namespace modsecurity {
|
||||
|
||||
@ -251,7 +250,7 @@ int Transaction::processConnection(const char *client, int cPort,
|
||||
bool Transaction::extractArguments(const std::string &orig,
|
||||
const std::string& buf) {
|
||||
char sep1 = '&';
|
||||
std::vector<std::string> key_value_sets = String::split(buf, sep1);
|
||||
std::vector<std::string> key_value_sets = utils::string::split(buf, sep1);
|
||||
|
||||
for (std::string t : key_value_sets) {
|
||||
char sep2 = '=';
|
||||
@ -263,7 +262,7 @@ bool Transaction::extractArguments(const std::string &orig,
|
||||
|
||||
std::string key;
|
||||
std::string value;
|
||||
std::vector<std::string> key_value = String::split(t, sep2);
|
||||
std::vector<std::string> key_value = utils::string::split(t, sep2);
|
||||
for (auto& a : key_value) {
|
||||
if (i == 0) {
|
||||
key = a;
|
||||
@ -499,16 +498,17 @@ int Transaction::addRequestHeader(const std::string& key,
|
||||
|
||||
this->m_collections.store("REQUEST_HEADERS:" + key, value);
|
||||
|
||||
std::string keyl = String::tolower(key);
|
||||
std::string keyl = utils::string::tolower(key);
|
||||
if (keyl == "authorization") {
|
||||
std::vector<std::string> type = String::split(value, ' ');
|
||||
std::vector<std::string> type = utils::string::split(value, ' ');
|
||||
this->m_collections.store("AUTH_TYPE", type[0]);
|
||||
}
|
||||
|
||||
if (keyl == "cookie") {
|
||||
std::vector<std::string> cookies = String::split(value, ';');
|
||||
std::vector<std::string> cookies = utils::string::split(value, ';');
|
||||
while (cookies.empty() == false) {
|
||||
std::vector<std::string> s = String::split(cookies.back(), '=');
|
||||
std::vector<std::string> s = utils::string::split(cookies.back(),
|
||||
'=');
|
||||
if (s.size() > 1) {
|
||||
if (s[0].at(0) == ' ') {
|
||||
s[0].erase(0, 1);
|
||||
@ -530,7 +530,7 @@ int Transaction::addRequestHeader(const std::string& key,
|
||||
|
||||
if (keyl == "content-type") {
|
||||
std::string multipart("multipart/form-data");
|
||||
std::string l = String::tolower(value);
|
||||
std::string l = utils::string::tolower(value);
|
||||
if (l.compare(0, multipart.length(), multipart) == 0) {
|
||||
this->m_requestBodyType = MultiPartRequestBody;
|
||||
m_collections.store("REQBODY_PROCESSOR", "MULTIPART");
|
||||
@ -543,7 +543,7 @@ int Transaction::addRequestHeader(const std::string& key,
|
||||
}
|
||||
|
||||
if (keyl == "host") {
|
||||
std::vector<std::string> host = String::split(value, ':');
|
||||
std::vector<std::string> host = utils::string::split(value, ':');
|
||||
m_collections.store("SERVER_NAME", host[0]);
|
||||
}
|
||||
return 1;
|
||||
@ -948,7 +948,7 @@ int Transaction::addResponseHeader(const std::string& key,
|
||||
|
||||
this->m_collections.store("RESPONSE_HEADERS:" + key, value);
|
||||
|
||||
if (String::tolower(key) == "content-type") {
|
||||
if (utils::string::tolower(key) == "content-type") {
|
||||
this->m_responseContentType->assign(value);
|
||||
}
|
||||
return 1;
|
||||
@ -1307,15 +1307,15 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
|
||||
|
||||
strftime(tstr, 299, "[%d/%b/%Y:%H:%M:%S %z]", &timeinfo);
|
||||
|
||||
ss << String::dash_if_empty(
|
||||
ss << utils::string::dash_if_empty(
|
||||
this->m_collections.resolveFirst("REQUEST_HEADERS:Host")) << " ";
|
||||
ss << String::dash_if_empty(this->m_clientIpAddress) << " ";
|
||||
ss << utils::string::dash_if_empty(this->m_clientIpAddress) << " ";
|
||||
/** TODO: Check variable */
|
||||
ss << String::dash_if_empty(
|
||||
ss << utils::string::dash_if_empty(
|
||||
this->m_collections.resolveFirst("REMOTE_USER"));
|
||||
ss << " ";
|
||||
/** TODO: Check variable */
|
||||
ss << String::dash_if_empty(
|
||||
ss << utils::string::dash_if_empty(
|
||||
this->m_collections.resolveFirst("LOCAL_USER"));
|
||||
ss << " ";
|
||||
ss << tstr << " ";
|
||||
@ -1329,15 +1329,15 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
|
||||
ss << this->m_httpCodeReturned << " ";
|
||||
ss << this->m_responseBody.tellp();
|
||||
/** TODO: Check variable */
|
||||
ss << String::dash_if_empty(
|
||||
ss << utils::string::dash_if_empty(
|
||||
this->m_collections.resolveFirst("REFERER")) << " ";
|
||||
ss << "\"";
|
||||
ss << String::dash_if_empty(
|
||||
ss << utils::string::dash_if_empty(
|
||||
this->m_collections.resolveFirst("REQUEST_HEADERS:User-Agent"));
|
||||
ss << "\" ";
|
||||
ss << this->m_id << " ";
|
||||
/** TODO: Check variable */
|
||||
ss << String::dash_if_empty(
|
||||
ss << utils::string::dash_if_empty(
|
||||
this->m_collections.resolveFirst("REFERER")) << " ";
|
||||
|
||||
ss << filename << " ";
|
||||
@ -1435,7 +1435,7 @@ std::string Transaction::toJSON(int parts) {
|
||||
const unsigned char *buf;
|
||||
size_t len;
|
||||
yajl_gen g = NULL;
|
||||
std::string ts = String::ascTime(&m_timeStamp).c_str();
|
||||
std::string ts = utils::string::ascTime(&m_timeStamp).c_str();
|
||||
std::string uniqueId = UniqueId::uniqueId();
|
||||
|
||||
g = yajl_gen_alloc(NULL);
|
||||
|
@ -43,7 +43,7 @@ int urldecode_nonstrict_inplace(unsigned char *input,
|
||||
char c1 = input[i + 1];
|
||||
char c2 = input[i + 2];
|
||||
if (VALID_HEX(c1) && VALID_HEX(c2)) {
|
||||
uint64_t uni = x2c(&input[i + 1]);
|
||||
uint64_t uni = string::x2c(&input[i + 1]);
|
||||
|
||||
*d++ = (wchar_t)uni;
|
||||
count++;
|
||||
@ -99,8 +99,8 @@ std::string uri_decode(const std::string & sSrc) {
|
||||
while (pSrc < SRC_LAST_DEC) {
|
||||
if (*pSrc == '%') {
|
||||
char dec1, dec2;
|
||||
if (-1 != (dec1 = HEX2DEC[*(pSrc + 1)])
|
||||
&& -1 != (dec2 = HEX2DEC[*(pSrc + 2)])) {
|
||||
if (-1 != (dec1 = string::HEX2DEC[*(pSrc + 1)])
|
||||
&& -1 != (dec2 = string::HEX2DEC[*(pSrc + 2)])) {
|
||||
*pEnd++ = (dec1 << 4) + dec2;
|
||||
pSrc += 3;
|
||||
continue;
|
||||
|
@ -44,16 +44,17 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace utils {
|
||||
namespace string {
|
||||
|
||||
|
||||
std::string String::ascTime(time_t *t) {
|
||||
std::string ascTime(time_t *t) {
|
||||
std::string ts = std::ctime(t);
|
||||
ts.pop_back();
|
||||
return ts;
|
||||
}
|
||||
|
||||
|
||||
std::string String::dash_if_empty(const std::string *str) {
|
||||
std::string dash_if_empty(const std::string *str) {
|
||||
if (str == NULL || str->empty()) {
|
||||
return "-";
|
||||
}
|
||||
@ -62,7 +63,7 @@ std::string String::dash_if_empty(const std::string *str) {
|
||||
}
|
||||
|
||||
|
||||
std::string String::dash_if_empty(const char *str) {
|
||||
std::string dash_if_empty(const char *str) {
|
||||
if (str == NULL || strlen(str) == 0) {
|
||||
return "-";
|
||||
}
|
||||
@ -71,7 +72,7 @@ std::string String::dash_if_empty(const char *str) {
|
||||
}
|
||||
|
||||
|
||||
std::string String::limitTo(int amount, const std::string &str) {
|
||||
std::string limitTo(int amount, const std::string &str) {
|
||||
std::string ret;
|
||||
|
||||
if (str.length() > amount) {
|
||||
@ -85,7 +86,7 @@ std::string String::limitTo(int amount, const std::string &str) {
|
||||
}
|
||||
|
||||
|
||||
std::string String::removeBracketsIfNeeded(std::string a) {
|
||||
std::string removeBracketsIfNeeded(std::string a) {
|
||||
if ((a.at(0) == '"') && (a.at(a.length()-1) == '"')) {
|
||||
a.pop_back();
|
||||
a.erase(0, 1);
|
||||
@ -94,7 +95,7 @@ std::string String::removeBracketsIfNeeded(std::string a) {
|
||||
}
|
||||
|
||||
|
||||
std::string String::string_to_hex(const std::string& input) {
|
||||
std::string string_to_hex(const std::string& input) {
|
||||
static const char* const lut = "0123456789ABCDEF";
|
||||
size_t len = input.length();
|
||||
|
||||
@ -109,7 +110,7 @@ std::string String::string_to_hex(const std::string& input) {
|
||||
}
|
||||
|
||||
|
||||
std::string String::toHexIfNeeded(const std::string &str) {
|
||||
std::string toHexIfNeeded(const std::string &str) {
|
||||
std::stringstream res;
|
||||
|
||||
for (int i = 0; i < str.size(); i++) {
|
||||
@ -125,7 +126,7 @@ std::string String::toHexIfNeeded(const std::string &str) {
|
||||
}
|
||||
|
||||
|
||||
std::string String::tolower(std::string str) {
|
||||
std::string tolower(std::string str) {
|
||||
std::string value;
|
||||
value.resize(str.length());
|
||||
|
||||
@ -138,7 +139,7 @@ std::string String::tolower(std::string str) {
|
||||
}
|
||||
|
||||
|
||||
std::string String::toupper(std::string str) {
|
||||
std::string toupper(std::string str) {
|
||||
std::locale loc;
|
||||
std::string value;
|
||||
|
||||
@ -150,7 +151,7 @@ std::string String::toupper(std::string str) {
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> String::split(std::string str, char delimiter) {
|
||||
std::vector<std::string> split(std::string str, char delimiter) {
|
||||
std::vector<std::string> internal;
|
||||
std::stringstream ss(str); // Turn the string into a stream.
|
||||
std::string tok;
|
||||
@ -163,7 +164,7 @@ std::vector<std::string> String::split(std::string str, char delimiter) {
|
||||
}
|
||||
|
||||
|
||||
void String::chomp(std::string *str) {
|
||||
void chomp(std::string *str) {
|
||||
std::string::size_type pos = str->find_last_not_of("\n\r");
|
||||
if (pos != std::string::npos) {
|
||||
str->erase(pos+1, str->length()-pos-1);
|
||||
@ -205,5 +206,6 @@ unsigned char *c2x(unsigned what, unsigned char *where) {
|
||||
}
|
||||
|
||||
|
||||
} // namespace string
|
||||
} // namespace utils
|
||||
} // namespace modsecurity
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef SRC_UTILS_MSC_STRING_H_
|
||||
#define SRC_UTILS_MSC_STRING_H_
|
||||
#ifndef SRC_UTILS_STRING_H_
|
||||
#define SRC_UTILS_STRING_H_
|
||||
|
||||
#define VALID_HEX(X) (((X >= '0') && (X <= '9')) || \
|
||||
((X >= 'a') && (X <= 'f')) || ((X >= 'A') && (X <= 'F')))
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
namespace modsecurity {
|
||||
namespace utils {
|
||||
namespace string {
|
||||
|
||||
const char HEX2DEC[256] = {
|
||||
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
|
||||
@ -54,26 +55,24 @@ const char HEX2DEC[256] = {
|
||||
};
|
||||
|
||||
|
||||
class String {
|
||||
public:
|
||||
static std::string ascTime(time_t *t);
|
||||
static std::string dash_if_empty(const char *str);
|
||||
static std::string dash_if_empty(const std::string *str);
|
||||
static std::string limitTo(int amount, const std::string &str);
|
||||
static std::string removeBracketsIfNeeded(std::string a);
|
||||
static std::string string_to_hex(const std::string& input);
|
||||
static std::string toHexIfNeeded(const std::string &str);
|
||||
static std::string tolower(std::string str);
|
||||
static std::string toupper(std::string str);
|
||||
static std::vector<std::string> split(std::string str, char delimiter);
|
||||
static void chomp(std::string *str);
|
||||
};
|
||||
std::string ascTime(time_t *t);
|
||||
std::string dash_if_empty(const char *str);
|
||||
std::string dash_if_empty(const std::string *str);
|
||||
std::string limitTo(int amount, const std::string &str);
|
||||
std::string removeBracketsIfNeeded(std::string a);
|
||||
std::string string_to_hex(const std::string& input);
|
||||
std::string toHexIfNeeded(const std::string &str);
|
||||
std::string tolower(std::string str);
|
||||
std::string toupper(std::string str);
|
||||
std::vector<std::string> split(std::string str, char delimiter);
|
||||
void chomp(std::string *str);
|
||||
|
||||
unsigned char x2c(unsigned char *what);
|
||||
unsigned char xsingle2c(unsigned char *what);
|
||||
unsigned char *c2x(unsigned what, unsigned char *where);
|
||||
|
||||
} // namespace string
|
||||
} // namespace utils
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_UTILS_MSC_STRING_H_
|
||||
#endif // SRC_UTILS_STRING_H_
|
||||
|
@ -47,9 +47,6 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace Variables {
|
||||
|
||||
@ -57,7 +54,7 @@ void Rule::evaluateInternal(Transaction *t,
|
||||
modsecurity::Rule *rule,
|
||||
std::vector<const collection::Variable *> *l) {
|
||||
std::map<std::string, std::string> envs;
|
||||
std::string m_name_upper = String::toupper(m_name);
|
||||
std::string m_name_upper = utils::string::toupper(m_name);
|
||||
|
||||
// id
|
||||
envs.insert(std::pair<std::string, std::string>("RULE:id",
|
||||
@ -99,7 +96,7 @@ void Rule::evaluateInternal(Transaction *t,
|
||||
}
|
||||
|
||||
for (auto& x : envs) {
|
||||
std::string xup = String::toupper(x.first);
|
||||
std::string xup = utils::string::toupper(x.first);
|
||||
if ((xup.substr(0, m_name_upper.size() + 1)
|
||||
.compare(m_name_upper + ":") != 0)
|
||||
&& (xup != m_name_upper)) {
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
using modsecurity::Variables::Variations::Exclusion;
|
||||
|
||||
|
||||
@ -39,7 +38,7 @@ Variable::Variable(std::string name)
|
||||
m_isExclusion(false),
|
||||
m_isCount(false) {
|
||||
if (m_name.find(":") != std::string::npos) {
|
||||
std::string col = String::toupper(
|
||||
std::string col = utils::string::toupper(
|
||||
std::string(m_name, 0, m_name.find(":")));
|
||||
std::string name = std::string(m_name, m_name.find(":") + 1,
|
||||
m_name.size());
|
||||
@ -56,19 +55,19 @@ Variable::Variable(std::string name)
|
||||
m_type = MultipleMatches;
|
||||
}
|
||||
|
||||
if (String::tolower(m_name) == "tx") {
|
||||
if (utils::string::tolower(m_name) == "tx") {
|
||||
m_collectionName = "TX";
|
||||
m_type = MultipleMatches;
|
||||
} else if (String::tolower(m_name) == "ip") {
|
||||
} else if (utils::string::tolower(m_name) == "ip") {
|
||||
m_collectionName = "IP";
|
||||
m_type = MultipleMatches;
|
||||
} else if (String::tolower(m_name) == "global") {
|
||||
} else if (utils::string::tolower(m_name) == "global") {
|
||||
m_collectionName = "GLOBAL";
|
||||
m_type = MultipleMatches;
|
||||
} else if (String::tolower(m_name) == "resource") {
|
||||
} else if (utils::string::tolower(m_name) == "resource") {
|
||||
m_collectionName = "RESOURCE";
|
||||
m_type = MultipleMatches;
|
||||
} else if (String::tolower(m_name) == "session") {
|
||||
} else if (utils::string::tolower(m_name) == "session") {
|
||||
m_collectionName = "SESSION";
|
||||
m_type = MultipleMatches;
|
||||
} else if (m_name.find(".") != std::string::npos) {
|
||||
@ -87,7 +86,7 @@ Variable::Variable(std::string name, VariableKind kind)
|
||||
m_isExclusion(false),
|
||||
m_isCount(false) {
|
||||
if (m_name.find(":") != std::string::npos) {
|
||||
std::string col = String::toupper(
|
||||
std::string col = utils::string::toupper(
|
||||
std::string(m_name, 0, m_name.find(":")));
|
||||
std::string name = std::string(m_name, m_name.find(":") + 1,
|
||||
m_name.size());
|
||||
@ -104,19 +103,19 @@ Variable::Variable(std::string name, VariableKind kind)
|
||||
m_type = MultipleMatches;
|
||||
}
|
||||
|
||||
if (String::tolower(m_name) == "tx") {
|
||||
if (utils::string::tolower(m_name) == "tx") {
|
||||
m_collectionName = "TX";
|
||||
m_type = MultipleMatches;
|
||||
} else if (String::tolower(m_name) == "ip") {
|
||||
} else if (utils::string::tolower(m_name) == "ip") {
|
||||
m_collectionName = "IP";
|
||||
m_type = MultipleMatches;
|
||||
} else if (String::tolower(m_name) == "global") {
|
||||
} else if (utils::string::tolower(m_name) == "global") {
|
||||
m_collectionName = "GLOBAL";
|
||||
m_type = MultipleMatches;
|
||||
} else if (String::tolower(m_name) == "resource") {
|
||||
} else if (utils::string::tolower(m_name) == "resource") {
|
||||
m_collectionName = "RESOURCE";
|
||||
m_type = MultipleMatches;
|
||||
} else if (String::tolower(m_name) == "session") {
|
||||
} else if (utils::string::tolower(m_name) == "session") {
|
||||
m_collectionName = "SESSION";
|
||||
m_type = MultipleMatches;
|
||||
} else if (m_name.find(".") != std::string::npos) {
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
using modsecurity_test::UnitTest;
|
||||
using modsecurity_test::ModSecurityTest;
|
||||
using modsecurity_test::ModSecurityTestResults;
|
||||
@ -91,7 +90,8 @@ void perform_unit_test(ModSecurityTest<UnitTest> *test, UnitTest *t,
|
||||
|
||||
if (test->m_automake_output) {
|
||||
std::cout << t->name << " "
|
||||
<< String::toHexIfNeeded(t->input) << std::endl;
|
||||
<< modsecurity::utils::string::toHexIfNeeded(t->input)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,6 @@
|
||||
#include "src/utils/string.h"
|
||||
|
||||
|
||||
using modsecurity::utils::String;
|
||||
|
||||
|
||||
namespace modsecurity_test {
|
||||
|
||||
|
||||
@ -112,9 +109,11 @@ std::string UnitTest::print() {
|
||||
i << this->obtained << "\"" << std::endl;
|
||||
}
|
||||
if (this->output != this->obtainedOutput) {
|
||||
i << "Expecting: \"" << String::toHexIfNeeded(this->output);
|
||||
i << "Expecting: \"";
|
||||
i << modsecurity::utils::string::toHexIfNeeded(this->output);
|
||||
i << "\" - returned: \"";
|
||||
i << String::toHexIfNeeded(this->obtainedOutput) << "\"";
|
||||
i << modsecurity::utils::string::toHexIfNeeded(this->obtainedOutput);
|
||||
i << "\"";
|
||||
i << std::endl;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user