Beispiel #1
0
 def _nice_virtual_path_list(self, virtual_path_list: List[str]) -> List[str]:
     path_list = []
     for virtual_path in virtual_path_list:
         uid_list = split_virtual_path(virtual_path)
         components = [
             self._virtual_path_element_to_span(hid, uid, root_uid=uid_list[0])
             for hid, uid in zip(split_virtual_path(self._filter_replace_uid_with_hid(virtual_path)), uid_list)
         ]
         path_list.append(' '.join(components))
     return path_list
Beispiel #2
0
def create_data_graph_nodes_and_groups(data, parent_uid, root_uid, whitelist):

    data_graph = {
        'nodes': [],
        'edges': [],
        'groups': []
    }
    groups = []

    for file in data:
        mime = file['processed_analysis']['file_type']['mime']
        if mime not in whitelist or root_uid not in file['virtual_file_path']:
            continue

        if mime not in groups:
            groups.append(mime)

        virtual_paths = file['virtual_file_path'][root_uid]

        for vpath in virtual_paths:

            path_components = split_virtual_path(vpath)

            if len(path_components) < 2:
                continue

            name_component = path_components[-1]
            parent_component = path_components[-2]

            if parent_component != parent_uid:
                continue

            linked_libraries = []
            elf_analysis_missing = 'elf_analysis' not in file['processed_analysis']
            with suppress(KeyError):
                linked_libraries = file['processed_analysis']['elf_analysis']['Output']['libraries']

            node = {
                'label': name_component,
                'id': vpath,
                'entity': file['_id'],
                'group': mime,
                'full_file_type': file['processed_analysis']['file_type']['full'],
                'linked_libraries': linked_libraries,
                'elf_analysis_missing': elf_analysis_missing
            }

            data_graph['nodes'].append(node)

    data_graph['groups'] = sorted(groups)

    return data_graph