diff --git a/cve_bin_tool/extractor.py b/cve_bin_tool/extractor.py index d457c4cb89..8e01831609 100644 --- a/cve_bin_tool/extractor.py +++ b/cve_bin_tool/extractor.py @@ -50,6 +50,7 @@ def __init__(self, logger=None, error_mode=ErrorMode.TruncTrace): self.extract_file_cab: {".cab"}, self.extract_file_apk: {".apk"}, self.extract_file_zst: {".zst"}, + self.extract_file_pkg: {".pkg"}, self.extract_file_zip: { ".exe", ".zip", @@ -117,7 +118,6 @@ async def extract_file_zst(self, filename, extraction_path): if await aio_inpath("zstd"): tar_path = os.path.join(extraction_path, "data.tar") - self.logger.warning(tar_path) stdout, stderr, return_code = await aio_run_command( ["unzstd", filename, "-f", "-o", tar_path] ) @@ -132,6 +132,19 @@ async def extract_file_zst(self, filename, extraction_path): tar.extractall(extraction_path) return 0 + async def extract_file_pkg(self, filename, extraction_path): + """Extract pkg files""" + if not await aio_inpath("tar"): + with ErrorHandler(mode=self.error_mode, logger=self.logger): + raise Exception("tar is required to extract .pkg files") + else: + stdout, stderr, return_code = await aio_run_command( + ["tar", "xf", filename, "-C", extraction_path] + ) + if (stderr or not stdout) and return_code != 0: + return 1 + return 0 + async def extract_file_deb(self, filename, extraction_path): """Extract debian packages""" if not await aio_inpath("ar"):