mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Coding style fixes
This commit is contained in:
@@ -56,7 +56,8 @@ bool FuzzyHash::init(const std::string ¶m2, std::string *error) {
|
||||
}
|
||||
|
||||
for (std::string line; std::getline(*iss, line); ) {
|
||||
chunk = (struct fuzzy_hash_chunk *)calloc(1, sizeof(struct fuzzy_hash_chunk));
|
||||
chunk = (struct fuzzy_hash_chunk *)calloc(1,
|
||||
sizeof(struct fuzzy_hash_chunk));
|
||||
|
||||
chunk->data = strdup(line.c_str());
|
||||
chunk->next = NULL;
|
||||
@@ -77,7 +78,8 @@ bool FuzzyHash::init(const std::string ¶m2, std::string *error) {
|
||||
delete iss;
|
||||
return true;
|
||||
#else
|
||||
error->assign("@fuzzyHash: SSDEEP support was not enabled during the compilation.");
|
||||
error->assign("@fuzzyHash: SSDEEP support was not enabled " \
|
||||
"during the compilation.");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@@ -89,17 +91,15 @@ bool FuzzyHash::evaluate(Transaction *t, const std::string &str) {
|
||||
char result[FUZZY_MAX_RESULT];
|
||||
struct fuzzy_hash_chunk *chunk = m_head;
|
||||
|
||||
if (fuzzy_hash_buf((const unsigned char*)str.c_str(), str.size(), result))
|
||||
{
|
||||
if (fuzzy_hash_buf((const unsigned char*)str.c_str(),
|
||||
str.size(), result)) {
|
||||
t->debug(4, "Problems generating fuzzy hash");
|
||||
return false;
|
||||
}
|
||||
|
||||
while (chunk != NULL)
|
||||
{
|
||||
while (chunk != NULL) {
|
||||
int i = fuzzy_compare(chunk->data, result);
|
||||
if (i >= m_threshold)
|
||||
{
|
||||
if (i >= m_threshold) {
|
||||
t->debug(4, "Fuzzy hash: matched " \
|
||||
"with score: " + std::to_string(i) + ".");
|
||||
return true;
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#ifdef WITH_SSDEEP
|
||||
#include "fuzzy.h"
|
||||
#include <fuzzy.h>
|
||||
#endif
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
@@ -15,9 +15,10 @@
|
||||
|
||||
#include "src/operators/inspect_file.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
#include "src/utils/system.h"
|
||||
@@ -61,7 +62,7 @@ bool InspectFile::evaluate(Transaction *transaction, const std::string &str) {
|
||||
openstr.append(m_param);
|
||||
openstr.append(" ");
|
||||
openstr.append(str);
|
||||
if (!(in = popen(openstr.c_str(), "r"))){
|
||||
if (!(in = popen(openstr.c_str(), "r"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -57,6 +57,7 @@ class Pm : public Operator {
|
||||
ACMP *m_p;
|
||||
|
||||
#ifdef MODSEC_MUTEX_ON_PM
|
||||
|
||||
private:
|
||||
pthread_mutex_t m_lock;
|
||||
#endif
|
||||
|
@@ -16,23 +16,24 @@
|
||||
#include "src/operators/verify_cpf.h"
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
int VerifyCPF::convert_to_int(const char c)
|
||||
{
|
||||
int VerifyCPF::convert_to_int(const char c) {
|
||||
int n;
|
||||
if ((c>='0') && (c<='9'))
|
||||
if ((c >= '0') && (c <= '9')) {
|
||||
n = c - '0';
|
||||
else if ((c>='A') && (c<='F'))
|
||||
} else if ((c >= 'A') && (c <= 'F')) {
|
||||
n = c - 'A' + 10;
|
||||
else if ((c>='a') && (c<='f'))
|
||||
} else if ((c >= 'a') && (c <= 'f')) {
|
||||
n = c - 'a' + 10;
|
||||
else
|
||||
} else {
|
||||
n = 0;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -53,12 +54,9 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
|
||||
"88888888888",
|
||||
"99999999999"};
|
||||
|
||||
while ((*cpfnumber != '\0') && ( var_len > 0))
|
||||
{
|
||||
if (*cpfnumber != '-' || *cpfnumber != '.')
|
||||
{
|
||||
if (i < cpf_len && isdigit(*cpfnumber))
|
||||
{
|
||||
while ((*cpfnumber != '\0') && (var_len > 0)) {
|
||||
if (*cpfnumber != '-' || *cpfnumber != '.') {
|
||||
if (i < cpf_len && isdigit(*cpfnumber)) {
|
||||
s_cpf[i] = *cpfnumber;
|
||||
cpf[i] = convert_to_int(*cpfnumber);
|
||||
i++;
|
||||
@@ -69,16 +67,11 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
|
||||
}
|
||||
|
||||
|
||||
if (i != cpf_len)
|
||||
{
|
||||
if (i != cpf_len) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i< cpf_len; i++)
|
||||
{
|
||||
if (strncmp(s_cpf,bad_cpf[i],cpf_len) == 0)
|
||||
{
|
||||
} else {
|
||||
for (i = 0; i< cpf_len; i++) {
|
||||
if (strncmp(s_cpf, bad_cpf[i], cpf_len) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +88,7 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
|
||||
|
||||
factor = (sum % cpf_len);
|
||||
|
||||
if(factor < 2) {
|
||||
if (factor < 2) {
|
||||
cpf[9] = 0;
|
||||
} else {
|
||||
cpf[9] = cpf_len-factor;
|
||||
@@ -104,8 +97,9 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
|
||||
sum = 0;
|
||||
c = cpf_len;
|
||||
|
||||
for (i = 0;i < 10; i++)
|
||||
for (i = 0; i < 10; i++) {
|
||||
sum += (cpf[i] * c--);
|
||||
}
|
||||
|
||||
factor = (sum % cpf_len);
|
||||
|
||||
@@ -115,8 +109,7 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
|
||||
cpf[10] = cpf_len-factor;
|
||||
}
|
||||
|
||||
if (part_1 == cpf[9] && part_2 == cpf[10])
|
||||
{
|
||||
if (part_1 == cpf[9] && part_2 == cpf[10]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#define SRC_OPERATORS_VERIFY_CPF_H_
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
#include "src/utils/regex.h"
|
||||
|
@@ -16,23 +16,25 @@
|
||||
#include "src/operators/verify_ssn.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <list>
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace operators {
|
||||
|
||||
int VerifySSN::convert_to_int(const char c)
|
||||
{
|
||||
int VerifySSN::convert_to_int(const char c) {
|
||||
int n;
|
||||
if ((c>='0') && (c<='9'))
|
||||
if ((c >= '0') && (c <= '9')) {
|
||||
n = c - '0';
|
||||
else if ((c>='A') && (c<='F'))
|
||||
} else if ((c >= 'A') && (c <= 'F')) {
|
||||
n = c - 'A' + 10;
|
||||
else if ((c>='a') && (c<='f'))
|
||||
} else if ((c >= 'a') && (c <= 'f')) {
|
||||
n = c - 'a' + 10;
|
||||
else
|
||||
} else {
|
||||
n = 0;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#define SRC_OPERATORS_VERIFY_SSN_H_
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "src/operators/operator.h"
|
||||
#include "src/utils/regex.h"
|
||||
|
Reference in New Issue
Block a user