[tor-commits] [bridgedb/master] Fix dkim header check

phw at torproject.org phw at torproject.org
Wed Feb 19 18:26:38 UTC 2020


commit aa6cbac12ffc93ffe664f9ede816e66214583c4a
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Jan 20 15:25:03 2020 -0800

    Fix dkim header check
    
    Oops, this one's my bad. When migrating from the rfc822 module I broke this
    check. The new email message's get() method returns a string rather than a list
    so we shouldn't index into it (we were setting dkimHeader to only the first
    character). This fixes...
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_email_dkim.py", line 57, in test_checkDKIM_good
          self.assertTrue(result)
        File "/usr/local/lib/python3.5/dist-packages/twisted/trial/_synctest.py", line 395, in assertTrue
          super(_Assertions, self).assertTrue(condition, msg)
        File "/usr/lib/python3.5/unittest/case.py", line 677, in assertTrue
          raise self.failureException(msg)
      twisted.trial.unittest.FailTest: False is not true
    
    Test results changed as follows...
    
      before: FAILED (skips=115, failures=19, successes=850)
      after:  FAILED (skips=115, failures=18, successes=851)
---
 bridgedb/distributors/email/dkim.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/bridgedb/distributors/email/dkim.py b/bridgedb/distributors/email/dkim.py
index 48118c8..5cee31d 100644
--- a/bridgedb/distributors/email/dkim.py
+++ b/bridgedb/distributors/email/dkim.py
@@ -64,9 +64,7 @@ def checkDKIM(message, rules):
         # getheader() returns the last of a given kind of header; we want
         # to get the first, so we use getheaders() instead.
         dkimHeaders = message.get("X-DKIM-Authentication-Results")
-        dkimHeader = "<no header>"
-        if dkimHeaders:
-            dkimHeader = dkimHeaders[0]
+        dkimHeader = dkimHeaders if dkimHeaders else "<no header>"
         if not dkimHeader.startswith("pass"):
             logging.info("Rejecting bad DKIM header on incoming email: %r "
                          % dkimHeader)





More information about the tor-commits mailing list