mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Added new cc and h files
This commit is contained in:
parent
9e41a53760
commit
f62de58632
63
src/actions/ctl/parse_xml_into_args.cc
Normal file
63
src/actions/ctl/parse_xml_into_args.cc
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2025 OWASP ModSecurity project
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address modsecurity@owasp.org.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/actions/ctl/parse_xml_into_args.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/rules_set_properties.h"
|
||||
#include "modsecurity/rules_set.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
bool ParseXmlIntoArgs::init(std::string *error) {
|
||||
std::string what(m_parser_payload, 17, m_parser_payload.size() - 17);
|
||||
|
||||
if (what == "on") {
|
||||
m_secXMLParseXmlIntoArgs = RulesSetProperties::TrueConfigXMLParseXmlIntoArgs;
|
||||
} else if (what == "off") {
|
||||
m_secXMLParseXmlIntoArgs = RulesSetProperties::FalseConfigXMLParseXmlIntoArgs;
|
||||
} else if (what == "onlyargs") {
|
||||
m_secXMLParseXmlIntoArgs = RulesSetProperties::OnlyArgsConfigXMLParseXmlIntoArgs;
|
||||
} else {
|
||||
error->assign("Internal error. Expected: On, Off or OnlyArgs; " \
|
||||
"got: " + m_parser_payload);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseXmlIntoArgs::evaluate(RuleWithActions *rule, Transaction *transaction) {
|
||||
std::stringstream a;
|
||||
a << "Setting SecParseXMLIntoArgs to ";
|
||||
a << modsecurity::RulesSetProperties::configXMLParseXmlIntoArgsString(m_secXMLParseXmlIntoArgs);
|
||||
a << " as requested by a ctl:parseXmlIntoArgs action";
|
||||
|
||||
ms_dbg_a(transaction, 8, a.str());
|
||||
|
||||
transaction->m_secXMLParseXmlIntoArgs = m_secXMLParseXmlIntoArgs;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
48
src/actions/ctl/parse_xml_into_args.h
Normal file
48
src/actions/ctl/parse_xml_into_args.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2025 OWASP ModSecurity Project
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address modsecurity@owasp.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/rules_set_properties.h"
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
|
||||
#ifndef SRC_ACTIONS_CTL_PARSE_XML_INTO_ARGS_H_
|
||||
#define SRC_ACTIONS_CTL_PARSE_XML_INTO_ARGS_H_
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
namespace ctl {
|
||||
|
||||
|
||||
class ParseXmlIntoArgs : public Action {
|
||||
public:
|
||||
explicit ParseXmlIntoArgs(const std::string &action)
|
||||
: Action(action),
|
||||
m_secXMLParseXmlIntoArgs(RulesSetProperties::PropertyNotSetConfigXMLParseXmlIntoArgs) { }
|
||||
|
||||
bool init(std::string *error) override;
|
||||
bool evaluate(RuleWithActions *rule, Transaction *transaction) override;
|
||||
|
||||
RulesSetProperties::ConfigXMLParseXmlIntoArgs m_secXMLParseXmlIntoArgs;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ctl
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_CTL_PARSE_XML_INTO_ARGS_H_
|
Loading…
x
Reference in New Issue
Block a user