troubadix 25.12.4__py3-none-any.whl → 26.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- troubadix/__version__.py +1 -1
- troubadix/argparser.py +4 -14
- troubadix/helper/date_format.py +3 -8
- troubadix/helper/helper.py +1 -3
- troubadix/helper/if_block_parser.py +14 -37
- troubadix/helper/linguistic_exception_handler.py +6 -18
- troubadix/helper/patterns.py +7 -19
- troubadix/helper/remove_comments.py +1 -4
- troubadix/helper/text_utils.py +1 -3
- troubadix/plugin.py +3 -9
- troubadix/plugins/__init__.py +6 -20
- troubadix/plugins/badwords.py +3 -9
- troubadix/plugins/copyright_text.py +2 -5
- troubadix/plugins/copyright_year.py +4 -12
- troubadix/plugins/creation_date.py +3 -9
- troubadix/plugins/cvss_format.py +1 -3
- troubadix/plugins/dependencies.py +2 -5
- troubadix/plugins/dependency_category_order.py +7 -20
- troubadix/plugins/deprecated_dependency.py +6 -16
- troubadix/plugins/deprecated_functions.py +2 -4
- troubadix/plugins/double_end_points.py +2 -7
- troubadix/plugins/duplicate_oid.py +1 -3
- troubadix/plugins/duplicated_script_tags.py +1 -2
- troubadix/plugins/forking_nasl_functions.py +1 -4
- troubadix/plugins/get_kb_on_services.py +2 -4
- troubadix/plugins/grammar.py +8 -20
- troubadix/plugins/http_links_in_tags.py +3 -6
- troubadix/plugins/illegal_characters.py +6 -15
- troubadix/plugins/log_messages.py +1 -2
- troubadix/plugins/malformed_dependencies.py +2 -6
- troubadix/plugins/missing_desc_exit.py +1 -3
- troubadix/plugins/multiple_re_parameters.py +2 -7
- troubadix/plugins/newlines.py +1 -2
- troubadix/plugins/overlong_description_lines.py +2 -6
- troubadix/plugins/overlong_script_tags.py +9 -14
- troubadix/plugins/prod_svc_detect_in_vulnvt.py +1 -4
- troubadix/plugins/qod.py +0 -1
- troubadix/plugins/script_add_preference_id.py +3 -10
- troubadix/plugins/script_add_preference_type.py +2 -7
- troubadix/plugins/script_calls_empty_values.py +3 -3
- troubadix/plugins/script_calls_recommended.py +5 -8
- troubadix/plugins/script_copyright.py +1 -3
- troubadix/plugins/script_family.py +1 -2
- troubadix/plugins/script_tag_form.py +1 -3
- troubadix/plugins/script_tag_whitespaces.py +5 -10
- troubadix/plugins/script_tags_mandatory.py +2 -5
- troubadix/plugins/script_version_and_last_modification_tags.py +6 -17
- troubadix/plugins/script_xref_form.py +1 -3
- troubadix/plugins/script_xref_url.py +3 -7
- troubadix/plugins/security_messages.py +8 -21
- troubadix/plugins/severity_date.py +3 -10
- troubadix/plugins/severity_format.py +1 -4
- troubadix/plugins/severity_origin.py +1 -4
- troubadix/plugins/solution_text.py +6 -10
- troubadix/plugins/solution_type.py +1 -2
- troubadix/plugins/spaces_before_dots.py +2 -9
- troubadix/plugins/spaces_in_filename.py +1 -2
- troubadix/plugins/spelling.py +5 -14
- troubadix/plugins/trailing_spaces_tabs.py +2 -5
- troubadix/plugins/using_display.py +2 -6
- troubadix/plugins/valid_oid.py +51 -60
- troubadix/plugins/valid_script_tag_names.py +2 -5
- troubadix/plugins/variable_assigned_in_if.py +2 -7
- troubadix/plugins/variable_redefinition_in_foreach.py +2 -6
- troubadix/plugins/vt_placement.py +2 -8
- troubadix/reporter.py +7 -21
- troubadix/results.py +2 -8
- troubadix/runner.py +5 -14
- troubadix/standalone_plugins/allowed_rev_diff.py +8 -25
- troubadix/standalone_plugins/changed_creation_date.py +4 -14
- troubadix/standalone_plugins/changed_cves.py +4 -12
- troubadix/standalone_plugins/changed_oid.py +3 -8
- troubadix/standalone_plugins/changed_packages/changed_packages.py +3 -8
- troubadix/standalone_plugins/changed_packages/marker/changed_update.py +1 -3
- troubadix/standalone_plugins/changed_packages/marker/dropped_architecture.py +1 -3
- troubadix/standalone_plugins/changed_packages/package.py +13 -7
- troubadix/standalone_plugins/dependency_graph/checks.py +5 -15
- troubadix/standalone_plugins/dependency_graph/dependency_graph.py +5 -13
- troubadix/standalone_plugins/deprecate_vts.py +3 -9
- troubadix/standalone_plugins/file_extensions.py +3 -10
- troubadix/standalone_plugins/last_modification.py +3 -9
- troubadix/standalone_plugins/no_solution.py +12 -34
- troubadix/standalone_plugins/util.py +0 -2
- troubadix/standalone_plugins/version_updated.py +5 -14
- troubadix/troubadix.py +1 -4
- {troubadix-25.12.4.dist-info → troubadix-26.2.0.dist-info}/METADATA +1 -1
- troubadix-26.2.0.dist-info/RECORD +116 -0
- {troubadix-25.12.4.dist-info → troubadix-26.2.0.dist-info}/WHEEL +1 -1
- troubadix-25.12.4.dist-info/RECORD +0 -116
- {troubadix-25.12.4.dist-info → troubadix-26.2.0.dist-info}/entry_points.txt +0 -0
- {troubadix-25.12.4.dist-info → troubadix-26.2.0.dist-info}/licenses/LICENSE +0 -0
troubadix/plugins/valid_oid.py
CHANGED
|
@@ -95,13 +95,8 @@ class CheckValidOID(FileContentPlugin):
|
|
|
95
95
|
# Vendor-specific OIDs
|
|
96
96
|
if "1.3.6.1.4.1.25623.1.1." in oid:
|
|
97
97
|
family = family_match.group("value")
|
|
98
|
-
vendor_number_match = re.search(
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
if (
|
|
102
|
-
vendor_number_match is None
|
|
103
|
-
or vendor_number_match.group(1) is None
|
|
104
|
-
):
|
|
98
|
+
vendor_number_match = re.search(r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.([0-9]+)\.", oid)
|
|
99
|
+
if vendor_number_match is None or vendor_number_match.group(1) is None:
|
|
105
100
|
yield LinterError(
|
|
106
101
|
f"script_oid() {invalid_oid} '{str(oid)}' (last digits)",
|
|
107
102
|
file=nasl_file,
|
|
@@ -114,8 +109,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
114
109
|
if vendor_number == "1":
|
|
115
110
|
if family != f"Debian {family_template}":
|
|
116
111
|
yield LinterError(
|
|
117
|
-
f"script_oid() {is_using_reserved} Debian "
|
|
118
|
-
f"'{str(oid)}'",
|
|
112
|
+
f"script_oid() {is_using_reserved} Debian '{str(oid)}'",
|
|
119
113
|
file=nasl_file,
|
|
120
114
|
plugin=self.name,
|
|
121
115
|
)
|
|
@@ -124,8 +118,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
124
118
|
elif vendor_number == "2":
|
|
125
119
|
if family != f"Huawei EulerOS {family_template}":
|
|
126
120
|
yield LinterError(
|
|
127
|
-
f"script_oid() {is_using_reserved} EulerOS "
|
|
128
|
-
f"'{str(oid)}'",
|
|
121
|
+
f"script_oid() {is_using_reserved} EulerOS '{str(oid)}'",
|
|
129
122
|
file=nasl_file,
|
|
130
123
|
plugin=self.name,
|
|
131
124
|
)
|
|
@@ -133,8 +126,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
133
126
|
|
|
134
127
|
# Fixed OID-scheme for (Huawei) Euler OS OIDs
|
|
135
128
|
euler_sa_match = re.search(
|
|
136
|
-
r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.2\.20[0-4][0-9]\.[0-9]{"
|
|
137
|
-
r"4}$",
|
|
129
|
+
r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.2\.20[0-4][0-9]\.[0-9]{" r"4}$",
|
|
138
130
|
oid,
|
|
139
131
|
)
|
|
140
132
|
if euler_sa_match is None:
|
|
@@ -150,8 +142,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
150
142
|
elif vendor_number == "4":
|
|
151
143
|
if family != f"SuSE {family_template}":
|
|
152
144
|
yield LinterError(
|
|
153
|
-
f"script_oid() {is_using_reserved} SUSE SLES "
|
|
154
|
-
f"'{str(oid)}'",
|
|
145
|
+
f"script_oid() {is_using_reserved} SUSE SLES '{str(oid)}'",
|
|
155
146
|
file=nasl_file,
|
|
156
147
|
plugin=self.name,
|
|
157
148
|
)
|
|
@@ -159,8 +150,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
159
150
|
|
|
160
151
|
# Fixed OID-scheme for SUSE SLES OS OIDs
|
|
161
152
|
sles_sa_match = re.search(
|
|
162
|
-
r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.4\.20[0-4][0-9]\.[0-9]{"
|
|
163
|
-
r"4,5}\.[0-9]$",
|
|
153
|
+
r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.4\.20[0-4][0-9]\.[0-9]{" r"4,5}\.[0-9]$",
|
|
164
154
|
oid,
|
|
165
155
|
)
|
|
166
156
|
if sles_sa_match is None:
|
|
@@ -176,8 +166,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
176
166
|
elif vendor_number == "5":
|
|
177
167
|
if family != f"Amazon Linux {family_template}":
|
|
178
168
|
yield LinterError(
|
|
179
|
-
f"script_oid() {is_using_reserved} Amazon Linux "
|
|
180
|
-
f"'{str(oid)}'",
|
|
169
|
+
f"script_oid() {is_using_reserved} Amazon Linux '{str(oid)}'",
|
|
181
170
|
file=nasl_file,
|
|
182
171
|
plugin=self.name,
|
|
183
172
|
)
|
|
@@ -200,8 +189,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
200
189
|
elif vendor_number == "6":
|
|
201
190
|
if family != f"Gentoo {family_template}":
|
|
202
191
|
yield LinterError(
|
|
203
|
-
f"script_oid() {is_using_reserved} Gentoo "
|
|
204
|
-
f"'{str(oid)}'",
|
|
192
|
+
f"script_oid() {is_using_reserved} Gentoo '{str(oid)}'",
|
|
205
193
|
file=nasl_file,
|
|
206
194
|
plugin=self.name,
|
|
207
195
|
)
|
|
@@ -210,8 +198,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
210
198
|
elif vendor_number == "7":
|
|
211
199
|
if family != "FreeBSD Local Security Checks":
|
|
212
200
|
yield LinterError(
|
|
213
|
-
f"script_oid() {is_using_reserved} FreeBSD "
|
|
214
|
-
f"'{str(oid)}'",
|
|
201
|
+
f"script_oid() {is_using_reserved} FreeBSD '{str(oid)}'",
|
|
215
202
|
file=nasl_file,
|
|
216
203
|
plugin=self.name,
|
|
217
204
|
)
|
|
@@ -220,8 +207,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
220
207
|
elif vendor_number == "8":
|
|
221
208
|
if family != f"Oracle Linux {family_template}":
|
|
222
209
|
yield LinterError(
|
|
223
|
-
f"script_oid() {is_using_reserved} Oracle Linux "
|
|
224
|
-
f"'{str(oid)}'",
|
|
210
|
+
f"script_oid() {is_using_reserved} Oracle Linux '{str(oid)}'",
|
|
225
211
|
file=nasl_file,
|
|
226
212
|
plugin=self.name,
|
|
227
213
|
)
|
|
@@ -230,8 +216,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
230
216
|
elif vendor_number == "9":
|
|
231
217
|
if family != f"Fedora {family_template}":
|
|
232
218
|
yield LinterError(
|
|
233
|
-
f"script_oid() {is_using_reserved} Fedora "
|
|
234
|
-
f"'{str(oid)}'",
|
|
219
|
+
f"script_oid() {is_using_reserved} Fedora '{str(oid)}'",
|
|
235
220
|
file=nasl_file,
|
|
236
221
|
plugin=self.name,
|
|
237
222
|
)
|
|
@@ -240,16 +225,14 @@ class CheckValidOID(FileContentPlugin):
|
|
|
240
225
|
elif vendor_number == "10":
|
|
241
226
|
if family != f"Mageia Linux {family_template}":
|
|
242
227
|
yield LinterError(
|
|
243
|
-
f"script_oid() {is_using_reserved} Mageia Linux "
|
|
244
|
-
f"'{str(oid)}'",
|
|
228
|
+
f"script_oid() {is_using_reserved} Mageia Linux '{str(oid)}'",
|
|
245
229
|
file=nasl_file,
|
|
246
230
|
plugin=self.name,
|
|
247
231
|
)
|
|
248
232
|
return
|
|
249
233
|
|
|
250
234
|
mageia_sa_match = re.search(
|
|
251
|
-
r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.10\.20[0-4][0-9]\.["
|
|
252
|
-
r"0-9]{4}$",
|
|
235
|
+
r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.10\.20[0-4][0-9]\.[" r"0-9]{4}$",
|
|
253
236
|
oid,
|
|
254
237
|
)
|
|
255
238
|
if mageia_sa_match is None:
|
|
@@ -265,8 +248,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
265
248
|
elif vendor_number == "11":
|
|
266
249
|
if family != f"Red Hat {family_template}":
|
|
267
250
|
yield LinterError(
|
|
268
|
-
f"script_oid() {is_using_reserved} Red Hat "
|
|
269
|
-
f"'{str(oid)}'",
|
|
251
|
+
f"script_oid() {is_using_reserved} Red Hat '{str(oid)}'",
|
|
270
252
|
file=nasl_file,
|
|
271
253
|
plugin=self.name,
|
|
272
254
|
)
|
|
@@ -275,8 +257,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
275
257
|
elif vendor_number == "12":
|
|
276
258
|
if family != f"Ubuntu {family_template}":
|
|
277
259
|
yield LinterError(
|
|
278
|
-
f"script_oid() {is_using_reserved} Ubuntu "
|
|
279
|
-
f"'{str(oid)}'",
|
|
260
|
+
f"script_oid() {is_using_reserved} Ubuntu '{str(oid)}'",
|
|
280
261
|
file=nasl_file,
|
|
281
262
|
plugin=self.name,
|
|
282
263
|
)
|
|
@@ -284,15 +265,11 @@ class CheckValidOID(FileContentPlugin):
|
|
|
284
265
|
|
|
285
266
|
elif vendor_number == "13":
|
|
286
267
|
if family != f"Slackware {family_template}":
|
|
287
|
-
yield LinterError(
|
|
288
|
-
f"script_oid() {is_using_reserved} Slackware "
|
|
289
|
-
f"'{str(oid)}'"
|
|
290
|
-
)
|
|
268
|
+
yield LinterError(f"script_oid() {is_using_reserved} Slackware '{str(oid)}'")
|
|
291
269
|
return
|
|
292
270
|
|
|
293
271
|
slackware_sa_match = re.search(
|
|
294
|
-
r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.13\.20[0-4][0-9]\.[0-9]"
|
|
295
|
-
r"{3,4}\.[0-9]{2}$",
|
|
272
|
+
r"^1\.3\.6\.1\.4\.1\.25623\.1\.1\.13\.20[0-4][0-9]\.[0-9]" r"{3,4}\.[0-9]{2}$",
|
|
296
273
|
oid,
|
|
297
274
|
)
|
|
298
275
|
if slackware_sa_match is None:
|
|
@@ -306,8 +283,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
306
283
|
elif vendor_number == "14":
|
|
307
284
|
if family != f"Rocky Linux {family_template}":
|
|
308
285
|
yield LinterError(
|
|
309
|
-
f"script_oid() {is_using_reserved} Rocky Linux "
|
|
310
|
-
f"'{str(oid)}'",
|
|
286
|
+
f"script_oid() {is_using_reserved} Rocky Linux '{str(oid)}'",
|
|
311
287
|
file=nasl_file,
|
|
312
288
|
plugin=self.name,
|
|
313
289
|
)
|
|
@@ -316,8 +292,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
316
292
|
elif vendor_number == "15":
|
|
317
293
|
if family != f"AlmaLinux {family_template}":
|
|
318
294
|
yield LinterError(
|
|
319
|
-
f"script_oid() {is_using_reserved} AlmaLinux "
|
|
320
|
-
f"'{str(oid)}'",
|
|
295
|
+
f"script_oid() {is_using_reserved} AlmaLinux '{str(oid)}'",
|
|
321
296
|
file=nasl_file,
|
|
322
297
|
plugin=self.name,
|
|
323
298
|
)
|
|
@@ -325,8 +300,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
325
300
|
elif vendor_number == "18":
|
|
326
301
|
if family != f"openSUSE {family_template}":
|
|
327
302
|
yield LinterError(
|
|
328
|
-
f"script_oid() {is_using_reserved} openSUSE "
|
|
329
|
-
f"'{str(oid)}'",
|
|
303
|
+
f"script_oid() {is_using_reserved} openSUSE '{str(oid)}'",
|
|
330
304
|
file=nasl_file,
|
|
331
305
|
plugin=self.name,
|
|
332
306
|
)
|
|
@@ -361,16 +335,14 @@ class CheckValidOID(FileContentPlugin):
|
|
|
361
335
|
if "1.3.6.1.4.1.25623.1.2.1." in oid:
|
|
362
336
|
if not name.startswith(f"Mozilla Firefox {security_template}"):
|
|
363
337
|
yield LinterError(
|
|
364
|
-
f"script_oid() {is_using_reserved} 'Firefox' ("
|
|
365
|
-
f"{str(oid)})",
|
|
338
|
+
f"script_oid() {is_using_reserved} 'Firefox' ({str(oid)})",
|
|
366
339
|
file=nasl_file,
|
|
367
340
|
plugin=self.name,
|
|
368
341
|
)
|
|
369
342
|
return
|
|
370
343
|
|
|
371
344
|
firefox_sa_match = re.search(
|
|
372
|
-
r"^1\.3\.6\.1\.4\.1\.25623\.1\.2\.1\.20[1-4][0-9]\.[0-9]{"
|
|
373
|
-
r"2,3}$",
|
|
345
|
+
r"^1\.3\.6\.1\.4\.1\.25623\.1\.2\.1\.20[1-4][0-9]\.[0-9]{" r"2,3}$",
|
|
374
346
|
oid,
|
|
375
347
|
)
|
|
376
348
|
if not firefox_sa_match:
|
|
@@ -389,8 +361,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
389
361
|
if "1.3.6.1.4.1.25623.1.3." in oid:
|
|
390
362
|
if family_match.group("value") != f"Windows {family_template}":
|
|
391
363
|
yield LinterError(
|
|
392
|
-
f"script_oid() {is_using_reserved} 'Windows' ("
|
|
393
|
-
f"{str(oid)})",
|
|
364
|
+
f"script_oid() {is_using_reserved} 'Windows' ({str(oid)})",
|
|
394
365
|
file=nasl_file,
|
|
395
366
|
plugin=self.name,
|
|
396
367
|
)
|
|
@@ -411,9 +382,31 @@ class CheckValidOID(FileContentPlugin):
|
|
|
411
382
|
return
|
|
412
383
|
return
|
|
413
384
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
385
|
+
# Fixed OID-scheme for Compliance OIDs
|
|
386
|
+
if "1.3.6.1.4.1.25623.1.4." in oid:
|
|
387
|
+
if family_match.group("value") != "Policy":
|
|
388
|
+
yield LinterError(
|
|
389
|
+
f"script_oid() {is_using_reserved} 'Policy & Compliance' ({str(oid)})",
|
|
390
|
+
file=nasl_file,
|
|
391
|
+
plugin=self.name,
|
|
392
|
+
)
|
|
393
|
+
return
|
|
394
|
+
|
|
395
|
+
compliance_oid_match = re.search(
|
|
396
|
+
r"^1\.3\.6\.1\.4\.1\.25623\.1\.4\.[0-4](\.\d+)+",
|
|
397
|
+
oid,
|
|
398
|
+
)
|
|
399
|
+
if not compliance_oid_match:
|
|
400
|
+
yield LinterError(
|
|
401
|
+
f"script_oid() {invalid_oid} '{str(oid)}' "
|
|
402
|
+
"(Compliance pattern: 1.3.6.1.4.1.25623.1.4.[0-4]",
|
|
403
|
+
file=nasl_file,
|
|
404
|
+
plugin=self.name,
|
|
405
|
+
)
|
|
406
|
+
return
|
|
407
|
+
return
|
|
408
|
+
|
|
409
|
+
oid_digit_match = re.search(r"^1\.3\.6\.1\.4\.1\.25623\.1\.0\.([0-9]+)", oid)
|
|
417
410
|
if oid_digit_match is None or oid_digit_match.group(1) is None:
|
|
418
411
|
yield LinterError(
|
|
419
412
|
f"script_oid() {invalid_oid} '{str(oid)}' (last digits)",
|
|
@@ -424,8 +417,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
424
417
|
|
|
425
418
|
exceptions = [
|
|
426
419
|
"ossim_server_detect.nasl",
|
|
427
|
-
"gsf/2018/vmware/gb_vmware_fusion_vmxnet3_"
|
|
428
|
-
+ "stack_memory_usage_vuln_macosx.nasl",
|
|
420
|
+
"gsf/2018/vmware/gb_vmware_fusion_vmxnet3_" + "stack_memory_usage_vuln_macosx.nasl",
|
|
429
421
|
"2008/asterisk_sdp_header_overflow.nasl",
|
|
430
422
|
"2008/cisco_ios_ftp_server_auth_bypass.nasl",
|
|
431
423
|
"2008/qk_smtp_server_dos.nasl",
|
|
@@ -465,8 +457,7 @@ class CheckValidOID(FileContentPlugin):
|
|
|
465
457
|
return
|
|
466
458
|
|
|
467
459
|
yield LinterError(
|
|
468
|
-
f"script_oid() {invalid_oid} "
|
|
469
|
-
f"'{str(oid)}' (unassigned OID range)",
|
|
460
|
+
f"script_oid() {invalid_oid} '{str(oid)}' (unassigned OID range)",
|
|
470
461
|
file=nasl_file,
|
|
471
462
|
plugin=self.name,
|
|
472
463
|
)
|
|
@@ -88,16 +88,13 @@ class CheckValidScriptTagNames(FileContentPlugin):
|
|
|
88
88
|
"solution_method",
|
|
89
89
|
]
|
|
90
90
|
|
|
91
|
-
matches = _get_tag_pattern(name=r".+?", flags=re.S).finditer(
|
|
92
|
-
file_content
|
|
93
|
-
)
|
|
91
|
+
matches = _get_tag_pattern(name=r".+?", flags=re.S).finditer(file_content)
|
|
94
92
|
|
|
95
93
|
if matches:
|
|
96
94
|
for match in matches:
|
|
97
95
|
if match.group("name") not in allowed_script_tag_names:
|
|
98
96
|
yield LinterError(
|
|
99
|
-
f"The script_tag name '{match.group('name')}' "
|
|
100
|
-
"is not allowed.",
|
|
97
|
+
f"The script_tag name '{match.group('name')}' is not allowed.",
|
|
101
98
|
file=nasl_file,
|
|
102
99
|
plugin=self.name,
|
|
103
100
|
)
|
|
@@ -57,9 +57,7 @@ class CheckVariableAssignedInIf(FileContentPlugin):
|
|
|
57
57
|
#
|
|
58
58
|
# if((foo =~ "bar || bar =~ "foo") || foobar = "foo")
|
|
59
59
|
# bar = "foo"; (no ending {)
|
|
60
|
-
matches = re.finditer(
|
|
61
|
-
r"^\s*(if|}?\s*else if)\s*\(([^)]+)", file_content, re.MULTILINE
|
|
62
|
-
)
|
|
60
|
+
matches = re.finditer(r"^\s*(if|}?\s*else if)\s*\(([^)]+)", file_content, re.MULTILINE)
|
|
63
61
|
if matches is None:
|
|
64
62
|
return
|
|
65
63
|
|
|
@@ -76,10 +74,7 @@ class CheckVariableAssignedInIf(FileContentPlugin):
|
|
|
76
74
|
r'[a-zA-Z_][a-zA-Z0-9_]*\s*=\s*("|\'|TRUE|0|1)',
|
|
77
75
|
match.group(0),
|
|
78
76
|
)
|
|
79
|
-
if (
|
|
80
|
-
var_assign_match is not None
|
|
81
|
-
and var_assign_match.group(1) is not None
|
|
82
|
-
):
|
|
77
|
+
if var_assign_match is not None and var_assign_match.group(1) is not None:
|
|
83
78
|
# nb: Can't be fixed because it would mean a change
|
|
84
79
|
# of a default behavior.
|
|
85
80
|
if (
|
|
@@ -8,17 +8,13 @@ from typing import Iterator
|
|
|
8
8
|
from troubadix.plugin import FileContentPlugin, LinterResult, LinterWarning
|
|
9
9
|
|
|
10
10
|
FOREACH_PATTERN = re.compile(r"foreach\s+(?P<ident>\w+)\s*\((?P<iter>.+)\)")
|
|
11
|
-
MAKE_LIST_PATTERN = re.compile(
|
|
12
|
-
r"^(?:make_list|make_list_unique)\((?P<params>.+)\)$"
|
|
13
|
-
)
|
|
11
|
+
MAKE_LIST_PATTERN = re.compile(r"^(?:make_list|make_list_unique)\((?P<params>.+)\)$")
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
class CheckVariableRedefinitionInForeach(FileContentPlugin):
|
|
17
15
|
name = "check_variable_redefinition_in_foreach"
|
|
18
16
|
|
|
19
|
-
def check_content(
|
|
20
|
-
self, nasl_file: Path, file_content: str
|
|
21
|
-
) -> Iterator[LinterResult]:
|
|
17
|
+
def check_content(self, nasl_file: Path, file_content: str) -> Iterator[LinterResult]:
|
|
22
18
|
"""This plugin checks for a redefinition of the variable
|
|
23
19
|
that is passed to the foreach loop.
|
|
24
20
|
This can be caused by using same variable name
|
|
@@ -71,17 +71,11 @@ class CheckVTPlacement(FileContentPlugin):
|
|
|
71
71
|
if match is not None:
|
|
72
72
|
return
|
|
73
73
|
|
|
74
|
-
if any(
|
|
75
|
-
(root / vers / nasl_file.name) == nasl_file
|
|
76
|
-
for vers in FEED_VERSIONS
|
|
77
|
-
):
|
|
74
|
+
if any((root / vers / nasl_file.name) == nasl_file for vers in FEED_VERSIONS):
|
|
78
75
|
return
|
|
79
76
|
|
|
80
77
|
for folder in chain(["attic"], ENTERPRISE_FOLDERS):
|
|
81
|
-
if any(
|
|
82
|
-
(root / vers / folder / nasl_file.name) == nasl_file
|
|
83
|
-
for vers in FEED_VERSIONS
|
|
84
|
-
):
|
|
78
|
+
if any((root / vers / folder / nasl_file.name) == nasl_file for vers in FEED_VERSIONS):
|
|
85
79
|
return
|
|
86
80
|
|
|
87
81
|
yield LinterError(
|
troubadix/reporter.py
CHANGED
|
@@ -77,9 +77,7 @@ class Reporter:
|
|
|
77
77
|
self._term.ok(message)
|
|
78
78
|
self._log_append(f"\t\t{message}".replace("\n", "\n\t\t"))
|
|
79
79
|
|
|
80
|
-
def _process_plugin_results(
|
|
81
|
-
self, plugin_name: str, plugin_results: Iterable[LinterResult]
|
|
82
|
-
):
|
|
80
|
+
def _process_plugin_results(self, plugin_name: str, plugin_results: Iterable[LinterResult]):
|
|
83
81
|
"""Process the results of a plugin: Print/Log results if
|
|
84
82
|
verbosity/logging fits and count the results"""
|
|
85
83
|
if plugin_results and self._verbose > 0:
|
|
@@ -123,9 +121,7 @@ class Reporter:
|
|
|
123
121
|
with self._term.indent():
|
|
124
122
|
self._process_plugin_results(plugin_name, plugin_results)
|
|
125
123
|
|
|
126
|
-
def report_by_file_plugin(
|
|
127
|
-
self, file_results: FileResults, pos: int
|
|
128
|
-
) -> None:
|
|
124
|
+
def report_by_file_plugin(self, file_results: FileResults, pos: int) -> None:
|
|
129
125
|
"""Print/log the results of all plugins for a specific file
|
|
130
126
|
|
|
131
127
|
Arguments:
|
|
@@ -135,12 +131,8 @@ class Reporter:
|
|
|
135
131
|
"""
|
|
136
132
|
if file_results and self._verbose > 0 or self._verbose > 1:
|
|
137
133
|
# only print the part "common/some_nasl.nasl"
|
|
138
|
-
from_root_path = get_path_from_root(
|
|
139
|
-
|
|
140
|
-
)
|
|
141
|
-
self._report_bold_info(
|
|
142
|
-
f"Checking {from_root_path} ({pos}/{self._files_count})"
|
|
143
|
-
)
|
|
134
|
+
from_root_path = get_path_from_root(file_results.file_path, self._root)
|
|
135
|
+
self._report_bold_info(f"Checking {from_root_path} ({pos}/{self._files_count})")
|
|
144
136
|
|
|
145
137
|
with self._term.indent():
|
|
146
138
|
for (
|
|
@@ -164,9 +156,7 @@ class Reporter:
|
|
|
164
156
|
if included:
|
|
165
157
|
self.report_info(f"Included Plugins: {', '.join(included)}")
|
|
166
158
|
|
|
167
|
-
self.report_info(
|
|
168
|
-
f"Running plugins: {', '.join([p.name for p in plugins])}"
|
|
169
|
-
)
|
|
159
|
+
self.report_info(f"Running plugins: {', '.join([p.name for p in plugins])}")
|
|
170
160
|
|
|
171
161
|
def report_statistic(self) -> None:
|
|
172
162
|
"""Print a Error/Warning summary from the different plugins"""
|
|
@@ -195,10 +185,7 @@ class Reporter:
|
|
|
195
185
|
if self._fix and self._ignore_warnings:
|
|
196
186
|
line = f"{plugin:48} {count['error']:8} {count['fix']:8}"
|
|
197
187
|
elif self._fix:
|
|
198
|
-
line =
|
|
199
|
-
f"{plugin:48} {count['error']:8} {count['warning']:8}"
|
|
200
|
-
f" {count['fix']:8}"
|
|
201
|
-
)
|
|
188
|
+
line = f"{plugin:48} {count['error']:8} {count['warning']:8} {count['fix']:8}"
|
|
202
189
|
elif self._ignore_warnings:
|
|
203
190
|
line = f"{plugin:48} {count['error']:8}"
|
|
204
191
|
else:
|
|
@@ -216,8 +203,7 @@ class Reporter:
|
|
|
216
203
|
|
|
217
204
|
if self._fix and self._ignore_warnings:
|
|
218
205
|
line = (
|
|
219
|
-
f"{'sum':48} {self._result_counts.error_count:8}"
|
|
220
|
-
f" {self._result_counts.fix_count:8}"
|
|
206
|
+
f"{'sum':48} {self._result_counts.error_count:8} {self._result_counts.fix_count:8}"
|
|
221
207
|
)
|
|
222
208
|
elif self._fix:
|
|
223
209
|
line = (
|
troubadix/results.py
CHANGED
|
@@ -28,15 +28,9 @@ class Results:
|
|
|
28
28
|
self.has_plugin_results = False
|
|
29
29
|
self._ignore_warnings = ignore_warnings
|
|
30
30
|
|
|
31
|
-
def add_plugin_results(
|
|
32
|
-
self, plugin_name: str, results: Iterator[LinterResult]
|
|
33
|
-
) -> "Results":
|
|
31
|
+
def add_plugin_results(self, plugin_name: str, results: Iterator[LinterResult]) -> "Results":
|
|
34
32
|
if self._ignore_warnings:
|
|
35
|
-
results = [
|
|
36
|
-
result
|
|
37
|
-
for result in results
|
|
38
|
-
if not isinstance(result, LinterWarning)
|
|
39
|
-
]
|
|
33
|
+
results = [result for result in results if not isinstance(result, LinterWarning)]
|
|
40
34
|
else:
|
|
41
35
|
results = list(results)
|
|
42
36
|
|
troubadix/runner.py
CHANGED
|
@@ -86,9 +86,7 @@ class Runner:
|
|
|
86
86
|
def _check_file(self, file_path: Path) -> FileResults:
|
|
87
87
|
"""Run all file plugins on a single file and collect the results"""
|
|
88
88
|
results = FileResults(file_path, ignore_warnings=self._ignore_warnings)
|
|
89
|
-
context = FilePluginContext(
|
|
90
|
-
root=self._root, nasl_file=file_path.resolve()
|
|
91
|
-
)
|
|
89
|
+
context = FilePluginContext(root=self._root, nasl_file=file_path.resolve())
|
|
92
90
|
|
|
93
91
|
for plugin_class in self.plugins.file_plugins:
|
|
94
92
|
plugin = plugin_class(context)
|
|
@@ -105,8 +103,7 @@ class Runner:
|
|
|
105
103
|
# run files plugins
|
|
106
104
|
context = FilesPluginContext(root=self._root, nasl_files=files)
|
|
107
105
|
files_plugins = [
|
|
108
|
-
plugin_class(context)
|
|
109
|
-
for plugin_class in self.plugins.files_plugins
|
|
106
|
+
plugin_class(context) for plugin_class in self.plugins.files_plugins
|
|
110
107
|
]
|
|
111
108
|
|
|
112
109
|
for results in pool.imap_unordered(
|
|
@@ -116,14 +113,10 @@ class Runner:
|
|
|
116
113
|
|
|
117
114
|
# run file plugins
|
|
118
115
|
for i, results in enumerate(
|
|
119
|
-
iterable=pool.imap_unordered(
|
|
120
|
-
self._check_file, files, chunksize=CHUNKSIZE
|
|
121
|
-
),
|
|
116
|
+
iterable=pool.imap_unordered(self._check_file, files, chunksize=CHUNKSIZE),
|
|
122
117
|
start=1,
|
|
123
118
|
):
|
|
124
|
-
self._reporter.report_by_file_plugin(
|
|
125
|
-
file_results=results, pos=i
|
|
126
|
-
)
|
|
119
|
+
self._reporter.report_by_file_plugin(file_results=results, pos=i)
|
|
127
120
|
|
|
128
121
|
except KeyboardInterrupt:
|
|
129
122
|
pool.terminate()
|
|
@@ -145,9 +138,7 @@ class Runner:
|
|
|
145
138
|
start = datetime.datetime.now()
|
|
146
139
|
self._run_pooled(files)
|
|
147
140
|
|
|
148
|
-
self._reporter.report_info(
|
|
149
|
-
f"Time elapsed: {datetime.datetime.now() - start}"
|
|
150
|
-
)
|
|
141
|
+
self._reporter.report_info(f"Time elapsed: {datetime.datetime.now() - start}")
|
|
151
142
|
self._reporter.report_statistic()
|
|
152
143
|
|
|
153
144
|
# Return true if no error exists
|
|
@@ -29,8 +29,7 @@ def parse_arguments() -> Namespace:
|
|
|
29
29
|
"--directory",
|
|
30
30
|
default=Path.cwd(),
|
|
31
31
|
type=Path,
|
|
32
|
-
help="The directory the repository to check is located in. "
|
|
33
|
-
"Defaults to 'pwd'",
|
|
32
|
+
help="The directory the repository to check is located in. Defaults to 'pwd'",
|
|
34
33
|
)
|
|
35
34
|
|
|
36
35
|
ignored_linestart_group = argument_parser.add_mutually_exclusive_group()
|
|
@@ -42,8 +41,7 @@ def parse_arguments() -> Namespace:
|
|
|
42
41
|
nargs="*",
|
|
43
42
|
type=str,
|
|
44
43
|
default=DEFAULT_IGNORED_LINESTARTS,
|
|
45
|
-
help="A list of line starts which will make the line be ignored. "
|
|
46
|
-
"Default: %(default)s",
|
|
44
|
+
help="A list of line starts which will make the line be ignored. Default: %(default)s",
|
|
47
45
|
)
|
|
48
46
|
|
|
49
47
|
ignored_linestart_group.add_argument(
|
|
@@ -73,9 +71,7 @@ def parse_arguments() -> Namespace:
|
|
|
73
71
|
"to check the diff for",
|
|
74
72
|
)
|
|
75
73
|
|
|
76
|
-
argument_parser.add_argument(
|
|
77
|
-
"-s", "--source", type=str, required=True, help="The upstream rev"
|
|
78
|
-
)
|
|
74
|
+
argument_parser.add_argument("-s", "--source", type=str, required=True, help="The upstream rev")
|
|
79
75
|
|
|
80
76
|
argument_parser.add_argument(
|
|
81
77
|
"-t", "--target", type=str, required=True, help="The downstream rev"
|
|
@@ -84,14 +80,8 @@ def parse_arguments() -> Namespace:
|
|
|
84
80
|
return argument_parser.parse_args()
|
|
85
81
|
|
|
86
82
|
|
|
87
|
-
def check_diff_line_starts_with_ignored_linestart(
|
|
88
|
-
|
|
89
|
-
) -> bool:
|
|
90
|
-
return any(
|
|
91
|
-
linestart
|
|
92
|
-
for linestart in ignored_linestarts
|
|
93
|
-
if line.startswith(linestart)
|
|
94
|
-
)
|
|
83
|
+
def check_diff_line_starts_with_ignored_linestart(line: str, ignored_linestarts: List[str]) -> bool:
|
|
84
|
+
return any(linestart for linestart in ignored_linestarts if line.startswith(linestart))
|
|
95
85
|
|
|
96
86
|
|
|
97
87
|
def check_diff_line_matches_pattern(line: str, patterns: List[Pattern]) -> bool:
|
|
@@ -104,9 +94,7 @@ def check_diff(
|
|
|
104
94
|
return [
|
|
105
95
|
line
|
|
106
96
|
for line in lines
|
|
107
|
-
if not check_diff_line_starts_with_ignored_linestart(
|
|
108
|
-
line, ignored_linestarts
|
|
109
|
-
)
|
|
97
|
+
if not check_diff_line_starts_with_ignored_linestart(line, ignored_linestarts)
|
|
110
98
|
and not check_diff_line_matches_pattern(line, patterns)
|
|
111
99
|
]
|
|
112
100
|
|
|
@@ -121,10 +109,7 @@ def read_ignored_linestarts(path: Path) -> List[str]:
|
|
|
121
109
|
|
|
122
110
|
def read_patterns(path: Path) -> List[Pattern]:
|
|
123
111
|
with open(path, "r", encoding="UTF-8") as file:
|
|
124
|
-
return [
|
|
125
|
-
re.compile(pattern.removesuffix("\n"))
|
|
126
|
-
for pattern in file.readlines()
|
|
127
|
-
]
|
|
112
|
+
return [re.compile(pattern.removesuffix("\n")) for pattern in file.readlines()]
|
|
128
113
|
|
|
129
114
|
|
|
130
115
|
def main() -> int:
|
|
@@ -140,9 +125,7 @@ def main() -> int:
|
|
|
140
125
|
|
|
141
126
|
diff = repo.git.diff(target, merge_base, unified=0)
|
|
142
127
|
|
|
143
|
-
result = check_diff(
|
|
144
|
-
diff.splitlines(), arguments.ignored_linestarts, patterns
|
|
145
|
-
)
|
|
128
|
+
result = check_diff(diff.splitlines(), arguments.ignored_linestarts, patterns)
|
|
146
129
|
|
|
147
130
|
if result:
|
|
148
131
|
print("The following lines don't match the any pattern:")
|
|
@@ -21,7 +21,6 @@ CREATION_DATE_BASE_PATTERN = (
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def parse_arguments() -> Namespace:
|
|
24
|
-
|
|
25
24
|
parser = ArgumentParser(
|
|
26
25
|
description="Check for changed creation date",
|
|
27
26
|
)
|
|
@@ -43,8 +42,7 @@ def parse_arguments() -> Namespace:
|
|
|
43
42
|
type=file_type_existing,
|
|
44
43
|
default=[],
|
|
45
44
|
help=(
|
|
46
|
-
"List of files to diff. "
|
|
47
|
-
"If empty use all files added or modified in the commit range."
|
|
45
|
+
"List of files to diff. If empty use all files added or modified in the commit range."
|
|
48
46
|
),
|
|
49
47
|
)
|
|
50
48
|
args = parser.parse_args()
|
|
@@ -61,9 +59,7 @@ def parse_arguments() -> Namespace:
|
|
|
61
59
|
return args
|
|
62
60
|
|
|
63
61
|
|
|
64
|
-
def check_changed_creation_date(
|
|
65
|
-
commit_range: str, nasl_files: list[Path]
|
|
66
|
-
) -> bool:
|
|
62
|
+
def check_changed_creation_date(commit_range: str, nasl_files: list[Path]) -> bool:
|
|
67
63
|
"""
|
|
68
64
|
This script checks (via git diff) if the creation date of
|
|
69
65
|
passed VTs has changed, which is not allowed.
|
|
@@ -71,7 +67,6 @@ def check_changed_creation_date(
|
|
|
71
67
|
creation_date_changed = False
|
|
72
68
|
|
|
73
69
|
for nasl_file in nasl_files:
|
|
74
|
-
|
|
75
70
|
if not nasl_file.exists():
|
|
76
71
|
continue
|
|
77
72
|
|
|
@@ -90,9 +85,7 @@ def check_changed_creation_date(
|
|
|
90
85
|
text,
|
|
91
86
|
re.MULTILINE,
|
|
92
87
|
)
|
|
93
|
-
if not creation_date_added or not (
|
|
94
|
-
added := creation_date_added.group("creation_date")
|
|
95
|
-
):
|
|
88
|
+
if not creation_date_added or not (added := creation_date_added.group("creation_date")):
|
|
96
89
|
continue
|
|
97
90
|
|
|
98
91
|
creation_date_removed = re.search(
|
|
@@ -120,14 +113,11 @@ def check_changed_creation_date(
|
|
|
120
113
|
|
|
121
114
|
|
|
122
115
|
def main() -> int:
|
|
123
|
-
|
|
124
116
|
try:
|
|
125
117
|
git_base = git("rev-parse", "--show-toplevel")
|
|
126
118
|
os.chdir(git_base.rstrip("\n"))
|
|
127
119
|
except subprocess.SubprocessError:
|
|
128
|
-
logger.error(
|
|
129
|
-
"Your current working directory doesn't belong to a git repository"
|
|
130
|
-
)
|
|
120
|
+
logger.error("Your current working directory doesn't belong to a git repository")
|
|
131
121
|
return 1
|
|
132
122
|
|
|
133
123
|
args = parse_arguments()
|