diff --git a/cve_bin_tool/checkers/__init__.py b/cve_bin_tool/checkers/__init__.py index 3b78d4e2a1..1ea7fbed3a 100644 --- a/cve_bin_tool/checkers/__init__.py +++ b/cve_bin_tool/checkers/__init__.py @@ -2,7 +2,8 @@ import collections import re -from ..util import regex_find +from cve_bin_tool.error_handler import InvalidCheckerError +from cve_bin_tool.util import regex_find __all__ = [ "Checker", @@ -96,6 +97,13 @@ def __new__(cls, name, bases, props): cls.VENDOR_PRODUCT = list( map(lambda vpkg: VendorProductPair(*vpkg), cls.VENDOR_PRODUCT) ) + # Validate that vendor product pair is in lowercase + for items in cls.VENDOR_PRODUCT: + for vp in items: + if vp.islower() != True: + raise InvalidCheckerError( + f"Checker {name} has a VENDOR_PRODUCT string that is not lowercase" + ) # Compile regex cls.CONTAINS_PATTERNS = list(map(re.compile, cls.CONTAINS_PATTERNS)) cls.VERSION_PATTERNS = list(map(re.compile, cls.VERSION_PATTERNS)) diff --git a/cve_bin_tool/error_handler.py b/cve_bin_tool/error_handler.py index 8b53caa751..a7ecaf83d3 100644 --- a/cve_bin_tool/error_handler.py +++ b/cve_bin_tool/error_handler.py @@ -17,6 +17,10 @@ class InvalidCsvError(Exception): """ Given File is an Invalid CSV """ +class InvalidCheckerError(Exception): + """ Raised when data provided to Checker is not correct """ + + class MissingFieldsError(Exception): """ Missing needed fields """ @@ -152,4 +156,5 @@ def __exit__(self, exc_type, exc_val, exc_tb): UnknownArchiveType: -13, UnknownConfigType: -14, CVEDataMissing: -15, + InvalidCheckerError: -16, }