Skip to content

Commit 9e41a53

Browse files
committed
Finish XMLArgs processing in v3
1 parent 01a0615 commit 9e41a53

File tree

12 files changed

+8323
-7286
lines changed

12 files changed

+8323
-7286
lines changed

headers/modsecurity/rules_set_properties.h

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
to = (from == PropertyNotSetBodyLimitAction) ? default : from; \
5353
}
5454

55+
#define merge_xmlargparse_value(to, from, default) \
56+
if (to == PropertyNotSetConfigXMLParseXmlIntoArgs) { \
57+
to = (from == PropertyNotSetConfigXMLParseXmlIntoArgs) ? default : from; \
58+
}
59+
5560
#ifdef __cplusplus
5661

5762
namespace modsecurity {
@@ -177,6 +182,7 @@ class RulesSetProperties {
177182
m_secRequestBodyAccess(PropertyNotSetConfigBoolean),
178183
m_secResponseBodyAccess(PropertyNotSetConfigBoolean),
179184
m_secXMLExternalEntity(PropertyNotSetConfigBoolean),
185+
m_secXMLParseXmlIntoArgs(PropertyNotSetConfigXMLParseXmlIntoArgs),
180186
m_tmpSaveUploadedFiles(PropertyNotSetConfigBoolean),
181187
m_uploadKeepFiles(PropertyNotSetConfigBoolean),
182188
m_debugLog(new DebugLog()),
@@ -191,6 +197,7 @@ class RulesSetProperties {
191197
m_secRequestBodyAccess(PropertyNotSetConfigBoolean),
192198
m_secResponseBodyAccess(PropertyNotSetConfigBoolean),
193199
m_secXMLExternalEntity(PropertyNotSetConfigBoolean),
200+
m_secXMLParseXmlIntoArgs(PropertyNotSetConfigXMLParseXmlIntoArgs),
194201
m_tmpSaveUploadedFiles(PropertyNotSetConfigBoolean),
195202
m_uploadKeepFiles(PropertyNotSetConfigBoolean),
196203
m_debugLog(debugLog),
@@ -218,14 +225,28 @@ class RulesSetProperties {
218225

219226
/**
220227
*
221-
*
228+
* The ConfigBoolean enumerator consists in mapping the different
229+
* states of the configuration boolean values.
230+
* The default value is PropertyNotSetConfigBoolean.
222231
*/
223232
enum ConfigBoolean {
224233
TrueConfigBoolean,
225234
FalseConfigBoolean,
226235
PropertyNotSetConfigBoolean
227236
};
228237

238+
/**
239+
*
240+
* The ConfigXMLParseXmlIntoArgs enumerator consists in mapping the
241+
* different states of the configuration XMLParseXmlIntoArgs values.
242+
* The default value is PropertyNotSetConfigXMLParseXmlIntoArgs.
243+
*/
244+
enum ConfigXMLParseXmlIntoArgs {
245+
TrueConfigXMLParseXmlIntoArgs,
246+
FalseConfigXMLParseXmlIntoArgs,
247+
OnlyArgsConfigXMLParseXmlIntoArgs,
248+
PropertyNotSetConfigXMLParseXmlIntoArgs
249+
};
229250

230251
/**
231252
*
@@ -338,6 +359,19 @@ class RulesSetProperties {
338359
}
339360
}
340361

362+
static std::string configXMLParseXmlIntoArgsString(ConfigXMLParseXmlIntoArgs i) {
363+
switch (i) {
364+
case TrueConfigXMLParseXmlIntoArgs:
365+
return "True";
366+
case FalseConfigXMLParseXmlIntoArgs:
367+
return "False";
368+
case OnlyArgsConfigXMLParseXmlIntoArgs:
369+
return "OnlyArgs";
370+
case PropertyNotSetConfigXMLParseXmlIntoArgs:
371+
default:
372+
return "Not set";
373+
}
374+
}
341375

342376
static int mergeProperties(RulesSetProperties *from,
343377
RulesSetProperties *to, std::ostringstream *err) {
@@ -357,6 +391,10 @@ class RulesSetProperties {
357391
from->m_secXMLExternalEntity,
358392
PropertyNotSetConfigBoolean);
359393

394+
merge_xmlargparse_value(to->m_secXMLParseXmlIntoArgs,
395+
from->m_secXMLParseXmlIntoArgs,
396+
PropertyNotSetConfigXMLParseXmlIntoArgs);
397+
360398
merge_boolean_value(to->m_uploadKeepFiles,
361399
from->m_uploadKeepFiles,
362400
PropertyNotSetConfigBoolean);
@@ -464,6 +502,7 @@ class RulesSetProperties {
464502
ConfigBoolean m_secRequestBodyAccess;
465503
ConfigBoolean m_secResponseBodyAccess;
466504
ConfigBoolean m_secXMLExternalEntity;
505+
ConfigXMLParseXmlIntoArgs m_secXMLParseXmlIntoArgs;
467506
ConfigBoolean m_tmpSaveUploadedFiles;
468507
ConfigBoolean m_uploadKeepFiles;
469508
ConfigDouble m_argumentsLimit;

headers/modsecurity/transaction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ class Transaction : public TransactionAnchoredVariables, public TransactionSecMa
635635

636636
std::vector<std::shared_ptr<RequestBodyProcessor::MultipartPartTmpFile>> m_multipartPartTmpFiles;
637637

638+
int m_secXMLParseXmlIntoArgs;
639+
638640
private:
639641

640642
Transaction(ModSecurity *ms, RulesSet *rules, const char *id,

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ ACTIONS = \
119119
actions/chain.cc \
120120
actions/ctl/audit_log_parts.cc \
121121
actions/ctl/audit_engine.cc \
122+
actions/ctl/parse_xml_into_args.cc \
122123
actions/ctl/rule_engine.cc \
123124
actions/ctl/request_body_processor_json.cc \
124125
actions/ctl/request_body_processor_xml.cc \

0 commit comments

Comments
 (0)