예제 #1
0
파일: core.py 프로젝트: mzidek-gh/faf
    def _hash_backtrace(self, backtrace):
        result = []

        for key in ["function_name", "fingerprint", "build_id_offset"]:
            hashbase = []

            threads_sane = []
            for thread in backtrace:
                threads_sane.append(all(key in f for f in thread["frames"]))

            if not all(threads_sane):
                continue

            for thread in backtrace:
                if "crash_thread" in thread and thread["crash_thread"]:
                    hashbase.append("Crash Thread")
                else:
                    hashbase.append("Thread")

                for frame in thread["frames"]:
                    if "build_id" in frame:
                        build_id = frame["build_id"]
                    else:
                        build_id = None

                    hashbase.append("  {0} @ {1} ({2})".format(
                        frame[key],
                        frame["file_name"].encode("ascii",
                                                  "ignore"), build_id))

            result.append(hash_list(hashbase))

        return result
예제 #2
0
    def _hash_koops(self, koops, taintflags=None, skip_unreliable=False):
        if taintflags is None:
            taintflags = []

        if skip_unreliable:
            frames = [f for f in koops if f["reliable"]]
        else:
            frames = koops

        if not frames:
            return None

        hashbase = list(taintflags)
        for frame in frames:
            if not "module_name" in frame:
                module = "vmlinux"
            else:
                module = frame["module_name"]

            if "address" not in frame:
                address = 0
            else:
                address = frame["address"]


            hashbase.append("{0} {1}+{2}/{3} @ {4}"
                            .format(address, frame["function_name"],
                                    frame["function_offset"],
                                    frame["function_length"], module))

        return hash_list(hashbase)
예제 #3
0
파일: kerneloops.py 프로젝트: mkutlak/faf
    def _hash_koops(self, koops, taintflags=None, skip_unreliable=False):
        if taintflags is None:
            taintflags = []

        if skip_unreliable:
            frames = [f for f in koops if f["reliable"]]
        else:
            frames = koops

        if not frames:
            return None

        hashbase = list(taintflags)
        for frame in frames:
            if not "module_name" in frame:
                module = "vmlinux"
            else:
                module = frame["module_name"]

            if "address" not in frame:
                address = 0
            else:
                address = frame["address"]


            hashbase.append("{0} {1}+{2}/{3} @ {4}"
                            .format(address, frame["function_name"],
                                    frame["function_offset"],
                                    frame["function_length"], module))

        return hash_list(hashbase)
예제 #4
0
파일: core.py 프로젝트: martinky82/faf
    def _hash_backtrace(self, backtrace):
        result = []

        for key in ["function_name", "fingerprint", "build_id_offset"]:
            hashbase = []

            threads_sane = []
            for thread in backtrace:
                threads_sane.append(all(key in f for f in thread["frames"]))

            if not all(threads_sane):
                continue

            for thread in backtrace:
                if "crash_thread" in thread and thread["crash_thread"]:
                    hashbase.append("Crash Thread")
                else:
                    hashbase.append("Thread")

                for frame in thread["frames"]:
                    if "build_id" in frame:
                        build_id = frame["build_id"]
                    else:
                        build_id = None

                    hashbase.append("  {0} @ {1} ({2})"
                                    .format(frame[key],
                                            frame["file_name"].encode("ascii",
                                                                      "ignore"),
                                            build_id))

            result.append(hash_list(hashbase))

        return result
예제 #5
0
    def test_hash_list_encoding(self):
        """
        hash_list and hashlib.sha1 respectively shouldn't fail if
        passed unicode literals
        """

        self.assertEqual(hash_list([u"♥", u"Bl\xe9"]),
                         'b4661b6dd570d2aeb4c90477f2c0cc4e3582fa10')
예제 #6
0
파일: test_utils.py 프로젝트: abrt/faf
    def test_hash_list_encoding(self):
        """
        hash_list and hashlib.sha1 respectively shouldn't fail if
        passed unicode literals
        """

        self.assertEqual(hash_list([u"♥", u"Bl\xe9"]),
                         'b4661b6dd570d2aeb4c90477f2c0cc4e3582fa10')
