1 /* 2 * ModSecurity, http://www.modsecurity.org/ 3 * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 * 5 * You may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * If any of the files related to licensing are missing or if you have any 11 * other questions related to licensing please contact Trustwave Holdings, Inc. 12 * directly using the email address security@modsecurity.org. 13 * 14 */ 15 16 #ifndef SRC_OPERATORS_VALIDATE_BYTE_RANGE_H_ 17 #define SRC_OPERATORS_VALIDATE_BYTE_RANGE_H_ 18 19 #include <string> 20 #include <vector> 21 #include <cstring> 22 #include <memory> 23 #include <utility> 24 25 #include "src/operators/operator.h" 26 27 28 namespace modsecurity { 29 namespace operators { 30 31 class ValidateByteRange : public Operator { 32 public: 33 /** @ingroup ModSecurity_Operator */ ValidateByteRange(std::unique_ptr<RunTimeString> param)34 explicit ValidateByteRange(std::unique_ptr<RunTimeString> param) 35 : Operator("ValidateByteRange", std::move(param)) { 36 std::memset(table, '\0', sizeof(char) * 32); 37 } ~ValidateByteRange()38 ~ValidateByteRange() override { } 39 40 bool evaluate(Transaction *transaction, RuleWithActions *rule, 41 const std::string &input, 42 std::shared_ptr<RuleMessage> ruleMessage) override; 43 bool getRange(const std::string &rangeRepresentation, std::string *error); 44 bool init(const std::string& file, std::string *error) override; 45 private: 46 std::vector<std::string> ranges; 47 char table[32]; 48 }; 49 50 } // namespace operators 51 } // namespace modsecurity 52 53 54 #endif // SRC_OPERATORS_VALIDATE_BYTE_RANGE_H_ 55