commit fdd18a673d38161a585cefc91aa70ac2afd5d57a Author: Arturo Filastò arturo@filasto.net Date: Thu Mar 10 18:34:41 2016 +0100
Fixes spotted to issues highlighted by @bassosimone in review of PR
Initialise tampering to None and set it False when we detect it not happening
Actually properly strip null characters form response body, but only after having tried to decode it
Remove un-used YAML format --- data/ooniprobe.conf.sample | 1 - ooni/nettests/manipulation/http_invalid_request_line.py | 4 ++-- ooni/templates/httpt.py | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/data/ooniprobe.conf.sample b/data/ooniprobe.conf.sample index a7d8d29..7aaacd7 100644 --- a/data/ooniprobe.conf.sample +++ b/data/ooniprobe.conf.sample @@ -22,7 +22,6 @@ reports: # This is a prefix for each packet capture file (.pcap) per test: pcap: null collector: null - format: yaml advanced: geoip_data_dir: /usr/share/GeoIP debug: false diff --git a/ooni/nettests/manipulation/http_invalid_request_line.py b/ooni/nettests/manipulation/http_invalid_request_line.py index f81d953..2109677 100644 --- a/ooni/nettests/manipulation/http_invalid_request_line.py +++ b/ooni/nettests/manipulation/http_invalid_request_line.py @@ -40,7 +40,7 @@ class HTTPInvalidRequestLine(tcpt.TCPTest): def setUp(self): self.port = int(self.localOptions['backendport']) self.address = self.localOptions['backend'] - self.report['tampering'] = False + self.report['tampering'] = None
def check_for_manipulation(self, response, payload): log.debug("Checking if %s == %s" % (response, payload)) @@ -50,7 +50,7 @@ class HTTPInvalidRequestLine(tcpt.TCPTest): self.report['tampering'] = True else: log.msg("No manipulation detected.") - self.report['tampering'] = self.report['tampering'] | False + self.report['tampering'] = False
def test_random_invalid_method(self): """ diff --git a/ooni/templates/httpt.py b/ooni/templates/httpt.py index 3a36b18..d2cc6e1 100644 --- a/ooni/templates/httpt.py +++ b/ooni/templates/httpt.py @@ -131,11 +131,12 @@ class HTTPTest(NetTestCase): def _representBody(body): # XXX perhaps add support for decoding gzip in the future. try: - body.replace('\0', '') body = unicode(body, 'ascii') + body = body.replace('\0', '') except UnicodeDecodeError: try: body = unicode(body, 'utf-8') + body = body.replace('\0', '') except UnicodeDecodeError: body = base64Dict(body)
tor-commits@lists.torproject.org