Makes multipart debug messages goes over modsec debug log not stdout

This commit is contained in:
Felipe Zimmerle
2015-09-16 15:24:01 -03:00
parent a52a3a71ed
commit 5b18db779e
4 changed files with 10 additions and 9 deletions

View File

@@ -512,7 +512,7 @@ int Assay::processRequestBody() {
if (m_requestBodyType == MultiPartRequestBody) { if (m_requestBodyType == MultiPartRequestBody) {
std::string *a = resolve_variable_first("REQUEST_HEADERS:Content-Type"); std::string *a = resolve_variable_first("REQUEST_HEADERS:Content-Type");
if (a != NULL) { if (a != NULL) {
Multipart m(*a); Multipart m(*a, this);
if (m.init() == true) { if (m.init() == true) {
m.process(m_requestBody.str()); m.process(m_requestBody.str());

View File

@@ -24,7 +24,7 @@
namespace ModSecurity { namespace ModSecurity {
namespace RequestBodyProcessor { namespace RequestBodyProcessor {
Multipart::Multipart(std:: string header) Multipart::Multipart(std:: string header, Assay *assay)
: crlf(false), : crlf(false),
containsDataAfter(false), containsDataAfter(false),
containsDataBefore(false), containsDataBefore(false),
@@ -33,6 +33,7 @@ Multipart::Multipart(std:: string header)
invalidQuote(false), invalidQuote(false),
boundaryStartsWithWhiteSpace(false), boundaryStartsWithWhiteSpace(false),
boundaryIsQuoted(false), boundaryIsQuoted(false),
m_assay(assay),
m_header(header) { m_header(header) {
} }

View File

@@ -27,7 +27,7 @@ namespace RequestBodyProcessor {
class Multipart { class Multipart {
public: public:
explicit Multipart(std::string header); Multipart(std::string header, Assay *assay);
bool init(); bool init();
bool boundaryContainsOnlyValidCharacters(); bool boundaryContainsOnlyValidCharacters();
@@ -46,12 +46,13 @@ class Multipart {
bool missingSemicolon; bool missingSemicolon;
bool invalidQuote; bool invalidQuote;
private:
void debug(int a, std::string str) { void debug(int a, std::string str) {
std::cout << "Debug: " << str << std::endl; m_assay->debug(a, str);
} }
private:
std::string m_boundary; std::string m_boundary;
std::string m_header; std::string m_header;
Assay *m_assay;
}; };
} // namespace RequestBodyProcessor } // namespace RequestBodyProcessor

View File

@@ -32,15 +32,14 @@ class MultipartBlob {
bool processContentDispositionLine(const std::string &dispositionLine); bool processContentDispositionLine(const std::string &dispositionLine);
bool processContentTypeLine(const std::string &contentTypeLine); bool processContentTypeLine(const std::string &contentTypeLine);
void debug(int a, std::string str) {
std::cout << "Debug: " << str << std::endl;
}
bool invalidQuote; bool invalidQuote;
std::string name; std::string name;
std::string filename; std::string filename;
std::string contentType; std::string contentType;
std::string content; std::string content;
void debug(int a, std::string str) {
m_parent->debug(a, str);
}
private: private:
const std::string m_blob; const std::string m_blob;
Multipart *m_parent; Multipart *m_parent;