Пример #1
0
    def test_serialize_deserialize(self):
        try:
            raise KeyError
        except Exception, e:
            except_type, except_class, tb = sys.exc_info()
            enabled_plugins = '{}'

            fr = self.get_fuzzable_request()

            core = w3afCore()
            status = CoreStatus(core)
            status.set_running_plugin('audit', 'sqli', log=False)
            status.set_current_fuzzable_request('audit', fr)

            exception_data = ExceptionData(status,
                                           e,
                                           tb,
                                           enabled_plugins,
                                           store_tb=False)

            pickled_ed = cPickle.dumps(exception_data)
            unpickled_ed = cPickle.loads(pickled_ed)

            self.assertEqual(exception_data.to_json(),
                             unpickled_ed.to_json())
Пример #2
0
    def handle_exception(self, phase, plugin_name, fuzzable_request,
                         _exception):
        """
        Get the exception information, and put it into the output queue
        then, the strategy will get the items from the output queue and
        handle the exceptions.

        :param plugin_name: The plugin that generated the exception
        :param fuzzable_request: The fuzzable request that was sent as input to
                                 the plugin when the exception was raised
        :param _exception: The exception object
        """
        except_type, except_class, tb = sys.exc_info()
        enabled_plugins = pprint_plugins(self._w3af_core)

        status = CoreStatus(self._w3af_core)
        status.set_running_plugin(phase, plugin_name, log=False)
        status.set_current_fuzzable_request(phase, fuzzable_request)

        exception_data = ExceptionData(status,
                                       _exception,
                                       tb,
                                       enabled_plugins,
                                       store_tb=False)
        self._out_queue.put(exception_data)
Пример #3
0
    def test_without_traceback(self):
        tb = None
        enabled_plugins = '{}'

        fr = self.get_fuzzable_request()

        core = w3afCore()
        status = CoreStatus(core)
        status.set_running_plugin('audit', 'sqli', log=False)
        status.set_current_fuzzable_request('audit', fr)

        exception_data = ExceptionData(status,
                                       KeyError(),
                                       tb,
                                       enabled_plugins,
                                       store_tb=False)

        pickled_ed = cPickle.dumps(exception_data)
        unpickled_ed = cPickle.loads(pickled_ed)

        self.assertEqual(exception_data.to_json(), unpickled_ed.to_json())
Пример #4
0
    def test_fail_traceback_serialize(self):
        try:
            raise KeyError
        except Exception, e:
            except_type, except_class, tb = sys.exc_info()
            enabled_plugins = '{}'

            fr = self.get_fuzzable_request()

            core = w3afCore()
            status = CoreStatus(core)
            status.set_running_plugin('audit', 'sqli', log=False)
            status.set_current_fuzzable_request('audit', fr)

            exception_data = ExceptionData(status,
                                           e,
                                           tb,
                                           enabled_plugins,
                                           store_tb=True)

            self.assertRaises(TypeError, cPickle.dumps, exception_data)