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

Test fails if any VENDOR_PRODUCT pair in checker is not lowercase #1032

Merged
merged 6 commits into from
Jan 27, 2021
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
10 changes: 9 additions & 1 deletion cve_bin_tool/checkers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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))
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 @@ -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 """

Expand Down Expand Up @@ -152,4 +156,5 @@ def __exit__(self, exc_type, exc_val, exc_tb):
UnknownArchiveType: -13,
UnknownConfigType: -14,
CVEDataMissing: -15,
InvalidCheckerError: -16,
}