How to use the ffpuppet.minidump_parser.process_minidumps function in ffpuppet

To help you get started, we’ve selected a few ffpuppet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MozillaSecurity / ffpuppet / ffpuppet / test_minidump_parser.py View on Github external
def test_process_minidumps_01(mocker, tmp_path):
    """test process_minidumps()"""
    fake_mdp = mocker.patch("ffpuppet.minidump_parser.MinidumpParser", autospec=True)
    fake_mdp.return_value.mdsw_available.return_value = False
    # test scan_path does not exist
    process_minidumps("/missing/path/", "symbols_path", mocker.Mock())
    # test empty scan_path (no .dmp files)
    fake_mdp.return_value.dump_files = []
    process_minidumps(str(tmp_path), "symbols_path", mocker.Mock())
    # test symbols_path does not exist
    fake_mdp.return_value.dump_files = [mocker.Mock()]
    process_minidumps(str(tmp_path), "symbols_path", mocker.Mock())
    assert fake_mdp.return_value.mdsw_available.call_count == 0
    assert not fake_mdp.return_value.mdsw_available.return_value
    # test minidump_stackwalk not available
    process_minidumps(str(tmp_path), str(tmp_path), mocker.Mock())
    assert fake_mdp.return_value.mdsw_available.call_count == 1
    assert fake_mdp.return_value.collect_logs.call_count == 0
    # test success
    fake_mdp.return_value.mdsw_available.return_value = True
    process_minidumps(str(tmp_path), str(tmp_path), mocker.Mock())
    assert fake_mdp.return_value.collect_logs.call_count == 1
github MozillaSecurity / ffpuppet / ffpuppet / test_minidump_parser.py View on Github external
def test_process_minidumps_01(mocker, tmp_path):
    """test process_minidumps()"""
    fake_mdp = mocker.patch("ffpuppet.minidump_parser.MinidumpParser", autospec=True)
    fake_mdp.return_value.mdsw_available.return_value = False
    # test scan_path does not exist
    process_minidumps("/missing/path/", "symbols_path", mocker.Mock())
    # test empty scan_path (no .dmp files)
    fake_mdp.return_value.dump_files = []
    process_minidumps(str(tmp_path), "symbols_path", mocker.Mock())
    # test symbols_path does not exist
    fake_mdp.return_value.dump_files = [mocker.Mock()]
    process_minidumps(str(tmp_path), "symbols_path", mocker.Mock())
    assert fake_mdp.return_value.mdsw_available.call_count == 0
    assert not fake_mdp.return_value.mdsw_available.return_value
    # test minidump_stackwalk not available
    process_minidumps(str(tmp_path), str(tmp_path), mocker.Mock())
    assert fake_mdp.return_value.mdsw_available.call_count == 1
    assert fake_mdp.return_value.collect_logs.call_count == 0
    # test success
    fake_mdp.return_value.mdsw_available.return_value = True
    process_minidumps(str(tmp_path), str(tmp_path), mocker.Mock())
    assert fake_mdp.return_value.collect_logs.call_count == 1
github MozillaSecurity / ffpuppet / ffpuppet / test_minidump_parser.py View on Github external
def test_process_minidumps_01(mocker, tmp_path):
    """test process_minidumps()"""
    fake_mdp = mocker.patch("ffpuppet.minidump_parser.MinidumpParser", autospec=True)
    fake_mdp.return_value.mdsw_available.return_value = False
    # test scan_path does not exist
    process_minidumps("/missing/path/", "symbols_path", mocker.Mock())
    # test empty scan_path (no .dmp files)
    fake_mdp.return_value.dump_files = []
    process_minidumps(str(tmp_path), "symbols_path", mocker.Mock())
    # test symbols_path does not exist
    fake_mdp.return_value.dump_files = [mocker.Mock()]
    process_minidumps(str(tmp_path), "symbols_path", mocker.Mock())
    assert fake_mdp.return_value.mdsw_available.call_count == 0
    assert not fake_mdp.return_value.mdsw_available.return_value
    # test minidump_stackwalk not available
    process_minidumps(str(tmp_path), str(tmp_path), mocker.Mock())
    assert fake_mdp.return_value.mdsw_available.call_count == 1
    assert fake_mdp.return_value.collect_logs.call_count == 0
    # test success
    fake_mdp.return_value.mdsw_available.return_value = True
    process_minidumps(str(tmp_path), str(tmp_path), mocker.Mock())
    assert fake_mdp.return_value.collect_logs.call_count == 1
github MozillaSecurity / ffpuppet / ffpuppet / core.py View on Github external
# will help verify that.
                # If '_proc' is not None this is the first call to close()
                # in this situation the PuppetLogger should still be available.
                assert self._proc is None, "PuppetLogger is closed!"
            else:
                log.debug("reviewing %d check(s)", len(self._checks))
                for check in self._checks:
                    if check.message is not None:
                        r_code = self.RC_WORKER
                        check.dump_log(dst_fp=self._logs.add_log("ffp_worker_%s" % check.name))
                # collect logs (excluding minidumps)
                for fname in self._crashreports(skip_md=True):
                    self._logs.add_log(os.path.basename(fname), open(fname, "rb"))
                # check for minidumps in the profile and dump them if possible
                if self.profile is not None:
                    process_minidumps(
                        os.path.join(self.profile, "minidumps"),
                        os.path.join(self._last_bin_path, "symbols"),
                        self._logs.add_log)
                if self._logs.get_fp("stderr"):
                    self._logs.get_fp("stderr").write(
                        ("[ffpuppet] Reason code: %s\n" % r_code).encode("utf-8"))

        self._proc = None
        self._logs.close()
        self._checks = list()
        # remove temporary profile directory if necessary
        if self.profile is not None and os.path.isdir(self.profile):
            try:
                shutil.rmtree(self.profile, onerror=onerror)
            except OSError:  # pragma: no cover
                log.error("Failed to remove profile %r", self.profile)
github MozillaSecurity / grizzly / grizzly / target / adb_device / adb_process.py View on Github external
with open(os.path.join(self.logs, "log_logcat.txt"), "wb") as log_fp:
            # TODO: should this filter by pid or not?
            log_fp.write(self._session.collect_logs())
            #log_fp.write(self._session.collect_logs(pid=self._pid))
        self._split_logcat(self.logs, self._package)
        if not crash_reports:
            return

        # copy crash logs from the device
        for fname in crash_reports:
            self._session.pull(fname, unprocessed)

        logger = PuppetLogger()
        try:
            syms_path = self._session.symbols_path(self._package)
            process_minidumps(unprocessed, syms_path, logger.add_log)
            logger.close()
            logger.save_logs(self.logs)
        finally:
            logger.clean_up()