Skip to content

Finish the SecRequestBodyNoFilesLimit configuration parameter #2265

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions headers/modsecurity/rules_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ class RulesProperties {
PropertyNotSetConfigBoolean);

to->m_requestBodyLimit.merge(&from->m_requestBodyLimit);
to->m_requestBodyNoFilesLimit.merge(&from->m_requestBodyNoFilesLimit);
to->m_responseBodyLimit.merge(&from->m_responseBodyLimit);

merge_bodylimitaction_value(to->m_requestBodyLimitAction,
Expand Down
16 changes: 16 additions & 0 deletions src/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,9 @@ int Transaction::processRequestBody() {
m_variableInboundDataError.set("0", 0);
}

// set the default reqBody length
// if CT *IS NOT* multipart, no_files value will the whole request length
size_t reqbodyNoFilesLength = m_requestBody.str().size();
/*
* Process the request body even if there is nothing to be done.
*
Expand Down Expand Up @@ -852,6 +855,9 @@ int Transaction::processRequestBody() {
if (m.init(&error) == true) {
m.process(m_requestBody.str(), &error, m_variableOffset);
}
// if CT *IS* multipart, no_files value will the m.m_reqbody_no_files_length
// calculated in request_body_processor/multipart.cc
reqbodyNoFilesLength = m.m_reqbody_no_files_length;
m.multipart_complete(&error);
}
if (error.empty() == false) {
Expand Down Expand Up @@ -907,6 +913,16 @@ int Transaction::processRequestBody() {
}
}

// check the SecRequestBodyNoFilsLimit criteria
if (this->m_rules->m_requestBodyNoFilesLimit.m_value > 0
&& this->m_rules->m_requestBodyNoFilesLimit.m_value < reqbodyNoFilesLength) {
m_variableInboundDataError.set("1", m_variableOffset);
ms_dbg(5, "Request body no files is bigger than the maximum expected.");
m_variableReqbodyError.set("1", m_variableOffset);
m_variableReqbodyErrorMsg.set("Request body no files is bigger than the maximum expected.",
m_variableOffset);
}

/**
* FIXME: This variable should be calculated on demand, it is
* computationally intensive.
Expand Down
Loading