Beispiel #1
0
    def test_virus(self):
        """Test if eicar is detected as virus"""
        from fuglu.shared import Suspect
        import shutil

        self.mc.load_plugins()
        if len(self.mc.plugins) == 0:
            raise Exception("plugins not loaded")

        sesshandler = SessionHandler(None, self.mc.config, self.mc.prependers,
                                     self.mc.plugins, self.mc.appenders)
        tempfilename = tempfile.mktemp(suffix='virus',
                                       prefix='fuglu-unittest',
                                       dir='/tmp')
        shutil.copy(TESTDATADIR + '/eicar.eml', tempfilename)
        self.tempfiles.append(tempfilename)
        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', tempfilename)
        pluglist = sesshandler.run_prependers(suspect)
        self.assertFalse(
            len(pluglist) == 0,
            "Viruscheck will fail, pluginlist empty after run_prependers")
        sesshandler.run_plugins(suspect, pluglist)
        self.assertTrue(suspect.is_virus(),
                        "Eicar message was not detected as virus")
Beispiel #2
0
    def test_prepender(self):
        """Test prepender plugin raising exception"""
        config = RawConfigParser()

        # -------------#
        # config: main #
        # -------------#
        config.add_section("main")
        config.set('main', 'plugins', '')
        config.set('main', 'prependers',
                   'sessionhandler_test.RaiseExceptionPrepender')
        config.set('main', 'appenders', '')

        # ------------------- #
        # config: performance #
        # ------------------- #
        config.add_section("performance")
        # minimum scanner threads
        config.set('performance', 'minthreads', 1)
        # maximum scanner threads
        config.set('performance', 'maxthreads', 1)
        # Method for parallelism, either 'thread' or 'process'
        config.set('performance', 'backend', 'process')

        mc = MainController(config)
        mc.propagate_core_defaults()
        ok = mc.load_plugins()

        suspect = Suspect('*****@*****.**',
                          '*****@*****.**', '/dev/null')

        shandler = SessionHandler(None, config, mc.prependers, mc.plugins,
                                  mc.appenders, 0)
        pluglist, applist = shandler.run_prependers(suspect)

        shandler.run_plugins(suspect, pluglist)

        ptags = suspect.get_tag("processingerrors")
        self.assertEqual([
            'Prepender RaiseExceptionPrepender failed: Prepender Plugin not implemented'
        ], ptags)
Beispiel #3
0
    def test_virus(self):
        """Test if eicar is detected as virus"""
        from fuglu.shared import Suspect
        import shutil

        self.mc.load_plugins()
        if len(self.mc.plugins) == 0:
            raise Exception("plugins not loaded")

        sesshandler = SessionHandler(
            None, self.mc.config, self.mc.prependers, self.mc.plugins, self.mc.appenders)
        tempfilename = tempfile.mktemp(
            suffix='virus', prefix='fuglu-unittest', dir='/tmp')
        shutil.copy(TESTDATADIR + '/eicar.eml', tempfilename)
        self.tempfiles.append(tempfilename)
        suspect = Suspect(
            '*****@*****.**', '*****@*****.**', tempfilename)
        pluglist = sesshandler.run_prependers(suspect)
        self.assertFalse(
            len(pluglist) == 0, "Viruscheck will fail, pluginlist empty after run_prependers")
        sesshandler.run_plugins(suspect, pluglist)
        self.assertTrue(
            suspect.is_virus(), "Eicar message was not detected as virus")