mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-18 18:30:35 +03:00
Moves static methods from class String to the namespace string
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user