Read AndroidQF process lists and skip ZIP directory entries

This commit is contained in:
Janik Besendorf committed 2026-11-18 00:03:12 +01:00
1 parent 086dde4b8f
commit 301616a296
3 files changed
+32 -2

No files matched your search

+3 -1
View File
@@ -95,7 +95,9 @@ class CmdAndroidCheckAndroidQF(Command):
elif os.path.isfile(self.target_path):
self.__format = "zip"
self.__zip = zipfile.ZipFile(self.target_path)
self.__files = self.__zip.namelist()
self.__files = [
entry.filename for entry in self.__zip.infolist() if not entry.is_dir()
]
self._load_acquisition_context()
@@ -34,7 +34,9 @@ class AQFProcesses(ProcessesArtifact, AndroidQFModule):
)
def run(self) -> None:
ps_files = self._get_files_by_pattern("*/ps.txt")
ps_files = self._get_files_by_pattern(
"*/processes.txt"
) or self._get_files_by_pattern("*/ps.txt")
if not ps_files:
return
+26
View File
@@ -63,6 +63,32 @@ def test_androidqf_property_detection_across_layouts(
class TestCheckAndroidqfCommand:
@pytest.mark.parametrize("use_zip", [False, True], ids=["folder", "zip"])
def test_androidqf_process_list_and_log_files(self, tmp_path, use_zip):
archive_path = tmp_path / "acquisition.zip"
with zipfile.ZipFile(archive_path, "w") as archive:
archive.writestr("processes.txt", "USER PID NAME\nroot 1 init\n")
archive.writestr("logs/proc/kmsg", "")
archive.writestr("logs/data/anr/", "")
target = archive_path if use_zip else tmp_path / "acquisition"
if not use_zip:
archive.extractall(target)
command = CmdAndroidCheckAndroidQF(
target_path=str(target),
disable_version_check=True,
disable_indicator_check=True,
)
command.run()
records = {type(module).__name__: module.results for module in command.executed}
assert records["AQFProcesses"] == [
{"user": "root", "pid": 1, "command": "init"}
]
timestamps = records["AQFLogTimestamps"]
assert len(timestamps) == 1
assert timestamps[0]["path"].replace("\\", "/").endswith("logs/proc/kmsg")
def test_log_timestamps_module_is_registered(self):
assert AQFLogTimestamps in ANDROIDQF_MODULES