예제 #7
0
파일: ruby.py 프로젝트: martinky82/faf
    def _hash_traceback(self, traceback):
        hashbase = []
        for frame in traceback:
            if "special_function" in frame:
                funcname = "<{0}>".format(frame["special_function"])
            else:
                funcname = frame["function_name"]

            hashbase.append("{0} @ {1} + {2}".format(funcname,
                                                     frame["file_name"],
                                                     frame["file_line"]))

        return hash_list(hashbase)
예제 #8
0
    def _hash_traceback(self, traceback):
        hashbase = []
        for frame in traceback:
            if "special_function" in frame:
                funcname = "<{0}>".format(frame["special_function"])
            else:
                funcname = frame["function_name"]

            hashbase.append("{0} @ {1} + {2}".format(funcname,
                                                     frame["file_name"],
                                                     frame["file_line"]))

        return hash_list(hashbase)
예제 #9
0
    def _hash_backtrace(self,
                        db_backtrace,
                        hashbase=None,
                        offset=False) -> str:
        if hashbase is None:
            hashbase = []

        crashthreads = [t for t in db_backtrace.threads if t.crashthread]
        if not crashthreads:
            raise FafError("No crash thread found")

        if len(crashthreads) > 1:
            raise FafError("Multiple crash threads found")

        frames = [f for f in crashthreads[0].frames if not f.inlined][:16]

        hasnames = all([
            f.symbolsource.symbol is not None
            and f.symbolsource.symbol.name is not None
            and f.symbolsource.symbol.name != "??" for f in frames
        ])
        hashashes = all([f.symbolsource.hash is not None for f in frames])

        # use function names if available
        if hasnames:
            # also hash offset for reports that use it as line numbers
            # these reports always have function names
            if offset:
                hashbase.extend([
                    "{0} @ {1} + {2}".format(f.symbolsource.symbol.name,
                                             f.symbolsource.path,
                                             f.symbolsource.offset)
                    for f in frames
                ])
            else:
                hashbase.extend([
                    "{0} @ {1}".format(f.symbolsource.symbol.name,
                                       f.symbolsource.path) for f in frames
                ])
        # fallback to hashes
        elif hashashes:
            hashbase.extend([
                "{0} @ {1}".format(f.symbolsource.hash, f.symbolsource.path)
                for f in frames
            ])
        else:
            raise FafError("either function names or hashes are required")

        return hash_list(hashbase)
예제 #10
0
파일: python.py 프로젝트: abrt/faf
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]

        for i, frame in enumerate(ureport["stacktrace"]):
            # Instance of 'PythonProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if "special_function" in frame:
                funcname = "<{0}>".format(frame["special_function"])
            else:
                funcname = frame["function_name"]

            hashbase.append("{0} @ {1} + {2}".format(funcname,
                                                     frame["file_name"],
                                                     frame["file_line"]))
        return hash_list(hashbase)
예제 #11
0
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]
        hashbase.extend(ureport["taint_flags"])

        for i, frame in enumerate(ureport["frames"]):
            # Instance of 'KerneloopsProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if not "module_name" in frame:
                module = "vmlinux"
            else:
                module = frame["module_name"]

            hashbase.append("{0} @ {1}".format(frame["function_name"], module))

        return hash_list(hashbase)
예제 #12
0
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]

        for i, frame in enumerate(ureport["stacktrace"]):
            # Instance of 'PythonProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if "special_function" in frame:
                funcname = "<{0}>".format(frame["special_function"])
            else:
                funcname = frame["function_name"]

            hashbase.append("{0} @ {1} + {2}".format(funcname,
                                                     frame["file_name"],
                                                     frame["file_line"]))
        return hash_list(hashbase)
