Skip to content

fix: rpm extractor for windows #1696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 15, 2022
18 changes: 17 additions & 1 deletion cve_bin_tool/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,24 @@ async def extract_file_rpm(self, filename, extraction_path):
if stderr or not stdout:
return 1
filenames = await aio_glob(os.path.join(extraction_path, "*.cpio"))
if not filenames:
if not await aio_inpath("zstd"):
with ErrorHandler(mode=self.error_mode, logger=self.logger):
raise Exception("zstd is required to extract rpm files")
else:
filenames = await aio_glob(
os.path.join(extraction_path, "*.cpio.zstd")
)
filename = filenames[0]
stdout, stderr, _ = await aio_run_command(
["zstd", "-d", filename]
)
if stderr:
return 1
filenames = await aio_glob(
os.path.join(extraction_path, "*.cpio")
)
filename = filenames[0]

stdout, stderr, _ = await aio_run_command(["7z", "x", filename])
if stderr or not stdout:
return 1
Expand Down