13
13
*
14
14
*/
15
15
16
- #ifdef __cplusplus
17
- #include < stack>
18
- #include < vector>
19
- #include < string>
20
- #include < list>
21
- #include < cstring>
22
- #endif
23
-
24
16
#ifndef HEADERS_MODSECURITY_RULE_MESSAGE_H_
25
17
#define HEADERS_MODSECURITY_RULE_MESSAGE_H_
26
18
31
23
32
24
#ifdef __cplusplus
33
25
34
- namespace modsecurity {
26
+ #include < string>
27
+ #include < list>
35
28
29
+ namespace modsecurity {
36
30
37
31
38
32
class RuleMessage {
@@ -45,43 +39,51 @@ class RuleMessage {
45
39
RuleMessage (const RuleWithActions &rule, const Transaction &trans) :
46
40
m_rule (rule),
47
41
m_transaction (trans)
48
- { }
42
+ {
43
+ reset (true );
44
+ }
49
45
50
46
RuleMessage (const RuleMessage &ruleMessage) = default ;
51
47
RuleMessage &operator =(const RuleMessage &ruleMessage) = delete ;
52
48
53
- void clean () {
54
- m_data = " " ;
55
- m_match = " " ;
49
+ void reset ( const bool resetSaveMessage)
50
+ {
51
+ m_data. clear () ;
56
52
m_isDisruptive = false ;
57
- m_reference = " " ;
53
+ m_match.clear ();
54
+ m_message.clear ();
55
+ m_noAuditLog = false ;
56
+ m_reference.clear ();
57
+ if (resetSaveMessage == true )
58
+ m_saveMessage = true ;
58
59
m_severity = 0 ;
60
+ m_tags.clear ();
59
61
}
60
62
61
- std::string log () {
62
- return log (this , 0 );
63
+ std::string log () const {
64
+ return log (* this , 0 );
63
65
}
64
- std::string log (int props) {
65
- return log (this , props);
66
+ std::string log (int props) const {
67
+ return log (* this , props);
66
68
}
67
- std::string log (int props, int responseCode) {
68
- return log (this , props, responseCode);
69
+ std::string log (int props, int responseCode) const {
70
+ return log (* this , props, responseCode);
69
71
}
70
- std::string errorLog () {
71
- return log (this ,
72
- ClientLogMessageInfo | ErrorLogTailLogMessageInfo);
72
+ std::string errorLog () const {
73
+ return log (* this ,
74
+ ClientLogMessageInfo | ErrorLogTailLogMessageInfo);
73
75
}
74
76
75
- static std::string log (const RuleMessage * rm, int props, int code);
76
- static std::string log (const RuleMessage * rm, int props) {
77
+ static std::string log (const RuleMessage & rm, int props, int code);
78
+ static std::string log (const RuleMessage & rm, int props) {
77
79
return log (rm, props, -1 );
78
80
}
79
- static std::string log (const RuleMessage * rm) {
81
+ static std::string log (const RuleMessage & rm) {
80
82
return log (rm, 0 );
81
83
}
82
84
83
- static std::string _details (const RuleMessage * rm);
84
- static std::string _errorLogTail (const RuleMessage * rm);
85
+ static std::string _details (const RuleMessage & rm);
86
+ static std::string _errorLogTail (const RuleMessage & rm);
85
87
86
88
int getPhase () const { return m_rule.getPhase () - 1 ; }
87
89
0 commit comments