]> git.ipfire.org Git - thirdparty/squid.git/commit - src/client_side_request.cc
Fix %>ru logging of huge URLs (#229) M-staged-PR229
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Tue, 17 Jul 2018 15:31:23 +0000 (15:31 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 17 Jul 2018 15:41:56 +0000 (15:41 +0000)
commitbec110e46f9dfba5ac076e337d9aedc9046d4c1e
tree78310ea032ab9482020da1503fe3b392127b28dd
parent69565793eef89d0137a69e2d923f14adc051b173
Fix %>ru logging of huge URLs (#229)

When dealing with an HTTP request header that Squid can parse but that
contains request URI length exceeding the 8K limit, Squid should log the
URL (prefix) instead of a dash. Logging the URL helps with triaging
these unusual requests. The older %ru (LFT_REQUEST_URI) was already
logging these huge URLs, but %>ru (LFT_CLIENT_REQ_URI) was logging a
dash. Now both log the URL (or its prefix).

As a side effect, %>ru now also logs error:request-too-large,
error:transaction-end-before-headers and other Squid-specific
pseudo-URLs, as appropriate.

Also refactored request- and URI-recording code to reduce chances of
similar inconsistencies reappearing in the future.

Also, honor strip_query_terms in %ru for large URLs. Not stripping query
string in %ru was a security problem.

Also fixed a bug with "redirected" flag calculation in
ClientHttpRequest::handleAdaptedHeader(). In general, http->url and
request->url should not be compared directly, because the latter always
passes through uri_whitespace cleanup, while the former does not.

Also fixed a bug with possibly wrong %ru after redirection:
ClientHttpRequest::log_uri was not updated in this case.

Also initialize AccessLogEntry::request and AccessLogEntry::notes ASAP.
Before this change, these fields were initialized in
ClientHttpRequest::doCallouts(). It is better to initialize them just
after the request object is created so that ACLs, running before
doCallouts(), could have them at hand. There are at least three such
ACLs: force_request_body_continuation, spoof_client_ip and
spoof_client_ip.

Also synced %ru and %>ru documentation with the current code.
22 files changed:
src/AccessLogEntry.cc
src/AccessLogEntry.h
src/Downloader.cc
src/HttpRequest.cc
src/HttpRequest.h
src/Makefile.am
src/anyp/Uri.cc
src/anyp/Uri.h
src/cf.data.pre
src/client_side.cc
src/client_side.h
src/client_side_reply.cc
src/client_side_request.cc
src/client_side_request.h
src/comm/TcpAcceptor.cc
src/format/Format.cc
src/htcp.cc
src/icp_v2.cc
src/servers/FtpServer.cc
src/servers/Http1Server.cc
src/tests/stub_client_side.cc
src/tests/stub_libanyp.cc