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_PM_H_ 17 #define SRC_OPERATORS_PM_H_ 18 19 #include <string> 20 #include <list> 21 #include <memory> 22 #include <utility> 23 24 #include "src/operators/operator.h" 25 #include "src/utils/acmp.h" 26 27 28 namespace modsecurity { 29 namespace operators { 30 31 32 class Pm : public Operator { 33 public: 34 /** @ingroup ModSecurity_Operator */ Pm(std::unique_ptr<RunTimeString> param)35 explicit Pm(std::unique_ptr<RunTimeString> param) 36 : Operator("Pm", std::move(param)) { 37 m_p = acmp_create(0); 38 } Pm(const std::string & n,std::unique_ptr<RunTimeString> param)39 explicit Pm(const std::string &n, std::unique_ptr<RunTimeString> param) 40 : Operator(n, std::move(param)) { 41 m_p = acmp_create(0); 42 } 43 ~Pm(); 44 bool evaluate(Transaction *transaction, RuleWithActions *rule, 45 const std::string &str, 46 std::shared_ptr<RuleMessage> ruleMessage) override; 47 48 49 bool init(const std::string &file, std::string *error) override; 50 void postOrderTraversal(acmp_btree_node_t *node); 51 void cleanup(acmp_node_t *n); 52 53 protected: 54 ACMP *m_p; 55 56 #ifdef MODSEC_MUTEX_ON_PM 57 58 private: 59 pthread_mutex_t m_lock; 60 #endif 61 }; 62 63 64 } // namespace operators 65 } // namespace modsecurity 66 67 68 #endif // SRC_OPERATORS_PM_H_ 69