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

[tor-commits] [bridgedb/develop] Fix gimp captcha check



commit 1767e28d61a97afeb3a55bbbe8f0bb3fd7e10e9b
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Jan 20 16:43:26 2020 -0800

    Fix gimp captcha check
    
    BridgeDB's multiple layers of catch-alls made this take over an hour to solve.
    The surface level exception is...
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_distributors_moat_server.py", line 947, in test_render_POST_unexpired_with_qrcode
          self.assertIsNotNone(decoded.get('data'))
        File "/usr/lib/python3.5/unittest/case.py", line 1229, in assertIsNotNone
          self.fail(self._formatMessage(msg, standardMsg))
      twisted.trial.unittest.FailTest: unexpectedly None
    
    ... but multiple layers down the actual error is...
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_distributors_moat_server.py", line 691, in test_withoutBlockIn
          self.resource.render(request)
        File "/usr/local/lib/python3.5/dist-packages/twisted/web/resource.py", line 265, in render
          return m(request)
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/moat/server.py", line 716, in render_POST
          valid = self.checkSolution(challenge, solution, clientIP)
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/moat/server.py", line 631, in checkSolution
          raise impossible
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/distributors/moat/server.py", line 628, in checkSolution
          self.secretKey, clientHMACKey)
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/captcha.py", line 293, in check
          timestamp = answerBlob[:12].lstrip('0')
      builtins.TypeError: a bytes-like object is required, not 'str'
    
    Test results changed as follows...
    
      before: FAILED (skips=115, failures=17, successes=852)
      after:  FAILED (skips=115, failures=9, successes=860)
---
 bridgedb/captcha.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bridgedb/captcha.py b/bridgedb/captcha.py
index fe0b876..6d8e8f7 100644
--- a/bridgedb/captcha.py
+++ b/bridgedb/captcha.py
@@ -289,10 +289,10 @@ class GimpCaptcha(Captcha):
             if hmacIsValid:
                 try:
                     answerBlob = secretKey.decrypt(encBlob)
-                    timestamp = answerBlob[:12].lstrip('0')
+                    timestamp = answerBlob[:12].lstrip(b'0')
                     then = cls.sched.nextIntervalStarts(int(timestamp))
                     now = int(time.time())
-                    answer = answerBlob[12:]
+                    answer = answerBlob[12:].decode('utf-8')
                 except Exception as error:
                     logging.warn(str(error))
                 else:



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