Skip to content
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

fix: halt if pdf selected but unavailable #4354

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cve_bin_tool/cli.py
terriko marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
InsufficientArgs,
InvalidExtensionError,
MirrorError,
PDFOutputUnavailable,
excepthook,
)
from cve_bin_tool.input_engine import InputEngine, TriageData
Expand Down Expand Up @@ -893,11 +894,14 @@ def main(argv=None):

# Check for PDF support
if "pdf" in output_formats and importlib.util.find_spec("reportlab") is None:
LOGGER.info("PDF output not available.")
LOGGER.info(
LOGGER.error("PDF output not available.")
LOGGER.error(
"If you want to produce PDF output, please install reportlab using pip install reportlab"
)
output_formats.remove("pdf")
if len(output_formats) < 1:
# If there's no other formats selected, exit so people actually see the error
return ERROR_CODES[PDFOutputUnavailable]

merged_reports = None
if args["merge"]:
Expand Down
5 changes: 5 additions & 0 deletions cve_bin_tool/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class NetworkConnectionError(Exception):
"""Raised when issue occurred with internet connection"""


class PDFOutputUnavailable(Exception):
"""Raised when reportlab is not installed and PDF output is unavailable"""


class ErrorMode(Enum):
Ignore = 0
NoTrace = 1
Expand Down Expand Up @@ -246,4 +250,5 @@ def __exit__(self, exc_type, exc_val, exc_tb):
InvalidExtensionError: 42,
SigningError: 43,
NetworkConnectionError: 44,
PDFOutputUnavailable: 45,
}
Loading