Exemple #1
0
 def test_overwrite_default_plugins(self):
     plugins_that_should_be_checked = ["optional_plugin"]
     result = overwrite_default_plugins(self.mocked_interface,
                                        plugins_that_should_be_checked)
     self.assertEqual(len(result.keys()), 4, "number of plug-ins changed")
     self.assertFalse(result['default_plugin'][2],
                      "default plugin still checked")
     self.assertTrue(result['optional_plugin'][2],
                     "optional plugin not checked")
Exemple #2
0
    def _update_analysis(self, uid, re_do=False):
        error = {}
        if request.method == 'POST':
            analysis_task = create_re_analyze_task(request, uid=uid)
            error = check_for_errors(analysis_task)
            if not error:
                self._schedule_re_analysis_task(uid, analysis_task, re_do)
                return render_template('upload/upload_successful.html',
                                       uid=uid)

        with ConnectTo(FrontEndDbInterface, self._config) as sc:
            old_firmware = sc.get_object(uid=uid, analysis_filter=[])
        if old_firmware is None:
            return render_template('uid_not_found.html', uid=uid)

        with ConnectTo(FrontEndDbInterface, self._config) as sc:
            device_class_list = sc.get_device_class_list()
        device_class_list.remove(old_firmware.device_class)

        with ConnectTo(FrontEndDbInterface, self._config) as sc:
            vendor_list = sc.get_vendor_list()
        vendor_list.remove(old_firmware.vendor)

        with ConnectTo(FrontEndDbInterface, self._config) as sc:
            device_name_dict = sc.get_device_name_dict()
        device_name_dict[old_firmware.device_class][
            old_firmware.vendor].remove(old_firmware.device_name)

        previously_processed_plugins = list(
            old_firmware.processed_analysis.keys())
        with ConnectTo(InterComFrontEndBinding, self._config) as sc:
            plugin_dict = overwrite_default_plugins(
                sc, previously_processed_plugins)

        if re_do:
            title = 're-do analysis'
        else:
            title = 'update analysis'

        return render_template('upload/re-analyze.html',
                               device_classes=device_class_list,
                               vendors=vendor_list,
                               error=error,
                               device_names=json.dumps(device_name_dict,
                                                       sort_keys=True),
                               firmware=old_firmware,
                               analysis_plugin_dict=plugin_dict,
                               title=title)