예제 #13
0
파일: java.py 프로젝트: sanjana098/faf
    def _hash_backtrace(self, threads):
        hashbase = []

        for thread in threads:
            hashbase.append("Thread")

            for frame in thread["frames"]:
                # Instance of 'JavaProblem' has no 'hashframes' member
                # pylint: disable-msg=E1101

                if "class_path" in frame:
                    hashbase.append("{0} @ {1}".format(frame["name"],
                                                       frame["class_path"]))
                    continue

                hashbase.append(frame["name"])

        return hash_list(hashbase)
예제 #14
0
파일: java.py 프로젝트: martinky82/faf
    def _hash_backtrace(self, threads):
        hashbase = []

        for thread in threads:
            hashbase.append("Thread")

            for frame in thread["frames"]:
                # Instance of 'JavaProblem' has no 'hashframes' member
                # pylint: disable-msg=E1101

                if "class_path" in frame:
                    hashbase.append("{0} @ {1}".format(frame["name"],
                                                       frame["class_path"]))
                    continue

                hashbase.append(frame["name"])

        return hash_list(hashbase)
예제 #15
0
파일: kerneloops.py 프로젝트: mkutlak/faf
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]
        hashbase.extend(ureport["taint_flags"])

        for i, frame in enumerate(ureport["frames"]):
            # Instance of 'KerneloopsProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if not "module_name" in frame:
                module = "vmlinux"
            else:
                module = frame["module_name"]

            hashbase.append("{0} @ {1}".format(frame["function_name"], module))

        return hash_list(hashbase)
예제 #16
0
파일: java.py 프로젝트: sanjana098/faf
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]

        # at the moment we only send crash thread
        # we may need to identify the crash thread in the future
        for i, frame in enumerate(ureport["threads"][0]["frames"]):
            # Instance of 'JavaProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if "class_path" in frame:
                hashbase.append("{0} @ {1}".format(frame["name"],
                                                   frame["class_path"]))
                continue

            hashbase.append(frame["name"])

        return hash_list(hashbase)
예제 #17
0
파일: java.py 프로젝트: martinky82/faf
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]

        # at the moment we only send crash thread
        # we may need to identify the crash thread in the future
        for i, frame in enumerate(ureport["threads"][0]["frames"]):
            # Instance of 'JavaProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if "class_path" in frame:
                hashbase.append("{0} @ {1}".format(frame["name"],
                                                   frame["class_path"]))
                continue

            hashbase.append(frame["name"])

        return hash_list(hashbase)
예제 #18
0
파일: core.py 프로젝트: mkutlak/faf
    def hash_ureport(self, ureport):
        crashthread = self._get_crash_thread(ureport["stacktrace"])
        hashbase = [ureport["component"]]

        if all("function_name" in f for f in crashthread):
            key = "function_name"
        elif all("fingerprint" in f for f in crashthread):
            key = "fingerprint"
        else:
            key = "build_id_offset"

        for i, frame in enumerate(crashthread):
            # Instance of 'CoredumpProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            hashbase.append("{0} @ {1}".format(frame[key], frame["file_name"]))

        return hash_list(hashbase)
예제 #19
0
파일: core.py 프로젝트: martinky82/faf
    def hash_ureport(self, ureport):
        crashthread = self._get_crash_thread(ureport["stacktrace"])
        hashbase = [ureport["component"]]

        if all("function_name" in f for f in crashthread):
            key = "function_name"
        elif all("fingerprint" in f for f in crashthread):
            key = "fingerprint"
        else:
            key = "build_id_offset"

        for i, frame in enumerate(crashthread):
            # Instance of 'CoredumpProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            hashbase.append("{0} @ {1}".format(
                frame[key],
                frame["file_name"].encode("ascii", "ignore")))

        return hash_list(hashbase)
예제 #20
0
파일: test_utils.py 프로젝트: abrt/faf
 def test_hash_list(self):
     self.assertEqual(hash_list(["aa", "bb"]),
                      'f67229713c9dcb92b3388cc8d254c866221404f3')
예제 #21
0
 def test_hash_list(self):
     self.assertEqual(hash_list(["aa", "bb"]),
                      'f67229713c9dcb92b3388cc8d254c866221404f3')