def _ajax_get_tree_children(self, uid, root_uid=None, compare_id=None):
     root_uid, compare_id = none_to_none(root_uid), none_to_none(compare_id)
     exclusive_files = self._get_exclusive_files(compare_id, root_uid)
     tree = self._generate_file_tree(root_uid, uid, exclusive_files)
     children = [
         convert_to_jstree_node(child_node)
         for child_node in tree.get_list_of_child_nodes()
     ]
     return jsonify(children)
 def show_analysis(self, uid, selected_analysis=None, root_uid=None):
     other_versions = None
     with ConnectTo(CompareDbInterface, self._config) as db_service:
         all_comparisons = db_service.page_compare_results()
         known_comparisons = [comparison for comparison in all_comparisons if uid in comparison[0]]
     analysis_filter = [selected_analysis] if selected_analysis else []
     with ConnectTo(FrontEndDbInterface, self._config) as sc:
         file_obj = sc.get_object(uid, analysis_filter=analysis_filter)
         if not file_obj:
             return render_template('uid_not_found.html', uid=uid)
         if isinstance(file_obj, Firmware):
             root_uid = file_obj.uid
             other_versions = sc.get_other_versions_of_firmware(file_obj)
         included_fo_analysis_complete = not sc.all_uids_found_in_database(list(file_obj.files_included))
     with ConnectTo(InterComFrontEndBinding, self._config) as sc:
         analysis_plugins = sc.get_available_analysis_plugins()
     return render_template_string(
         self._get_correct_template(selected_analysis, file_obj),
         uid=uid,
         firmware=file_obj,
         selected_analysis=selected_analysis,
         all_analyzed_flag=included_fo_analysis_complete,
         root_uid=none_to_none(root_uid),
         analysis_plugin_dict=analysis_plugins,
         other_versions=other_versions,
         uids_for_comparison=get_comparison_uid_list_from_session(),
         user_has_admin_clearance=user_has_privilege(current_user, privilege='delete'),
         known_comparisons=known_comparisons,
         available_plugins=self._get_used_and_unused_plugins(
             file_obj.processed_analysis,
             [x for x in analysis_plugins.keys() if x != 'unpacker']
         )
     )
Exemple #3
0
    def _filter_nice_uid_list(self, uids, root_uid=None, selected_analysis=None, filename_only=False):
        root_uid = none_to_none(root_uid)
        if not is_list_of_uids(uids):
            return uids

        with ConnectTo(FrontEndDbInterface, self._config) as sc:
            analyzed_uids = sc.get_data_for_nice_list(uids, root_uid)
        number_of_unanalyzed_files = len(uids) - len(analyzed_uids)
        first_item = analyzed_uids.pop(0)

        return render_template(
            'generic_view/nice_fo_list.html',
            fo_list=analyzed_uids, u_show_id=random_collapse_id(),
            number_of_unanalyzed_files=number_of_unanalyzed_files, root_uid=root_uid,
            selected_analysis=selected_analysis, first_item=first_item, filename_only=filename_only
        )
def test_none_to_none(input_data, expected):
    assert none_to_none(input_data) == expected