mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds a set of sanity checks to validate API inputs (1 of 2)
This commit is contained in:
parent
5a32b389b4
commit
49b7ea99e6
@ -235,7 +235,7 @@ int Transaction::processConnection(const char *client, int cPort,
|
||||
bool Transaction::extractArguments(const std::string &orig,
|
||||
const std::string& buf, size_t offset) {
|
||||
char sep1 = '&';
|
||||
std::vector<std::string> key_value_sets = utils::string::split(buf, sep1);
|
||||
std::vector<std::string> key_value_sets = utils::string::ssplit(buf, sep1);
|
||||
|
||||
for (std::string t : key_value_sets) {
|
||||
char sep2 = '=';
|
||||
@ -247,7 +247,7 @@ bool Transaction::extractArguments(const std::string &orig,
|
||||
|
||||
std::string key;
|
||||
std::string value;
|
||||
std::vector<std::string> key_value = utils::string::split(t, sep2);
|
||||
std::vector<std::string> key_value = utils::string::ssplit(t, sep2);
|
||||
for (auto& a : key_value) {
|
||||
if (i == 0) {
|
||||
key = a;
|
||||
@ -515,7 +515,7 @@ int Transaction::addRequestHeader(const std::string& key,
|
||||
|
||||
if (keyl == "cookie") {
|
||||
size_t localOffset = m_variableOffset;
|
||||
std::vector<std::string> cookies = utils::string::split(value, ';');
|
||||
std::vector<std::string> cookies = utils::string::ssplit(value, ';');
|
||||
for (const std::string &c : cookies) {
|
||||
std::vector<std::string> s = utils::string::split(c,
|
||||
'=');
|
||||
|
@ -170,7 +170,7 @@ std::string toupper(std::string str) {
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> split(std::string str, char delimiter) {
|
||||
std::vector<std::string> ssplit(std::string str, char delimiter) {
|
||||
std::vector<std::string> internal;
|
||||
std::stringstream ss(str); // Turn the string into a stream.
|
||||
std::string tok;
|
||||
@ -183,6 +183,17 @@ std::vector<std::string> split(std::string str, char delimiter) {
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> split(std::string str, char delimiter) {
|
||||
std::vector<std::string> internal = ssplit(str, delimiter);
|
||||
|
||||
if (internal.size() == 0) {
|
||||
internal.push_back(str);
|
||||
}
|
||||
|
||||
return internal;
|
||||
}
|
||||
|
||||
|
||||
void chomp(std::string *str) {
|
||||
std::string::size_type pos = str->find_last_not_of("\n\r");
|
||||
if (pos != std::string::npos) {
|
||||
|
@ -64,6 +64,7 @@ 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> ssplit(std::string str, char delimiter);
|
||||
std::vector<std::string> split(std::string str, char delimiter);
|
||||
void chomp(std::string *str);
|
||||
void replaceAll(std::string *str, const std::string& from,
|
||||
|
Loading…
x
Reference in New Issue
Block a user