nilp0inter / cpe

CPE: Common Platform Enumeration for Python
GNU Lesser General Public License v3.0
92 stars 30 forks source link

Updated _VALUE_PATTERN for CPE 2.2 #56

Closed programmerchad closed 1 year ago

programmerchad commented 1 year ago

According to https://nvd.nist.gov/products/cpe/search, the following CPE is a valid CPE: cpe:/a:intel:proset\/wireless_wifi

However, the current _VALUE_PATTERN in cpecomp2_2.py does not recognize it as valid:

>>> CPE("cpe:/a:intel:proset\/wireless_wifi").as_uri_2_3()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/chad/.pyenv/versions/service_tvdb_loader/lib/python3.10/site-packages/cpe/cpe.py", line 311, in __new__
    raise NotImplementedError(errmsg)
NotImplementedError: Version of CPE not implemented

With the changes in this PR, this CPE becomes recognized as valid:

>>> from cpe.comp.cpecomp2_2 import CPEComponent2_2
>>> from cpe import CPE
>>> import re
>>> CPEComponent2_2._value_rxc = re.compile(r"^([\d\w\._\-~%\\/]+)$")
>>> CPE("cpe:/a:intel:proset\/wireless_wifi").as_uri_2_3()
'cpe:/a:intel:proset%2fwireless_wifi'
creekorful commented 1 year ago

Thanks for the PR! Looks good to me but Ill have a look properly and merge it end of week.

Cheers

creekorful commented 1 year ago

Merged! Thanks for you contribution!