-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: improved XMLArgs processing #3363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
9e41a53
Finish XMLArgs processing in v3
airween f62de58
Added new cc and h files
airween 8ae8374
Fix cppcheck errors
airween b42602f
Fix more cppcheck warning
airween 3e95614
Add nullptr check conditions
airween 029684c
Add nullptr check conditions
airween 22fee12
Change owner in legal text
airween e367876
Update comment
airween 3dc9fe9
Update comment
airween 90be54e
Update error message
airween f0aa070
Update comment
airween eedfed8
Update error message
airween 5b1c6fb
Update comment
airween fedc709
Update comment
airween 0fcd257
Update comment
airween bbe7eda
Update explanation
airween 159f612
Update comment
airween 2000f4c
Update comment
airween 0bf6020
Add explanation
airween 72de7e8
Update comment
airween 0c7ea21
Update comment
airween 6742930
Update comment
airween 8947346
Update comment
airween 2135c89
Update comment
airween 91a45e7
Update error message
airween 0b62b7e
Align debug messages to fix regression tests
airween bf707de
Change directive format to strict camel case
airween e8dc60e
Change node value's parsing to concatenate instead of copy it every time
airween 89442ed
Change directives in tests; add multibyte test case
airween d228ea6
Update comment
airween a3876e3
Avoid unvanted content parse (whitespaces between tags)
airween File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 OWASP. | ||
* directly using the email address [email protected]. | ||
* | ||
*/ | ||
|
||
#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); | ||
airween marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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; " \ | ||
theseion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 OWASP. | ||
* directly using the email address [email protected] | ||
* | ||
*/ | ||
|
||
#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_ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.