diff --git a/src/operators/validate_byte_range.cc b/src/operators/validate_byte_range.cc index db350ae6..fc9dcd8c 100644 --- a/src/operators/validate_byte_range.cc +++ b/src/operators/validate_byte_range.cc @@ -32,7 +32,8 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation, try { start = std::stoi(rangeRepresentation); } catch(...) { - *error = ("Not able to convert '" + rangeRepresentation + "' into a number").c_str(); + *error = ("Not able to convert '" + rangeRepresentation + + "' into a number").c_str(); return false; } table[start >> 3] = (table[start >> 3] | (1 << (start & 0x7))); @@ -42,7 +43,9 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation, try { start = std::stoi(std::string(rangeRepresentation, 0, pos)); } catch (...) { - *error = ("Not able to convert '" + std::string(rangeRepresentation, 0, pos) + "' into a number").c_str(); + *error = ("Not able to convert '" + + std::string(rangeRepresentation, 0, pos) + + "' into a number").c_str(); return false; } @@ -50,13 +53,15 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation, end = std::stoi(std::string(rangeRepresentation, pos + 1, rangeRepresentation.length() - (pos + 1))); } catch (...) { - *error = ("Not able to convert '" + std::string(rangeRepresentation, pos + 1, - rangeRepresentation.length() - (pos + 1)) + "' into a number").c_str(); + *error = ("Not able to convert '" + std::string(rangeRepresentation, + pos + 1, rangeRepresentation.length() - (pos + 1)) + + "' into a number").c_str(); return false; } if ((start < 0) || (start > 255)) { - *error = ("Invalid range start value: " + std::to_string(start)).c_str(); + *error = ("Invalid range start value: " + + std::to_string(start)).c_str(); return false; } if ((end < 0) || (end > 255)) { @@ -69,7 +74,7 @@ bool ValidateByteRange::getRange(const std::string &rangeRepresentation, return false; } - while(start <= end) { + while (start <= end) { table[start >> 3] = (table[start >> 3] | (1 << (start & 0x7))); start++; } @@ -88,7 +93,8 @@ bool ValidateByteRange::init(const char **error) { while (pos != std::string::npos) { size_t next_pos = param.find_first_of(",", pos + 1); if (next_pos == std::string::npos) { - getRange(std::string(param, pos + 1, param.length() - (pos + 1)), error); + getRange(std::string(param, pos + 1, param.length() - + (pos + 1)), error); } else { getRange(std::string(param, pos + 1, next_pos), error); } @@ -97,24 +103,23 @@ bool ValidateByteRange::init(const char **error) { } - bool ValidateByteRange::evaluate(Assay *assay, const std::string &input) { bool ret = true; size_t count = 0; - for(int i = 0; i < input.length(); i++) { + for (int i = 0; i < input.length(); i++) { int x = input.at(i); if (!(table[x >> 3] & (1 << (x & 0x7)))) { - //debug(9, "Value " + std::to_string(x) + " in " + input + " ouside range: " + param); + // debug(9, "Value " + std::to_string(x) + " in " + + // input + " ouside range: " + param); count++; } } ret = (count != 0); - //if (count == 0) return 0; - //debug(9, "Found %d byte(s) in %s outside range: %s.", - //count, var->name, rule->op_param); + // debug(9, "Found %d byte(s) in %s outside range: %s.", + // count, var->name, rule->op_param); if (negation) { return !ret; diff --git a/src/operators/validate_byte_range.h b/src/operators/validate_byte_range.h index bbfbf38c..d2faa4db 100644 --- a/src/operators/validate_byte_range.h +++ b/src/operators/validate_byte_range.h @@ -17,6 +17,7 @@ #define SRC_OPERATORS_VALIDATE_BYTE_RANGE_H_ #include +#include #include "operators/operator.h" @@ -28,7 +29,7 @@ class ValidateByteRange : public Operator { public: /** @ingroup ModSecurity_Operator */ ValidateByteRange(std::string op, std::string param, bool negation) - : Operator(op, param, negation) { } + : Operator(op, param, negation) { } ~ValidateByteRange() override { }