mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-10-01 03:57:47 +03:00
Adds XML variable, xml body request processor and @validateSchema
This commit is contained in:
68
src/request_body_processor/xml.h
Normal file
68
src/request_body_processor/xml.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* 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 security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <libxml/xmlschemas.h>
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
#ifndef SRC_REQUEST_BODY_PROCESSOR_XML_H_
|
||||
#define SRC_REQUEST_BODY_PROCESSOR_XML_H_
|
||||
|
||||
|
||||
namespace modsecurity {
|
||||
namespace RequestBodyProcessor {
|
||||
|
||||
|
||||
struct xml_data {
|
||||
xmlSAXHandler *sax_handler;
|
||||
xmlParserCtxtPtr parsing_ctx;
|
||||
xmlDocPtr doc;
|
||||
|
||||
unsigned int well_formed;
|
||||
};
|
||||
|
||||
typedef struct xml_data xml_data;
|
||||
|
||||
class XML {
|
||||
public:
|
||||
explicit XML(Transaction *transaction);
|
||||
~XML();
|
||||
bool init();
|
||||
bool processChunk(const char *buf, unsigned int size);
|
||||
bool complete();
|
||||
static xmlParserInputBufferPtr unloadExternalEntity(const char *URI,
|
||||
xmlCharEncoding enc) { return NULL; }
|
||||
|
||||
#ifndef NO_LOGS
|
||||
void debug(int a, std::string str) {
|
||||
m_transaction->debug(a, str);
|
||||
}
|
||||
#endif
|
||||
xml_data m_data;
|
||||
|
||||
private:
|
||||
Transaction *m_transaction;
|
||||
std::string m_header;
|
||||
};
|
||||
|
||||
} // namespace RequestBodyProcessor
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_REQUEST_BODY_PROCESSOR_XML_H_
|
Reference in New Issue
Block a user