コード例 #1
0
 def setSourceCode(self, editor, source_file):
     try:
         editor.append(source_file.read())
     except FileNotFoundError:
         debug(1, "[NOT FOUND] %s", source_file.name)
コード例 #2
0
 def marginLeftClick(self, margin_nr, line_nr, state):
     debug(
         5,
         "[SRC] marginLeftClick\n\tmargin_nr: %d, line_nr: %d, state: %d",
         (margin_nr, line_nr, state))
コード例 #3
0
ファイル: report.py プロジェクト: Fraunhofer-AISEC/DATA
def parse_leaks(lib_hierarchy):
    assert isinstance(lib_hierarchy, LibHierarchy)

    with utils.datafs.get_binfile(IP_INFO_FILE) as f:
        short_info_map = loadipinfo(f)

    for ip in sorted_keys(lib_hierarchy.entries):
        lib = lib_hierarchy.entries[ip]
        assert isinstance(lib, Library)

        lib_name = lib.libentry.name.split("/")[-1]
        lib_item = LibHierarchyItem("{}".format(lib_name), lib, lib_model.root_item)
        lib_model.root_item.appendChild(lib_item)

        bin_file_path = lib.libentry.name

        with utils.datafs.get_file(f"{bin_file_path}.asm") as f:
            asm_dump = f.read().split("\n")

        debug(0, f"[REPORT] lib_name: {lib_name}")
        debug(0, f"[REPORT] bin_path: {bin_file_path}")

        fl_entries = createLibFunctionItems(lib, lib_item)  # tuple (ip, fl_item)

        for (addr, lib_tree_item) in fl_entries:
            if addr not in short_info_map:
                debug(0, "Cannot find addr in short_info_map")
                debug(0, "(Could be a wrong combination of pickle and zip file?)")
                sys.exit(ErrorCode.INVALID_COMB_OF_FILES)

            leak_docs = LeakDocs(
                lib_name,
                lib_tree_item,
                addr,
                None,
                None,
            )
            if leak_docs.leak.meta is None:
                leak_docs.leak.meta = LeakMetaInfo()
            if leak_docs.leak.meta.flag == LeakFlags.DONTCARE or (
                leak_docs.leak.meta.flag != LeakFlags.LEAK
                and leak_docs.leak.status.is_generic_leak() is False
                and leak_docs.leak.status.is_specific_leak() is False
            ):
                continue

            short_info = short_info_map[addr]
            assert isinstance(short_info, IpInfoShort)

            # ASM
            if short_info.asm_line_nr < 0:
                continue
            search_str = format(utils.getLocalIp(addr), "x") + ":"
            debug(1, f"ASM search_str: {search_str}")
            search_idx = [
                idx for (idx, line) in enumerate(asm_dump) if search_str in line
            ]
            assert len(search_idx) >= 1  # search for ff0 will trigger 1ff0 as well
            search_idx = search_idx[0]
            leak_docs.asm = LeakDump(
                bin_file_path,
                search_idx,
                asm_dump[search_idx - 5 : search_idx],
                asm_dump[search_idx],
                asm_dump[search_idx + 1 : search_idx + 5],
            )

            # SRC
            src_line_nr = short_info.src_line_nr - 1
            debug(1, f"SRC src_line_nr: {src_line_nr}")
            debug(1, f"SRC src_file: {short_info.src_file}")
            leak_dump_src = None
            if short_info.src_file is None:
                debug(1, "Source file path missing: %s", short_info.src_file)
            else:
                with utils.datafs.get_file(short_info.src_file) as f:
                    src_dump = f.read().split("\n")
                debug(1, src_dump[src_line_nr])
                leak_docs.src = LeakDump(
                    short_info.src_file,
                    src_line_nr,
                    src_dump[src_line_nr - 5 : src_line_nr],
                    src_dump[src_line_nr],
                    src_dump[src_line_nr + 1 : src_line_nr + 5],
                )

            leaks_docs.append(leak_docs)
            libs_leaks_docs[lib_name].append(leak_docs)
コード例 #4
0
ファイル: report.py プロジェクト: Fraunhofer-AISEC/DATA
                    self.generate_leak_page(leak_docs)

        self.doc.generate_pdf(clean_tex=False)
        self.doc.generate_tex()


if __name__ == "__main__":
    if args.pickle is None or args.zip is None:
        experiment_dir = "/".join(args.experiment.split("/")[:-1])
        results = list()
        for file in glob.glob(f"{experiment_dir}/{'*'.join(PICKLE)}"):
            results.append(file)
        args.pickle = sorted(results)[-1]
        args.zip = f"{experiment_dir}/{ZIP}"

        debug(0, f"[REPORT] Automatically selected {args.pickle}")
        debug(0, f"[REPORT] Automatically selected {args.zip}")

    try:
        call_hierarchy = loadpickle(args.pickle)
        if not call_hierarchy:
            raise FileNotFoundError()
    except FileNotFoundError:
        debug(0, "Please enter a valid pickle file path (mandatory)")
        sys.exit(ErrorCode.INVALID_PICKLE)
    except Exception as e:
        debug(0, f"Unable to load pickle file at {args.pickle}")
        debug(1, "Exception: " + str(e))
        sys.exit(ErrorCode.CANNOT_LOAD_PICKLE)

    try:
コード例 #5
0
ファイル: SummaryTab.py プロジェクト: kanhavishva/data-gui
 def commentChanged(self):
     comment = self.user_comment.toPlainText()
     debug(5, "[usrComment]: %s", comment)
     self.leak.meta.comment = comment
     self.notifyUnsavedChanges()
コード例 #6
0
ファイル: SummaryTab.py プロジェクト: kanhavishva/data-gui
 def bgClicked(self, btn_id):
     debug(5, "[bgClicked] flag_%d clicked", btn_id)
     flag_id = btn_to_flag[btn_id]
     self.leak.meta.flag = flag_id
     self.updateFlagIcon(self.leak.ip, flag_id)
     self.notifyUnsavedChanges()