Skip to content

Commit ec123c5

Browse files
committed
Disabled whole word matches for keyword regexes
1 parent 598682a commit ec123c5

File tree

1 file changed

+5
-5
lines changed
  • SecurityKeywordsBasedSearchTool/SecFeatFinder

1 file changed

+5
-5
lines changed

SecurityKeywordsBasedSearchTool/SecFeatFinder/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ def search_keywords_in_file(file_path, flattened_keywords, repo_dir,
183183

184184
# Search only non-comment, non-test, non-HAnS-annotated lines
185185
keywords_found = {}
186-
for category, subcategory, keyword in flattened_keywords:
187-
if re.search(rf"\b{keyword}\b", cleaned_line, re.IGNORECASE):
186+
for category, subcategory, keyword_regex in flattened_keywords:
187+
if re.search(keyword_regex, cleaned_line, re.IGNORECASE):
188188
key = f"{category} : {subcategory}"
189189
if key not in keywords_found:
190190
keywords_found[key] = []
191-
keywords_found[key].append(keyword)
191+
keywords_found[key].append(keyword_regex)
192192

193193
if keywords_found:
194194
if line_number not in matches:
@@ -202,9 +202,9 @@ def search_keywords_in_file(file_path, flattened_keywords, repo_dir,
202202
if key not in matches[line_number]["Keywords Found"]:
203203
matches[line_number]["Keywords Found"][key] = []
204204
matches[line_number]["Keywords Found"][key].extend(keywords)
205-
for keyword in keywords:
205+
for keyword_regex in keywords:
206206
# Increment the counter with the correct category, subcategory, and keyword
207-
keyword_counter[(key.split(" : ")[0], key.split(" : ")[1], keyword)] += 1
207+
keyword_counter[(key.split(" : ")[0], key.split(" : ")[1], keyword_regex)] += 1
208208

209209
# Add begin and end comments only once for the line
210210
features, fm = determine_feature(pos_counter, matches, line_number, fm)

0 commit comments

Comments
 (0)