Unverified Commit aa6cbac1 authored by Damian Johnson's avatar Damian Johnson Committed by Philipp Winter
Browse files

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)
parent 702abdb2
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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)