Skip to content

Commit

Permalink
Explicitly copy request body into Apache structures for any mode.
Browse files Browse the repository at this point in the history
Use the same helper that has been previously only called for
detection-only mode when prevention mode is enabled.

Signed-off-by: Vladimir Krivopalov <vlkrivop@microsoft.com>
  • Loading branch information
vkrivopalov committed Mar 13, 2019
1 parent e0795b9 commit 3fa2cac
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions iis/mymodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,17 +957,6 @@ CMyHttpModule::OnBeginRequest(IHttpContext* httpContext, IHttpEventProvider* pro

delete apppath;
delete path;

if (config->config->is_enabled == MODSEC_DETECTION_ONLY)
{
modsecSetReadBody(nullptr);
modsecSetWriteBody(nullptr);
}
else
{
modsecSetReadBody(ReadBodyCallback);
modsecSetWriteBody(WriteBodyCallback);
}
}

ConnRecPtr connRec = MakeConnReq();
Expand Down Expand Up @@ -1218,13 +1207,14 @@ CMyHttpModule::OnBeginRequest(IHttpContext* httpContext, IHttpEventProvider* pro
#endif
c->remote_host = NULL;

hr = SaveRequestBodyToRequestRec(context);
if (FAILED(hr)) {
context->provider->SetErrorStatus(hr);
return RQ_NOTIFICATION_FINISH_REQUEST;
}

if (config->config->is_enabled == MODSEC_DETECTION_ONLY)
{
hr = SaveRequestBodyToRequestRec(context);
if (FAILED(hr)) {
context->provider->SetErrorStatus(hr);
return RQ_NOTIFICATION_FINISH_REQUEST;
}
// We post the processing task to the thread pool to happen in the background.
// We store the future to track and wait for this processing in case if we also
// need to process the response because we need request processing to finish
Expand Down

0 comments on commit 3fa2cac

Please # to comment.