Skip to content

Commit

Permalink
Fix bug if incomplete / short CPE was supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1nb0rn committed Apr 23, 2024
1 parent 9797725 commit 7880eee
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions search_vulns.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,14 @@ def _is_version_start_end_matching(cpe_parts, version_start, version_start_incl,

# combine version and subversion if NVD merged both for version_end as well
cpe_product = cpe_parts[4]
cpe_version, cpe_subversion = CPEVersion(cpe_parts[5]), CPEVersion(cpe_parts[6])
cpe_version, cpe_subversion = CPEVersion('*'), CPEVersion('*')
# check that CPE is not short/incomplete
if len(cpe_parts) > 5:
cpe_version = CPEVersion(cpe_parts[5])
if len(cpe_parts) > 6:
cpe_subversion = CPEVersion(cpe_parts[6])

# try to merge version and subversion if needed
if version_end:
version_end_sections = version_end.get_version_sections()
cpe_version_subsections = cpe_version.get_version_sections()
Expand Down Expand Up @@ -442,8 +449,11 @@ def get_equivalent_cpes(cpe, config):
cpes = [cpe]
cpe_split = cpe.split(':')
cpe_prefix = ':'.join(cpe_split[:5]) + ':'
cpe_version = cpe_split[5]
cpe_subversion = cpe_split[6]
cpe_version, cpe_subversion = '*', '*'
if len(cpe_split) > 5:
cpe_version = cpe_split[5]
if len(cpe_split) > 6:
cpe_subversion = cpe_split[6]

# if version part consists of more than one version parts, split into two CPE fields
cpe_version_sections = CPEVersion(cpe_version).get_version_sections()
Expand Down

0 comments on commit 7880eee

Please sign in to comment.