troubadix 25.12.4__py3-none-any.whl → 26.1.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 -7
- 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 +1 -2
- troubadix/plugins/double_end_points.py +2 -7
- troubadix/plugins/duplicate_oid.py +1 -3
- troubadix/plugins/forking_nasl_functions.py +1 -4
- troubadix/plugins/get_kb_on_services.py +2 -4
- troubadix/plugins/grammar.py +6 -16
- troubadix/plugins/http_links_in_tags.py +1 -3
- troubadix/plugins/illegal_characters.py +5 -13
- 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 -6
- troubadix/plugins/newlines.py +1 -2
- troubadix/plugins/overlong_description_lines.py +2 -6
- troubadix/plugins/prod_svc_detect_in_vulnvt.py +1 -4
- 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 +4 -8
- 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 +6 -17
- troubadix/plugins/severity_date.py +3 -9
- troubadix/plugins/severity_format.py +1 -3
- troubadix/plugins/severity_origin.py +1 -3
- troubadix/plugins/solution_text.py +6 -10
- troubadix/plugins/solution_type.py +1 -2
- troubadix/plugins/spaces_before_dots.py +2 -8
- 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 +6 -19
- 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 +3 -9
- troubadix/standalone_plugins/changed_cves.py +4 -12
- troubadix/standalone_plugins/changed_oid.py +2 -6
- 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 +2 -5
- 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 -32
- troubadix/standalone_plugins/version_updated.py +4 -12
- troubadix/troubadix.py +1 -4
- {troubadix-25.12.4.dist-info → troubadix-26.1.0.dist-info}/METADATA +1 -1
- troubadix-26.1.0.dist-info/RECORD +116 -0
- troubadix-25.12.4.dist-info/RECORD +0 -116
- {troubadix-25.12.4.dist-info → troubadix-26.1.0.dist-info}/WHEEL +0 -0
- {troubadix-25.12.4.dist-info → troubadix-26.1.0.dist-info}/entry_points.txt +0 -0
- {troubadix-25.12.4.dist-info → troubadix-26.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -36,8 +36,7 @@ def _file_contains_security_message(file_content: str) -> bool:
|
|
|
36
36
|
file_content (str): The content of the VT
|
|
37
37
|
"""
|
|
38
38
|
return any(
|
|
39
|
-
security_message in file_content
|
|
40
|
-
for security_message in SECURITY_MESSAGE_IMPLEMENTATIONS
|
|
39
|
+
security_message in file_content for security_message in SECURITY_MESSAGE_IMPLEMENTATIONS
|
|
41
40
|
)
|
|
42
41
|
|
|
43
42
|
|
|
@@ -54,9 +53,7 @@ class CheckSecurityMessages(FileContentPlugin):
|
|
|
54
53
|
nasl_file (Path): The VTs path
|
|
55
54
|
file_content (str): The content of the VT
|
|
56
55
|
"""
|
|
57
|
-
deprecated_pattern = get_script_tag_pattern(
|
|
58
|
-
script_tag=ScriptTag.DEPRECATED
|
|
59
|
-
)
|
|
56
|
+
deprecated_pattern = get_script_tag_pattern(script_tag=ScriptTag.DEPRECATED)
|
|
60
57
|
if deprecated_pattern.search(file_content):
|
|
61
58
|
return
|
|
62
59
|
|
|
@@ -90,9 +87,7 @@ class CheckSecurityMessages(FileContentPlugin):
|
|
|
90
87
|
plugin=self.name,
|
|
91
88
|
)
|
|
92
89
|
|
|
93
|
-
def _determinate_security_message_by_severity(
|
|
94
|
-
self, file_content: str
|
|
95
|
-
) -> bool:
|
|
90
|
+
def _determinate_security_message_by_severity(self, file_content: str) -> bool:
|
|
96
91
|
"""Determinates wether a VT requires a
|
|
97
92
|
security_message or implementing function
|
|
98
93
|
call
|
|
@@ -122,15 +117,9 @@ class CheckSecurityMessages(FileContentPlugin):
|
|
|
122
117
|
if nasl_file.suffix == ".inc":
|
|
123
118
|
return
|
|
124
119
|
|
|
125
|
-
security_message_required = (
|
|
126
|
-
self._determinate_security_message_by_severity(file_content)
|
|
127
|
-
)
|
|
120
|
+
security_message_required = self._determinate_security_message_by_severity(file_content)
|
|
128
121
|
|
|
129
122
|
if security_message_required:
|
|
130
|
-
yield from self._check_security_message_present(
|
|
131
|
-
nasl_file, file_content
|
|
132
|
-
)
|
|
123
|
+
yield from self._check_security_message_present(nasl_file, file_content)
|
|
133
124
|
else:
|
|
134
|
-
yield from self._check_security_message_absent(
|
|
135
|
-
nasl_file, file_content
|
|
136
|
-
)
|
|
125
|
+
yield from self._check_security_message_absent(nasl_file, file_content)
|
|
@@ -25,13 +25,9 @@ class CheckSeverityDate(FileContentPlugin):
|
|
|
25
25
|
return
|
|
26
26
|
|
|
27
27
|
severity_date_pattern = get_script_tag_pattern(ScriptTag.SEVERITY_DATE)
|
|
28
|
-
last_modification_pattern = get_script_tag_pattern(
|
|
29
|
-
ScriptTag.LAST_MODIFICATION
|
|
30
|
-
)
|
|
28
|
+
last_modification_pattern = get_script_tag_pattern(ScriptTag.LAST_MODIFICATION)
|
|
31
29
|
|
|
32
|
-
if not (
|
|
33
|
-
match_severity_date := severity_date_pattern.search(file_content)
|
|
34
|
-
):
|
|
30
|
+
if not (match_severity_date := severity_date_pattern.search(file_content)):
|
|
35
31
|
return
|
|
36
32
|
|
|
37
33
|
yield from check_date(
|
|
@@ -41,9 +37,7 @@ class CheckSeverityDate(FileContentPlugin):
|
|
|
41
37
|
self.name,
|
|
42
38
|
)
|
|
43
39
|
|
|
44
|
-
if match_last_mod_date := last_modification_pattern.search(
|
|
45
|
-
file_content
|
|
46
|
-
):
|
|
40
|
+
if match_last_mod_date := last_modification_pattern.search(file_content):
|
|
47
41
|
yield from compare_date_with_last_modification_date(
|
|
48
42
|
match_severity_date.group("value"),
|
|
49
43
|
"severity_date",
|
|
@@ -20,9 +20,7 @@ class CheckSeverityFormat(FileContentPlugin):
|
|
|
20
20
|
if nasl_file.suffix == ".inc" or "severity_vector" not in file_content:
|
|
21
21
|
return
|
|
22
22
|
|
|
23
|
-
severity_vector_pattern = get_script_tag_pattern(
|
|
24
|
-
ScriptTag.SEVERITY_VECTOR
|
|
25
|
-
)
|
|
23
|
+
severity_vector_pattern = get_script_tag_pattern(ScriptTag.SEVERITY_VECTOR)
|
|
26
24
|
|
|
27
25
|
severity_vector_match = severity_vector_pattern.search(file_content)
|
|
28
26
|
if not severity_vector_match:
|
|
@@ -20,9 +20,7 @@ class CheckSeverityOrigin(FileContentPlugin):
|
|
|
20
20
|
if nasl_file.suffix == ".inc" or "severity_origin" not in file_content:
|
|
21
21
|
return
|
|
22
22
|
|
|
23
|
-
severity_origin_pattern = get_script_tag_pattern(
|
|
24
|
-
ScriptTag.SEVERITY_ORIGIN
|
|
25
|
-
)
|
|
23
|
+
severity_origin_pattern = get_script_tag_pattern(ScriptTag.SEVERITY_ORIGIN)
|
|
26
24
|
|
|
27
25
|
severity_origin_match = severity_origin_pattern.search(file_content)
|
|
28
26
|
if not severity_origin_match:
|
|
@@ -98,11 +98,9 @@ class CheckSolutionText(FilePlugin):
|
|
|
98
98
|
)
|
|
99
99
|
file_content = self.context.file_content
|
|
100
100
|
|
|
101
|
-
if _get_tag_pattern(
|
|
102
|
-
|
|
103
|
-
)
|
|
104
|
-
correct_none_available_pattern, file_content
|
|
105
|
-
):
|
|
101
|
+
if _get_tag_pattern(name=ScriptTag.SOLUTION_TYPE.value, value="NoneAvailable").search(
|
|
102
|
+
file_content
|
|
103
|
+
) and not re.search(correct_none_available_pattern, file_content):
|
|
106
104
|
yield LinterError(
|
|
107
105
|
"The VT with solution type 'NoneAvailable' is using an "
|
|
108
106
|
"incorrect syntax in the solution text. Please use "
|
|
@@ -110,11 +108,9 @@ class CheckSolutionText(FilePlugin):
|
|
|
110
108
|
file=self.context.nasl_file,
|
|
111
109
|
plugin=self.name,
|
|
112
110
|
)
|
|
113
|
-
elif _get_tag_pattern(
|
|
114
|
-
|
|
115
|
-
)
|
|
116
|
-
correct_will_not_fix_pattern, file_content
|
|
117
|
-
):
|
|
111
|
+
elif _get_tag_pattern(name=ScriptTag.SOLUTION_TYPE.value, value="WillNotFix").search(
|
|
112
|
+
file_content
|
|
113
|
+
) and not re.search(correct_will_not_fix_pattern, file_content):
|
|
118
114
|
yield LinterError(
|
|
119
115
|
"The VT with solution type 'WillNotFix' is using an incorrect "
|
|
120
116
|
"syntax in the solution text. Please use one of these "
|
|
@@ -53,8 +53,7 @@ class CheckSolutionType(FileContentPlugin):
|
|
|
53
53
|
|
|
54
54
|
has_severity = True
|
|
55
55
|
cvss_detect = re.search(
|
|
56
|
-
r"script_tag\s*\(name\s*:\s*\"cvss_base\","
|
|
57
|
-
r"\s*value:\s*\"(\d{1,2}\.\d)\"\)",
|
|
56
|
+
r"script_tag\s*\(name\s*:\s*\"cvss_base\"," r"\s*value:\s*\"(\d{1,2}\.\d)\"\)",
|
|
58
57
|
file_content,
|
|
59
58
|
)
|
|
60
59
|
if cvss_detect is not None and cvss_detect.group(1) == "0.0":
|
|
@@ -71,9 +71,7 @@ IGNORE = [
|
|
|
71
71
|
class CheckSpacesBeforeDots(FileContentPlugin):
|
|
72
72
|
name = "check_spaces_before_dots"
|
|
73
73
|
|
|
74
|
-
def check_content(
|
|
75
|
-
self, nasl_file: Path, file_content: str
|
|
76
|
-
) -> Iterator[LinterResult]:
|
|
74
|
+
def check_content(self, nasl_file: Path, file_content: str) -> Iterator[LinterResult]:
|
|
77
75
|
"""
|
|
78
76
|
This plugin checks for excess whitespace before a dot
|
|
79
77
|
in script_tags that have full sentence values
|
|
@@ -114,11 +112,7 @@ class CheckSpacesBeforeDots(FileContentPlugin):
|
|
|
114
112
|
for pos, match_str in self.matches:
|
|
115
113
|
# Replace the match by removing the excess whitespace before the dot
|
|
116
114
|
fixed_str = re.sub(r"\s+\.", ".", match_str)
|
|
117
|
-
file_content = (
|
|
118
|
-
file_content[:pos]
|
|
119
|
-
+ fixed_str
|
|
120
|
-
+ file_content[pos + len(match_str) :]
|
|
121
|
-
)
|
|
115
|
+
file_content = file_content[:pos] + fixed_str + file_content[pos + len(match_str) :]
|
|
122
116
|
|
|
123
117
|
with open(self.context.nasl_file, "w", encoding=CURRENT_ENCODING) as f:
|
|
124
118
|
f.write(file_content)
|
|
@@ -13,8 +13,7 @@ class CheckSpacesInFilename(FilePlugin):
|
|
|
13
13
|
def run(self) -> Iterator[LinterResult]:
|
|
14
14
|
if re.search(r"\s", self.context.nasl_file.name):
|
|
15
15
|
yield LinterError(
|
|
16
|
-
f"The VT {self.context.nasl_file}"
|
|
17
|
-
" contains whitespace in the filename",
|
|
16
|
+
f"The VT {self.context.nasl_file}" " contains whitespace in the filename",
|
|
18
17
|
file=self.context.nasl_file,
|
|
19
18
|
plugin=self.name,
|
|
20
19
|
)
|
troubadix/plugins/spelling.py
CHANGED
|
@@ -48,9 +48,7 @@ exceptions = [
|
|
|
48
48
|
# Same for a few other files:
|
|
49
49
|
PatternInFileCheck("smtp_AV_42zip_DoS.nasl", r"BA\s+==>\s+BY, BE"),
|
|
50
50
|
PatternInFileCheck("bad_ssh_host_keys.inc", r"ba\s+==>\s+by, be"),
|
|
51
|
-
PatternsInFileCheck(
|
|
52
|
-
"wmi_misc.inc", [r"BA\s+==>\s+BY, BE", r"OD\s+==>\s+OF"]
|
|
53
|
-
),
|
|
51
|
+
PatternsInFileCheck("wmi_misc.inc", [r"BA\s+==>\s+BY, BE", r"OD\s+==>\s+OF"]),
|
|
54
52
|
PatternInFilesCheck(
|
|
55
53
|
["ssl_funcs.inc", "gb_ssl_tls_cert_details.nasl"],
|
|
56
54
|
r"fpr\s+==>\s+for, far, fps",
|
|
@@ -104,9 +102,7 @@ exceptions = [
|
|
|
104
102
|
r"n[iI]n\s+==>\s+inn",
|
|
105
103
|
),
|
|
106
104
|
# False positive in this VT in German example responses.
|
|
107
|
-
PatternInFileCheck(
|
|
108
|
-
"gb_exchange_server_CVE-2021-26855_active.nasl", r"ist\s+==>\s+is"
|
|
109
|
-
),
|
|
105
|
+
PatternInFileCheck("gb_exchange_server_CVE-2021-26855_active.nasl", r"ist\s+==>\s+is"),
|
|
110
106
|
# Mostly a false positive in LSCs because of things like
|
|
111
107
|
# "ALSA: hda" or a codec called "Conexant". There are too
|
|
112
108
|
# many hits to maintain them in codespell.exclude so exclude
|
|
@@ -152,9 +148,7 @@ exceptions = [
|
|
|
152
148
|
r"nam\s+==>\s+name",
|
|
153
149
|
text_pattern_flags=re.IGNORECASE,
|
|
154
150
|
),
|
|
155
|
-
PatternInFileCheck(
|
|
156
|
-
"/netop_infopublic.nasl", r"nam\s+==>\s+name", flags=re.IGNORECASE
|
|
157
|
-
),
|
|
151
|
+
PatternInFileCheck("/netop_infopublic.nasl", r"nam\s+==>\s+name", flags=re.IGNORECASE),
|
|
158
152
|
# Product names used in a few VTs (no re.IGNORECASE is expected)
|
|
159
153
|
PatternsCheck([r"renderD\s+==>\s+rendered", r"VertX\s+==>\s+vertex"]),
|
|
160
154
|
PatternInFileCheck("_vertx_", r"vertx\s+==>\s+vertex"),
|
|
@@ -206,8 +200,7 @@ class CheckSpelling(FilesPlugin):
|
|
|
206
200
|
batch_size = 10_000
|
|
207
201
|
for i in range(0, len(self.context.nasl_files), batch_size):
|
|
208
202
|
files_parameters = [
|
|
209
|
-
str(nasl_file)
|
|
210
|
-
for nasl_file in self.context.nasl_files[i : i + batch_size]
|
|
203
|
+
str(nasl_file) for nasl_file in self.context.nasl_files[i : i + batch_size]
|
|
211
204
|
]
|
|
212
205
|
codespell_arguments = [
|
|
213
206
|
"--hard-encoding-detection",
|
|
@@ -235,9 +228,7 @@ class CheckSpelling(FilesPlugin):
|
|
|
235
228
|
codespell_entries = [
|
|
236
229
|
line
|
|
237
230
|
for line in codespell_output.splitlines()
|
|
238
|
-
if not handle_linguistic_checks(
|
|
239
|
-
*self._parse_codespell_line(line), exceptions
|
|
240
|
-
)
|
|
231
|
+
if not handle_linguistic_checks(*self._parse_codespell_line(line), exceptions)
|
|
241
232
|
]
|
|
242
233
|
|
|
243
234
|
for codespell_entry in codespell_entries:
|
|
@@ -39,15 +39,12 @@ class CheckTrailingSpacesTabs(FilePlugin):
|
|
|
39
39
|
to find special tags
|
|
40
40
|
|
|
41
41
|
"""
|
|
42
|
-
for line_number, line in enumerate(
|
|
43
|
-
self.context.file_content.splitlines(), start=1
|
|
44
|
-
):
|
|
42
|
+
for line_number, line in enumerate(self.context.file_content.splitlines(), start=1):
|
|
45
43
|
if not PATTERN.search(line):
|
|
46
44
|
continue
|
|
47
45
|
|
|
48
46
|
yield LinterError(
|
|
49
|
-
"The VT has one or more trailing spaces "
|
|
50
|
-
f"and/or tabs in line {line_number}!",
|
|
47
|
+
"The VT has one or more trailing spaces " f"and/or tabs in line {line_number}!",
|
|
51
48
|
file=self.context.nasl_file,
|
|
52
49
|
plugin=self.name,
|
|
53
50
|
)
|
|
@@ -63,9 +63,7 @@ class CheckUsingDisplay(FileContentPlugin):
|
|
|
63
63
|
|
|
64
64
|
# Case 1: Not in any if statement - ERROR
|
|
65
65
|
if not containing_if:
|
|
66
|
-
line_start = (
|
|
67
|
-
comment_free_content.rfind("\n", 0, display_pos) + 1
|
|
68
|
-
)
|
|
66
|
+
line_start = comment_free_content.rfind("\n", 0, display_pos) + 1
|
|
69
67
|
line_end = comment_free_content.find("\n", display_pos)
|
|
70
68
|
if line_end == -1:
|
|
71
69
|
line_end = len(comment_free_content)
|
|
@@ -95,9 +93,7 @@ class CheckUsingDisplay(FileContentPlugin):
|
|
|
95
93
|
yield LinterWarning(
|
|
96
94
|
"VT is using a display() inside an if statement"
|
|
97
95
|
f" but without debug check at line {line}\n"
|
|
98
|
-
+ comment_free_content[
|
|
99
|
-
containing_if.if_start : containing_if.if_end
|
|
100
|
-
],
|
|
96
|
+
+ comment_free_content[containing_if.if_start : containing_if.if_end],
|
|
101
97
|
file=nasl_file,
|
|
102
98
|
plugin=self.name,
|
|
103
99
|
)
|
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(
|