Bug 54377 - RemoteIpFilter does not correctly set request attributes for AccessLog
RemoteIpFilter does not correctly set request attributes for AccessLog
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
7.0.32
All All
: P2 minor (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2013-01-05 23:52 UTC by Greg Arakelian
Modified: 2013-01-08 20:30 UTC (History)
0 users



Attachments
patch proposal (1.12 KB, patch)
2013-01-06 20:19 UTC, Violeta Georgieva
Details | Diff
test case (4.72 KB, patch)
2013-01-06 20:19 UTC, Violeta Georgieva
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Arakelian 2013-01-05 23:52:37 UTC
In RemoteIpFilter class, there is code that publishes the new request attributes to AccessLog (see below).

821             if (requestAttributesEnabled) {
822                 request.setAttribute(AccessLog.REMOTE_ADDR_ATTRIBUTE,
823                         request.getRemoteAddr());
824                 request.setAttribute(AccessLog.REMOTE_HOST_ATTRIBUTE,
825                         request.getRemoteHost());
826                 request.setAttribute(AccessLog.PROTOCOL_ATTRIBUTE,
827                         request.getProtocol());
828                 request.setAttribute(AccessLog.SERVER_PORT_ATTRIBUTE,
829                         Integer.valueOf(request.getServerPort()));
830             }

The problem is that the source values should come from xRequest, e.g. xRequest.getRemoteAddr() and xRequest.getRemoteHost(), etc.

As it is written above, RemoteIpFilter simply republishes the current values, and AccessLog therefore does not display the correct values.
Comment 1 Violeta Georgieva 2013-01-06 20:19:29 UTC
Created attachment 29820 [details]
patch proposal
Comment 2 Violeta Georgieva 2013-01-06 20:19:53 UTC
Created attachment 29821 [details]
test case
Comment 3 Violeta Georgieva 2013-01-06 20:21:11 UTC
+1

Please find a patch proposal and a test case.
RemoteIpValve sets the correct request attributes, only RequestIpFilter need correction.

Regards
Violeta
Comment 4 Mark Thomas 2013-01-08 20:30:57 UTC
Thanks for the patch and test cases. This has been applied to trunk and 7.0.x and will be included in 7.0.35 onwards.