[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Add support for stripping potential inclusion of probe IPs in reports



commit ee2fa7b4093117bd618af03382809ade4e9832a0
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date:   Fri Mar 11 17:57:10 2016 +0100

    Add support for stripping potential inclusion of probe IPs in reports
---
 ooni/templates/httpt.py   | 3 +++
 ooni/templates/process.py | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ooni/templates/httpt.py b/ooni/templates/httpt.py
index 3702e86..d0822f2 100644
--- a/ooni/templates/httpt.py
+++ b/ooni/templates/httpt.py
@@ -134,6 +134,9 @@ class HTTPTest(NetTestCase):
             }
         }
         if response:
+            # Attempt to redact the IP address of the probe from the responses
+            if config.privacy.includeip is False:
+                response_body = response_body.replace(config.probe_ip.address, "[REDACTED]")
             request_response['response'] = {
                 'headers': list(response.headers.getAllRawHeaders()),
                 'body': response_body if self.localOptions.get('withoutbody', 0) == 0 else '',
diff --git a/ooni/templates/process.py b/ooni/templates/process.py
index 82457dc..42a4256 100644
--- a/ooni/templates/process.py
+++ b/ooni/templates/process.py
@@ -1,5 +1,6 @@
 from twisted.internet import protocol, defer, reactor
 
+from ooni.settings import config
 from ooni.nettest import NetTestCase
 from ooni.utils import log
 
@@ -66,7 +67,7 @@ class ProcessDirector(protocol.ProcessProtocol):
         self.stderr += data
         if self.shouldClose():
             self.close("condition_met")
-        self.handlRead(None,  data)
+        self.handleRead(None,  data)
 
 
     def inConnectionLost(self):
@@ -105,6 +106,12 @@ class ProcessTest(NetTestCase):
         log.debug("Finished %s: %s" % (command, result))
         if not isinstance(self.report.get('commands'), list):
             self.report['commands'] = []
+
+        # Attempt to redact the IP address of the probe from the standard output
+        if config.privacy.includeip is False:
+            result['stdout'] = result['stdout'].replace(config.probe_ip.address, "[REDACTED]")
+            result['stderr'] = result['stderr'].replace(config.probe_ip.address, "[REDACTED]")
+
         self.report['commands'].append({
             'command_name': ' '.join(command),
             'command_stdout': result['stdout'],



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits