Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Fix bug regarding CPE insertion into results list
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1nb0rn committed Oct 12, 2023
1 parent 2785afc commit fec8950
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cpe_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@ def words_in_line(words, line):
cpe_base = ':'.join(cpe.split(':')[:5]) + ':'
if sim_score > most_similar[query][0][1]:
most_similar[query] = [(cpe, sim_score)] + most_similar[query][:count-1]
elif len(most_similar[query]) < count and not most_similar[query][0][0].startswith(cpe_base):
most_similar[query].append((cpe, sim_score))
elif not most_similar[query][0][0].startswith(cpe_base):
insert_idx = None
for i, (cur_cpe, cur_sim_score) in enumerate(most_similar[query][1:]):
Expand All @@ -367,7 +365,10 @@ def words_in_line(words, line):
insert_idx = i+1
break
if insert_idx:
most_similar[query] = most_similar[query][:insert_idx] + [(cpe, sim_score)] + most_similar[query][insert_idx:-1]
if len(most_similar[query]) < count:
most_similar[query] = most_similar[query][:insert_idx] + [(cpe, sim_score)] + most_similar[query][insert_idx:]
else:
most_similar[query] = most_similar[query][:insert_idx] + [(cpe, sim_score)] + most_similar[query][insert_idx:-1]


# create intermediate results (including any additional queries)
Expand Down

0 comments on commit fec8950

Please sign in to comment.