예제 #1
0
    def test_localpartblacklist(self):
        """test messages from mailer-daemon"""
        from fuglu.shared import Suspect
        import email
        v = Vacation()
        v.ignoresender = u""
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'awaaay'
        v.body = u'cya'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        botmsg = """From: [email protected]
Subject: mailinglist membership reminder...
"""

        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', '/dev/null')
        suspect.set_tag('nobounce', True)
        suspect.set_source(botmsg)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(candidatevacation != None,
                        "Vacation object not found in database")
        self.assertFalse(
            self.candidate.should_send_vacation_message(suspect),
            "Test Message should NOT generate vacation reply(automated)")
예제 #2
0
    def test_localpartblacklist(self):
        """test messages from mailer-daemon"""
        from fuglu.shared import Suspect
        import email
        v = Vacation()
        v.ignoresender = u""
        v.awayuser = u'*****@*****.**'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'awaaay'
        v.body = u'cya'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        botmsg = """From: [email protected]
Subject: mailinglist membership reminder...
"""

        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', '/dev/null')
        suspect.set_tag('nobounce', True)
        suspect.set_source(botmsg)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(
            candidatevacation != None, "Vacation object not found in database")
        self.assertFalse(self.candidate.should_send_vacation_message(
            suspect), "Test Message should NOT generate vacation reply(automated)")
예제 #3
0
    def test_score(self):
        suspect = Suspect("*****@*****.**", "*****@*****.**", "/dev/null")
        stream = """Date: Mon, 08 Sep 2008 17:33:54 +0200
To: [email protected]
From: [email protected]
Subject: test scanner

  XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
"""
        suspect.set_source(stream)
        result = self.candidate.examine(suspect)
        if type(result) is tuple:
            result, message = result
        score = int(suspect.get_tag("SAPlugin.spamscore"))
        self.failUnless(score > 999, "GTUBE mails should score ~1000 , we got %s" % score)
        self.failUnless(result == REJECT, "High spam should be rejected")
예제 #4
0
    def test_withSuspect_newDecode(self):
        """Test if new version of URIExtract gives same result as old one"""
        myclass = self.__class__.__name__
        functionNameAsString = sys._getframe().f_code.co_name
        loggername = "%s.%s" % (myclass,functionNameAsString)
        logger = logging.getLogger(loggername)

        logger.debug("Read file content")
        filecontent = BytesIO(mail_html).read()

        logger.debug("Create suspect")
        suspect = Suspect("*****@*****.**","*****@*****.**","/dev/null")
        suspect.set_source(filecontent)

        textparts_deprecated = self.candidate.get_decoded_textparts_deprecated(suspect)
        textparts            = self.candidate.get_decoded_textparts(suspect,bcompatible=False)

        self.assertEqual(textparts_deprecated,textparts)
예제 #5
0
    def test_score(self):
        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', '/dev/null')
        stream = """Date: Mon, 08 Sep 2008 17:33:54 +0200
To: [email protected]
From: [email protected]
Subject: test scanner

  XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
"""
        suspect.set_source(stream)
        result = self.candidate.examine(suspect)
        if type(result) is tuple:
            result, message = result
        score = int(suspect.get_tag('SAPlugin.spamscore'))
        self.failUnless(score > 999,
                        "GTUBE mails should score ~1000 , we got %s" % score)
        self.failUnless(result == REJECT, 'High spam should be rejected')
예제 #6
0
    def test_withSuspect(self):
        """Test unquoted href attribute in html part of mail"""
        myclass = self.__class__.__name__
        functionNameAsString = sys._getframe().f_code.co_name
        loggername = "%s.%s" % (myclass,functionNameAsString)
        logger = logging.getLogger(loggername)

        logger.debug("Read file content")
        filecontent = BytesIO(mail_html).read()

        logger.debug("Create suspect")
        suspect = Suspect("*****@*****.**","*****@*****.**","/dev/null")
        suspect.set_source(filecontent)

        logger.debug("examine suspect")
        self.candidate.examine(suspect)

        uris = suspect.get_tag('body.uris')
        logger.debug('uris: '+",".join(uris))
        self.assertTrue( "http://toBeDetected.com.br/Jul2018/En/Statement/Invoice-DDDDDDDDD-DDDDDD/" in uris)
예제 #7
0
    def _make_dummy_suspect(self, envelope_sender_domain='a.unittests.fuglu.org', header_from_domain='a.unittests.fuglu.org', recipient_domain='b.unittests.fuglu.org', file='/dev/null'):
        s = Suspect('sender@%s' %
                    envelope_sender_domain, 'recipient@%s'%recipient_domain, file)

        template="""From: sender@%s
Subject: Hello spear phished world!
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_MIME_BOUNDARY_000_12140"

------=_MIME_BOUNDARY_000_12140
Content-Type: text/plain

blablabla

some <tagged>text</tagged>
------=_MIME_BOUNDARY_000_12140--
        """%header_from_domain

        s.set_source(template)
        return s
예제 #8
0
    def test_withSuspect_TE(self):
        """Test using suspect, link is in the base64 transfer encoded part"""
        myclass = self.__class__.__name__
        functionNameAsString = sys._getframe().f_code.co_name
        loggername = "%s.%s" % (myclass,functionNameAsString)
        logger = logging.getLogger(loggername)

        logger.debug("Read file content")
        filecontent = BytesIO(mail_base64).read()

        logger.debug("Create suspect")
        suspect = Suspect("*****@*****.**","*****@*****.**","/dev/null")
        suspect.set_source(filecontent)

        logger.debug("examine suspect")
        self.candidate.examine(suspect)

        uris = suspect.get_tag('body.uris')
        logger.debug('uris: '+",".join(uris))

        self.assertTrue('www.co.uk' in uris)