Skip to content

Commit

Permalink
Strip query before attempting to match it to a CPE
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1nb0rn committed Dec 13, 2023
1 parent 7e30d72 commit a83e687
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions search_vulns.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ def search_vulns(query, db_cursor=None, software_match_threshold=CPE_SEARCH_THRE
close_cursor_after = True

# if given query is not already a CPE, retrieve a CPE that matches the query
query = query.strip()
cpe = query
if not MATCH_CPE_23_RE.match(query):
cpe = search_cpes(query, count=1, threshold=software_match_threshold, keep_data_in_memory=keep_data_in_memory)
Expand Down Expand Up @@ -416,6 +417,7 @@ def search_vulns(query, db_cursor=None, software_match_threshold=CPE_SEARCH_THRE
def search_vulns_return_cpe(query, db_cursor=None, software_match_threshold=CPE_SEARCH_THRESHOLD, keep_data_in_memory=False, add_other_exploits_refs=False, is_good_cpe=False, ignore_general_cpe_vulns=False):
"""Search for known vulnerabilities based on the given query and return them with their CPE"""

query = query.strip()
cpe, pot_cpes = query, []
if not MATCH_CPE_23_RE.match(query):
is_good_cpe = False
Expand Down Expand Up @@ -544,6 +546,7 @@ def main():
out_string = ''
for query in args.queries:
# if current query is not already a CPE, retrieve a CPE that matches the query
query = query.strip()
cpe = query
if not MATCH_CPE_23_RE.match(query):
cpe = search_cpes(query, count=1, threshold=args.cpe_search_threshold)
Expand Down

0 comments on commit a83e687

Please sign in to comment.