mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-18 10:20:35 +03:00
Changes debuglogs schema to avoid unecessary str allocation
This commit is contained in:
@@ -52,9 +52,7 @@ bool ValidateSchema::evaluate(Transaction *t,
|
||||
if (m_err.empty() == false) {
|
||||
err << m_err;
|
||||
}
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, err.str());
|
||||
#endif
|
||||
ms_dbg_a(t, 4, err.str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -77,9 +75,7 @@ bool ValidateSchema::evaluate(Transaction *t,
|
||||
if (m_err.empty() == false) {
|
||||
err << " " << m_err;
|
||||
}
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, err.str());
|
||||
#endif
|
||||
ms_dbg_a(t, 4, err.str());
|
||||
xmlSchemaFreeParserCtxt(m_parserCtx);
|
||||
return true;
|
||||
}
|
||||
@@ -90,9 +86,7 @@ bool ValidateSchema::evaluate(Transaction *t,
|
||||
if (m_err.empty() == false) {
|
||||
err << " " << m_err;
|
||||
}
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, err.str());
|
||||
#endif
|
||||
ms_dbg_a(t, 4, err.str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -102,46 +96,36 @@ bool ValidateSchema::evaluate(Transaction *t,
|
||||
(xmlSchemaValidityWarningFunc)warn_runtime, t);
|
||||
|
||||
if (t->m_xml->m_data.doc == NULL) {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, "XML document tree could not be found for " \
|
||||
ms_dbg_a(t, 4, "XML document tree could not be found for " \
|
||||
"schema validation.");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
if (t->m_xml->m_data.well_formed != 1) {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, "XML: Schema validation failed because " \
|
||||
ms_dbg_a(t, 4, "XML: Schema validation failed because " \
|
||||
"content is not well formed.");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Make sure there were no other generic processing errors */
|
||||
/*
|
||||
if (msr->msc_reqbody_error) {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, "XML: Schema validation could not proceed due to previous"
|
||||
ms_dbg_a(t, 4, "XML: Schema validation could not proceed due to previous"
|
||||
" processing errors.");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
rc = xmlSchemaValidateDoc(m_validCtx, t->m_xml->m_data.doc);
|
||||
if (rc != 0) {
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, "XML: Schema validation failed.");
|
||||
#endif
|
||||
ms_dbg_a(t, 4, "XML: Schema validation failed.");
|
||||
xmlSchemaFree(m_schema);
|
||||
xmlSchemaFreeParserCtxt(m_parserCtx);
|
||||
return true; /* No match. */
|
||||
}
|
||||
|
||||
#ifndef NO_LOGS
|
||||
t->debug(4, "XML: Successfully validated payload against " \
|
||||
ms_dbg_a(t, 4, "XML: Successfully validated payload against " \
|
||||
"Schema: " + m_resource);
|
||||
#endif
|
||||
xmlSchemaFree(m_schema);
|
||||
xmlSchemaFreeParserCtxt(m_parserCtx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user