Exemplo n.º 1
0
    def test_result(self):
        """Test if EICAR virus is detected and message deleted"""

        suspect = Suspect(
            '*****@*****.**', '*****@*****.**', '/dev/null')
        stream = """Date: Mon, 08 Sep 2008 17:33:54 +0200
To: [email protected]
From: [email protected]
Subject: test eicar attachment
X-Mailer: swaks v20061116.0 jetmore.org/john/code/#swaks
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_MIME_BOUNDARY_000_12140"

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

Eicar test
------=_MIME_BOUNDARY_000_12140
Content-Type: application/octet-stream
Content-Transfer-Encoding: BASE64
Content-Disposition: attachment

UEsDBAoAAAAAAGQ7WyUjS4psRgAAAEYAAAAJAAAAZWljYXIuY29tWDVPIVAlQEFQWzRcUFpYNTQo
UF4pN0NDKTd9JEVJQ0FSLVNUQU5EQVJELUFOVElWSVJVUy1URVNULUZJTEUhJEgrSCoNClBLAQIU
AAoAAAAAAGQ7WyUjS4psRgAAAEYAAAAJAAAAAAAAAAEAIAD/gQAAAABlaWNhci5jb21QSwUGAAAA
AAEAAQA3AAAAbQAAAAAA

------=_MIME_BOUNDARY_000_12140--"""

        suspect.setMessageRep(email.message_from_string(stream))
        result = self.candidate.examine(suspect)
        if type(result) is tuple:
            result, message = result
        strresult = actioncode_to_string(result)
        self.assertEqual(strresult, "DELETE")
Exemplo n.º 2
0
    def test_modified_message(self):
        """Test if the modified message gets archived correctly"""
        from fuglu.shared import Suspect
        import shutil
        import tempfile

        tempfilename = tempfile.mktemp(suffix='archive',
                                       prefix='fuglu-unittest',
                                       dir='/tmp')
        shutil.copy(TESTDATADIR + '/helloworld.eml', tempfilename)
        self.tempfiles.append(tempfilename)

        self.config.set('ArchivePlugin', 'storeoriginal', '0')
        candidate = ArchivePlugin(self.config)
        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', tempfilename)
        origmessage = suspect.get_source()
        # modify the mesg
        msgrep = suspect.get_message_rep()
        msgrep['X-Changed-Something'] = 'Yes'
        suspect.setMessageRep(msgrep)

        filename = candidate.archive(suspect)
        self.assertTrue(filename != None and filename)

        self.tempfiles.append(filename)

        archivedmessage = open(filename, 'r').read()
        self.assertNotEqual(origmessage.strip(), archivedmessage.strip(
        )), 'Archived message should have stored modified message'
Exemplo n.º 3
0
    def test_modified_message(self):
        """Test if the modified message gets archived correctly"""
        from fuglu.shared import Suspect
        import shutil
        import tempfile

        tempfilename = tempfile.mktemp(
            suffix='archive', prefix='fuglu-unittest', dir='/tmp')
        shutil.copy(TESTDATADIR + '/helloworld.eml', tempfilename)
        self.tempfiles.append(tempfilename)

        self.config.set('ArchivePlugin', 'storeoriginal', '0')
        candidate = ArchivePlugin(self.config)
        suspect = Suspect(
            '*****@*****.**', '*****@*****.**', tempfilename)
        origmessage = suspect.get_source()
        # modify the mesg
        msgrep = suspect.get_message_rep()
        msgrep['X-Changed-Something'] = 'Yes'
        suspect.setMessageRep(msgrep)

        filename = candidate.archive(suspect)
        self.assertTrue(filename != None and filename)

        self.tempfiles.append(filename)

        archivedmessage = open(filename, 'r').read()
        self.assertNotEqual(origmessage.strip(), archivedmessage.strip(
        )), 'Archived message should have stored modified message'
Exemplo n.º 4
0
    def test_result(self):
        """Test if EICAR virus is detected and message deleted"""

        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', '/dev/null')
        stream = """Date: Mon, 08 Sep 2008 17:33:54 +0200
To: [email protected]
From: [email protected]
Subject: test eicar attachment
X-Mailer: swaks v20061116.0 jetmore.org/john/code/#swaks
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_MIME_BOUNDARY_000_12140"

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

Eicar test
------=_MIME_BOUNDARY_000_12140
Content-Type: application/octet-stream
Content-Transfer-Encoding: BASE64
Content-Disposition: attachment

UEsDBAoAAAAAAGQ7WyUjS4psRgAAAEYAAAAJAAAAZWljYXIuY29tWDVPIVAlQEFQWzRcUFpYNTQo
UF4pN0NDKTd9JEVJQ0FSLVNUQU5EQVJELUFOVElWSVJVUy1URVNULUZJTEUhJEgrSCoNClBLAQIU
AAoAAAAAAGQ7WyUjS4psRgAAAEYAAAAJAAAAAAAAAAEAIAD/gQAAAABlaWNhci5jb21QSwUGAAAA
AAEAAQA3AAAAbQAAAAAA

------=_MIME_BOUNDARY_000_12140--"""

        suspect.setMessageRep(email.message_from_string(stream))
        result = self.candidate.examine(suspect)
        if type(result) is tuple:
            result, message = result
        strresult = actioncode_to_string(result)
        self.assertEqual(strresult, "DELETE")