Skip to content

Commit dbf2a6b

Browse files
authored
fix: added "" around strings (#1228)
* fix: added "" around output strings * fix: isort and black
1 parent b4c924a commit dbf2a6b

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

cve_bin_tool/helper_script.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ def search_pattern(self, string_list):
144144
def search_version_string(self, matched_list):
145145
"""finds version strings from matched list"""
146146

147+
# pattern = rf"{self.product}(.*){self.version}"
148+
# ^ this does not work for debian packages
147149
pattern = rf"{self.product}(.*)([0-9]+[.-][0-9]+([.-][0-9]+)?)"
148150
# this matches patterns like:
149151
# product1.2.3
@@ -153,15 +155,15 @@ def search_version_string(self, matched_list):
153155
# product version 1.2.3
154156
# product v1.2.3(1)
155157

156-
version_string = [
158+
version_strings = [
157159
i
158160
for i in matched_list
159161
if re.search(pattern, i, re.IGNORECASE)
160162
if not i.endswith(
161163
".debug"
162164
) # removes .debug, so, this does not gets printed
163165
]
164-
return version_string
166+
return version_strings
165167

166168
def parse_filename(self, filename):
167169
"""
@@ -224,7 +226,7 @@ def find_vendor_product(self):
224226
textwrap.dedent(
225227
f"""
226228
============================================
227-
Multiple (vendor, product) pairs found.
229+
Multiple ("vendor", "product") pairs found.
228230
Please manually select the appropriate pair.
229231
============================================
230232
"""
@@ -266,15 +268,15 @@ def output(self):
266268
for common_strings in sorted(self.contain_patterns):
267269
if ".debug" in common_strings:
268270
rprint(
269-
f"\t[medium_orchid1]{common_strings}[/] <--- not recommended to use these form of strings"
271+
f'\t[red]r"{common_strings}"[/] <--- not recommended to use these form of strings'
270272
)
271273
continue # without this, the else statement was getting printed ;-;
272274
if ".so" in common_strings:
273275
rprint(
274-
f"\t[medium_orchid1]{common_strings}[/] <--- not recommended to use these form of strings"
276+
f'\t[red]r"{common_strings}"[/] <--- not recommended to use these form of strings'
275277
)
276278
else:
277-
rprint(f"\t[green]{common_strings}[/],")
279+
rprint(f'\t[green]r"{common_strings}"[/],')
278280
print("]")
279281

280282
"""
@@ -288,23 +290,23 @@ def output(self):
288290
for filename in self.filename_pattern:
289291
if self.product == filename:
290292
rprint(
291-
f"\t[medium_orchid1]{filename}[/] <--- this is a really common filename pattern"
293+
f'\t[cyan]r"{filename}"[/], <--- this is a really common filename pattern'
292294
)
293295
elif self.product in filename:
294296
if ".so" in filename:
295-
rprint(f"\t[green]{filename}[/]")
297+
rprint(f'\t[green]r"{filename}"[/],')
296298
else:
297299
rprint(
298-
f'\t[red]{filename}[/] <--- you could just use "{self.product}" to match this file'
300+
f'\t[bright_green]r"{filename}"[/], <--- you could just use "{self.product}" to match this file'
299301
) # to single-handedly match filenames of type varnishd, varnishlog, varnishtop, etc.
300302
else:
301-
rprint(f"\t[green]{filename}[/]")
303+
rprint(f'\t[green]r"{filename}"[/],')
302304
print("]")
303305

304306
# output: version-strings
305307
print("VERSION_PATTERNS = [")
306308
for version_string in self.version_pattern:
307-
rprint(f"\t[green]{version_string}[/],")
309+
rprint(f'\t[green]r"{version_string}"[/],')
308310
print("]")
309311

310312
# output: vendor-product pair

0 commit comments

Comments
 (0)