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: Backwards compatibility for vex triage #4421

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
34 changes: 34 additions & 0 deletions cve_bin_tool/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import logging
import os
import platform
import shutil
import sys
import textwrap
import time
Expand Down Expand Up @@ -64,6 +65,7 @@
InvalidExtensionError,
MirrorError,
PDFOutputUnavailable,
VEXError,
excepthook,
)
from cve_bin_tool.input_engine import InputEngine, TriageData
Expand Down Expand Up @@ -544,6 +546,13 @@ def main(argv=None):
)

deprecated_group = parser.add_argument_group("Deprecated")
deprecated_group.add_argument(
"--triage-input-file",
action="store",
help="replaced by --vex-file",
default="",
)

deprecated_group.add_argument(
"-x",
"--extract",
Expand Down Expand Up @@ -658,6 +667,31 @@ def main(argv=None):
"""
LOGGER.warning(warning_nolinux)

# warning about deprecated "--triage-input-file" argument
if args["triage_input_file"]:
LOGGER.error(
" --triage-input-file has been deprecated. Please use --vex-file in future."
)
args["vex_file"] = args["triage_input_file"]
if args["vex_file"].endswith(".vex"):
# Auto-switch it to .json
LOGGER.error(".vex extension no longer supported, please use .json")

file_copy = Path(args["vex_file"] + ".cve-bin-tool-auto.json")
original_file = Path(args["vex_file"])
if not file_copy.exists():
LOGGER.error("Trying to make a copy with .json extension for this run.")
LOGGER.error("You will need to use this copy in future scans.")
shutil.copy(original_file, file_copy)
args["vex_file"] = str(file_copy)
else:
# abort and let the user deal with it
LOGGER.error(
"Looks like a previous run of cve-bin-tool already made a copy."
)
LOGGER.error(f"Try re-running with --vex-file {file_copy}")
return ERROR_CODES[VEXError]

# CSVScanner related settings
score = 0
if args["severity"]:
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 @@ -149,6 +149,10 @@ class PDFOutputUnavailable(Exception):
"""Raised when reportlab is not installed and PDF output is unavailable"""


class VEXError(Exception):
"""Raised when VEX file provided is invalid"""


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