[tor-commits] [ooni-probe/master] Add support for redacting IP address of user in response headers

art at torproject.org art at torproject.org
Fri Jan 13 12:39:57 UTC 2017


commit 6e43f2145d8bffb5e735c37c17b1d80ced463959
Author: Arturo Filastò <arturo at filasto.net>
Date:   Wed Nov 23 16:10:13 2016 +0000

    Add support for redacting IP address of user in response headers
---
 ooni/templates/httpt.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/ooni/templates/httpt.py b/ooni/templates/httpt.py
index e57463b..b9308b7 100644
--- a/ooni/templates/httpt.py
+++ b/ooni/templates/httpt.py
@@ -163,19 +163,25 @@ class HTTPTest(NetTestCase):
             'response': None
         }
         if response:
+            if (getattr(response, 'request', None) and
+                    getattr(response.request, 'absoluteURI', None)):
+                session['request']['url'] = response.request.absoluteURI
+
             if self.localOptions.get('withoutbody', 0) is 0:
                 response_body = representBody(response_body)
             else:
                 response_body = ''
+
+            response_headers = _representHeaders(response.headers)
             # Attempt to redact the IP address of the probe from the responses
             if (config.privacy.includeip is False and probe_ip.address is not None and
                     (isinstance(response_body, str) or isinstance(response_body, unicode))):
                 response_body = response_body.replace(probe_ip.address, "[REDACTED]")
-            if (getattr(response, 'request', None) and
-                    getattr(response.request, 'absoluteURI', None)):
-                session['request']['url'] = response.request.absoluteURI
+                for key, value in response_headers.items():
+                    response_headers[key] = value.replace(probe_ip.address,
+                                                          "[REDACTED]")
             session['response'] = {
-                'headers': _representHeaders(response.headers),
+                'headers': response_headers,
                 'body': response_body,
                 'code': response.code
             }





More information about the tor-commits mailing list