cosmetics: Fix compilation warnings to please QA

This commit is contained in:
Felipe Zimmerle 2020-12-14 09:30:10 -03:00
parent e0408ef0a1
commit ecdaeb0aa0
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
8 changed files with 36 additions and 23 deletions

View File

@ -42,11 +42,14 @@ void process_special_request (int j) {
msc_process_uri(transaction,
"http://www.modsecurity.org/test?foo=herewego",
"GET", "1.1");
msc_add_request_header(transaction, "User-Agent",
"Basic ModSecurity example");
msc_add_request_header(transaction,
(const unsigned char *) "User-Agent",
(const unsigned char *) "Basic ModSecurity example");
msc_process_request_headers(transaction);
msc_process_request_body(transaction);
msc_add_response_header(transaction, "Content-type", "text/html");
msc_add_response_header(transaction,
(const unsigned char *) "Content-type",
(const unsigned char *) "text/html");
msc_process_response_headers(transaction, 200, "HTTP 1.0");
msc_process_response_body(transaction);
msc_process_logging(transaction);
@ -70,11 +73,14 @@ void process_request (int j) {
msc_process_uri(transaction,
"http://www.modsecurity.org/test?key1=value1&key2=value2&key3=value3",
"GET", "1.1");
msc_add_request_header(transaction, "User-Agent",
"Basic ModSecurity example");
msc_add_request_header(transaction,
(const unsigned char *) "User-Agent",
(const unsigned char *) "Basic ModSecurity example");
msc_process_request_headers(transaction);
msc_process_request_body(transaction);
msc_add_response_header(transaction, "Content-type", "text/html");
msc_add_response_header(transaction,
(const unsigned char *) "Content-type",
(const unsigned char *) "text/html");
msc_process_response_headers(transaction, 200, "HTTP 1.0");
msc_process_response_body(transaction);
msc_process_logging(transaction);

View File

@ -29,8 +29,8 @@ int main(int argc, char **argv) {
return -1;
}
*(argv++);
std::string rules(*argv);
char *rule = *(argv++);
std::string rules(rule);
ReadingLogsViaRuleMessage rlvrm(request_header, request_uri, request_body,
response_headers, response_body, ip, rules);
rlvrm.process();

View File

@ -133,9 +133,8 @@ int main(int argc, char **argv) {
std::cout << std::endl << std::endl;
return -1;
}
*(argv++);
std::string rules_arg(*argv);
char *rule = *(argv++);
std::string rules_arg(rule);
/**
* ModSecurity initial setup

View File

@ -25,7 +25,7 @@
*/
#include "modsecurity/rules_set.h"
#ifdef MSC_DOCUMENTATION
/**
* Description: Assigns a tag (category) to a rule or a chain.
*
@ -46,7 +46,7 @@
*
*
*/
#endif
namespace modsecurity {
namespace actions {

View File

@ -34,11 +34,12 @@ void RemoveWhitespace::execute(const Transaction *t,
ModSecString &out) noexcept {
out = in;
int64_t i = 0;
char nonBreakingSpaces = 0xa0;
// loop through all the chars
while (i < out.size()) {
// remove whitespaces and non breaking spaces (NBSP)
if (isspace(out[i]) || (out[i] == NBSP)) {
if (isspace(out[i]) || (out[i] == nonBreakingSpaces)) {
out.erase(i, 1);
} else {
/* if the space is not a whitespace char, increment counter

View File

@ -29,14 +29,22 @@ namespace transformations {
void Trim::ltrim(ModSecString *s) {
s->erase(s->begin(), std::find_if(s->begin(), s->end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
s->erase(
s->begin(),
std::find_if(s->begin(), s->end(), [](unsigned char c) {
return !std::isspace(c);
})
);
}
void Trim::rtrim(ModSecString *s) {
s->erase(std::find_if(s->rbegin(), s->rend(),
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s->end());
s->erase(
std::find_if(s->rbegin(), s->rend(), [](unsigned char c) {
return !std::isspace(c);
}).base(),
s->end()
);
}

View File

@ -1325,14 +1325,13 @@ int Transaction::appendResponseBody(const unsigned char *buf, size_t len) {
* contents of the response body, otherwise there is no need to call this
* method.
*
* WARN: This is a skeleton that it is not in use yet.
*
* @return It returns a buffer (const char *)
* @retval >0 body was update and available.
* @retval NULL Nothing was updated.
*
*/
const char *Transaction::getResponseBody() const {
// int there_is_update = this->rules->loadResponseBodyFromJS(this);
return this->m_responseBody.str().c_str();
return strdup(this->m_responseBody.str().c_str());
}

View File

@ -290,7 +290,7 @@ TreeNode *CPTAddElement(unsigned char *ipdata, unsigned int ip_bitmask, CPTTree
unsigned char *buffer = NULL;
unsigned char bitlen = 0;
int bit_validation = 0, test_bit = 0;
int i = 0;
size_t i = 0;
unsigned int x, y;
TreeNode *node = NULL, *new_node = NULL;
TreeNode *parent = NULL, *i_node = NULL;