Skip to content

Commit f62de58

Browse files
committed
Added new cc and h files
1 parent 9e41a53 commit f62de58

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* ModSecurity, http://www.modsecurity.org/
3+
* Copyright (c) 2025 OWASP ModSecurity project
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 modsecurity@owasp.org.
13+
*
14+
*/
15+
16+
#include "src/actions/ctl/parse_xml_into_args.h"
17+
18+
#include <iostream>
19+
#include <string>
20+
21+
#include "modsecurity/rules_set_properties.h"
22+
#include "modsecurity/rules_set.h"
23+
#include "modsecurity/transaction.h"
24+
25+
namespace modsecurity {
26+
namespace actions {
27+
namespace ctl {
28+
29+
30+
bool ParseXmlIntoArgs::init(std::string *error) {
31+
std::string what(m_parser_payload, 17, m_parser_payload.size() - 17);
32+
33+
if (what == "on") {
34+
m_secXMLParseXmlIntoArgs = RulesSetProperties::TrueConfigXMLParseXmlIntoArgs;
35+
} else if (what == "off") {
36+
m_secXMLParseXmlIntoArgs = RulesSetProperties::FalseConfigXMLParseXmlIntoArgs;
37+
} else if (what == "onlyargs") {
38+
m_secXMLParseXmlIntoArgs = RulesSetProperties::OnlyArgsConfigXMLParseXmlIntoArgs;
39+
} else {
40+
error->assign("Internal error. Expected: On, Off or OnlyArgs; " \
41+
"got: " + m_parser_payload);
42+
return false;
43+
}
44+
45+
return true;
46+
}
47+
48+
bool ParseXmlIntoArgs::evaluate(RuleWithActions *rule, Transaction *transaction) {
49+
std::stringstream a;
50+
a << "Setting SecParseXMLIntoArgs to ";
51+
a << modsecurity::RulesSetProperties::configXMLParseXmlIntoArgsString(m_secXMLParseXmlIntoArgs);
52+
a << " as requested by a ctl:parseXmlIntoArgs action";
53+
54+
ms_dbg_a(transaction, 8, a.str());
55+
56+
transaction->m_secXMLParseXmlIntoArgs = m_secXMLParseXmlIntoArgs;
57+
return true;
58+
}
59+
60+
61+
} // namespace ctl
62+
} // namespace actions
63+
} // namespace modsecurity

src/actions/ctl/parse_xml_into_args.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* ModSecurity, http://www.modsecurity.org/
3+
* Copyright (c) 2025 OWASP ModSecurity Project
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 modsecurity@owasp.org
13+
*
14+
*/
15+
16+
#include <string>
17+
18+
#include "modsecurity/rules_set_properties.h"
19+
#include "modsecurity/actions/action.h"
20+
#include "modsecurity/transaction.h"
21+
22+
23+
#ifndef SRC_ACTIONS_CTL_PARSE_XML_INTO_ARGS_H_
24+
#define SRC_ACTIONS_CTL_PARSE_XML_INTO_ARGS_H_
25+
26+
namespace modsecurity {
27+
namespace actions {
28+
namespace ctl {
29+
30+
31+
class ParseXmlIntoArgs : public Action {
32+
public:
33+
explicit ParseXmlIntoArgs(const std::string &action)
34+
: Action(action),
35+
m_secXMLParseXmlIntoArgs(RulesSetProperties::PropertyNotSetConfigXMLParseXmlIntoArgs) { }
36+
37+
bool init(std::string *error) override;
38+
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
39+
40+
RulesSetProperties::ConfigXMLParseXmlIntoArgs m_secXMLParseXmlIntoArgs;
41+
};
42+
43+
44+
} // namespace ctl
45+
} // namespace actions
46+
} // namespace modsecurity
47+
48+
#endif // SRC_ACTIONS_CTL_PARSE_XML_INTO_ARGS_H_

0 commit comments

Comments
 (0)