Esempio n. 1
0
    def _app_upload(self):
        error = {}
        if request.method == 'POST':
            analysis_task = create_analysis_task(request)
            error = check_for_errors(analysis_task)
            if not error:
                fw = convert_analysis_task_to_fw_obj(analysis_task)
                with ConnectTo(InterComFrontEndBinding, self._config) as sc:
                    sc.add_analysis_task(fw)
                return render_template('upload/upload_successful.html',
                                       uid=analysis_task['uid'])

        with ConnectTo(FrontEndDbInterface, self._config) as sc:
            device_class_list = sc.get_device_class_list()
            vendor_list = sc.get_vendor_list()
            device_name_dict = sc.get_device_name_dict()
        with ConnectTo(InterComFrontEndBinding, self._config) as sc:
            analysis_plugins = sc.get_available_analysis_plugins()
        analysis_presets = [key for key in self._config['default_plugins']]
        return render_template('upload/upload.html',
                               device_classes=device_class_list,
                               vendors=vendor_list,
                               error=error,
                               analysis_presets=analysis_presets,
                               device_names=json.dumps(device_name_dict,
                                                       sort_keys=True),
                               analysis_plugin_dict=analysis_plugins)
Esempio n. 2
0
 def post_upload(self):
     analysis_task = create_analysis_task(request, self._config)
     error = check_for_errors(analysis_task)
     if error:
         return self.get_upload(error=error)
     fw = convert_analysis_task_to_fw_obj(analysis_task)
     with ConnectTo(InterComFrontEndBinding, self._config) as sc:
         sc.add_analysis_task(fw)
     return render_template('upload/upload_successful.html', uid=analysis_task['uid'])