Skip to content

Commit

Permalink
feat: add support for VEX (Fixes intel#1570)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyharrison committed Mar 20, 2022
1 parent c2975ac commit 156ae08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions cve_bin_tool/input_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# TriageData is dictionary of cve_number mapped to dictionary of remarks, comments and custom severity
TriageData = Dict[str, Union[Dict[str, Any], Set[str]]]


class InputEngine:
# parsed_data is a dictionary of vendor, product, version mapped to TriageData
parsed_data: DefaultDict[ProductInfo, TriageData]
Expand Down Expand Up @@ -68,11 +69,11 @@ def input_json(self) -> None:
self.parse_data(set(json_data[0].keys()), json_data)

def validate_product(self, product: str) -> bool:
'''
"""
Ensure product name conforms to CPE 2.3 standard.
See https://csrc.nist.gov/schema/cpe/2.3/cpe-naming_2.3.xsd for naming specification
'''
cpe_regex = "\A([A-Za-z0-9\._\-~ %])+\Z"
"""
cpe_regex = r"\A([A-Za-z0-9\._\-~ %])+\Z"
return re.search(cpe_regex, product) is not None

def input_vex(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion test/test_input_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@ def test_vex_file(self, filepath, parsed_data):
)
def test_valid_product_name(self, product, product_result):
input_engine = InputEngine("temp.txt", error_mode=ErrorMode.FullTrace)
assert input_engine.validate_product(product) == product_result
assert input_engine.validate_product(product) == product_result

0 comments on commit 156ae08

Please sign in to comment.