troubadix 24.10.0__py3-none-any.whl → 24.10.1__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/plugins/script_xref_url.py +1 -1
- troubadix/standalone_plugins/deprecate_vts.py +40 -29
- {troubadix-24.10.0.dist-info → troubadix-24.10.1.dist-info}/METADATA +3 -2
- {troubadix-24.10.0.dist-info → troubadix-24.10.1.dist-info}/RECORD +8 -8
- {troubadix-24.10.0.dist-info → troubadix-24.10.1.dist-info}/WHEEL +1 -1
- {troubadix-24.10.0.dist-info → troubadix-24.10.1.dist-info}/LICENSE +0 -0
- {troubadix-24.10.0.dist-info → troubadix-24.10.1.dist-info}/entry_points.txt +0 -0
troubadix/__version__.py
CHANGED
|
@@ -64,7 +64,7 @@ class CheckScriptXrefUrl(FileContentPlugin):
|
|
|
64
64
|
for match in matches:
|
|
65
65
|
if match:
|
|
66
66
|
if match.group("value") not in ALLOWED_URLS and not url(
|
|
67
|
-
match.group("value")
|
|
67
|
+
match.group("value"), strict_query=False
|
|
68
68
|
):
|
|
69
69
|
yield LinterError(
|
|
70
70
|
f"{match.group(0)}: Invalid URL value",
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
# SPDX-FileCopyrightText: 2024 Greenbone AG
|
|
3
3
|
|
|
4
4
|
import re
|
|
5
|
-
from argparse import ArgumentParser, Namespace
|
|
5
|
+
from argparse import ArgumentParser, ArgumentTypeError, Namespace
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from enum import Enum
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from typing import Iterable, Optional
|
|
10
10
|
|
|
11
|
+
from pontos.terminal.terminal import ConsoleTerminal
|
|
12
|
+
|
|
11
13
|
from troubadix.argparser import directory_type, file_type
|
|
12
14
|
from troubadix.helper.patterns import (
|
|
13
15
|
ScriptTag,
|
|
@@ -15,6 +17,7 @@ from troubadix.helper.patterns import (
|
|
|
15
17
|
get_script_tag_pattern,
|
|
16
18
|
get_special_script_tag_pattern,
|
|
17
19
|
)
|
|
20
|
+
from troubadix.troubadix import from_file
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
class Deprecations(Enum):
|
|
@@ -34,6 +37,15 @@ class DeprecatedFile:
|
|
|
34
37
|
KB_ITEMS_PATTERN = re.compile(r"set_kb_item\(.+\);")
|
|
35
38
|
|
|
36
39
|
|
|
40
|
+
def existing_file_type(string: str) -> Path:
|
|
41
|
+
file_path = Path(string)
|
|
42
|
+
if not file_path.exists():
|
|
43
|
+
raise ArgumentTypeError(f'File "{string}" does not exist.')
|
|
44
|
+
if not file_path.is_file():
|
|
45
|
+
raise ArgumentTypeError(f'"{string}" is not a file.')
|
|
46
|
+
return file_path
|
|
47
|
+
|
|
48
|
+
|
|
37
49
|
def update_summary(file: DeprecatedFile, deprecation_reason: str) -> str:
|
|
38
50
|
"""Update the summary of the nasl script by adding the information
|
|
39
51
|
that the script has been deprecated, and if possible, the oid of
|
|
@@ -83,26 +95,18 @@ def get_files_from_path(dir_path: Path = None) -> list:
|
|
|
83
95
|
return [file for file in dir_path.glob("**/*")]
|
|
84
96
|
|
|
85
97
|
|
|
86
|
-
def
|
|
87
|
-
|
|
88
|
-
) -> list[DeprecatedFile]:
|
|
89
|
-
"""Filter the files based on a provided prefix and convert them into
|
|
98
|
+
def parse_files(files: list) -> list[DeprecatedFile]:
|
|
99
|
+
"""Convert filepaths into
|
|
90
100
|
DeprecatedFile objects
|
|
91
101
|
|
|
92
102
|
Args:
|
|
93
103
|
files: a list of files to deprecate, should be .nasl VTs
|
|
94
|
-
filename_prefix: an optional prefix to filter only specific files
|
|
95
104
|
|
|
96
105
|
Returns:
|
|
97
106
|
List of DeprecatedFile objects
|
|
98
107
|
|
|
99
108
|
"""
|
|
100
109
|
to_deprecate = []
|
|
101
|
-
if filename_prefix:
|
|
102
|
-
filename_filter = re.compile(rf"{filename_prefix}")
|
|
103
|
-
files[:] = [
|
|
104
|
-
file for file in files if re.match(filename_filter, file.name)
|
|
105
|
-
]
|
|
106
110
|
|
|
107
111
|
for file in files:
|
|
108
112
|
with file.open("r", encoding="latin-1") as fh:
|
|
@@ -193,16 +197,6 @@ def parse_args(args: Iterable[str] = None) -> Namespace:
|
|
|
193
197
|
required=True,
|
|
194
198
|
help="Path where the deprecated files should be written to.",
|
|
195
199
|
)
|
|
196
|
-
parser.add_argument(
|
|
197
|
-
"-p",
|
|
198
|
-
"--filename-prefix",
|
|
199
|
-
metavar="<filename_prefix>",
|
|
200
|
-
nargs="?",
|
|
201
|
-
default=None,
|
|
202
|
-
type=str,
|
|
203
|
-
help="The prefix of the files you would like to deprecate,"
|
|
204
|
-
"for example 'gb_rhsa_2021' to filter on the year",
|
|
205
|
-
)
|
|
206
200
|
parser.add_argument(
|
|
207
201
|
"-r",
|
|
208
202
|
"--deprecation-reason",
|
|
@@ -214,16 +208,17 @@ def parse_args(args: Iterable[str] = None) -> Namespace:
|
|
|
214
208
|
"been merged with another still active VT, 'duplicate': The VT has"
|
|
215
209
|
"a still active duplicate, 'defunct': The VT is no longer "
|
|
216
210
|
"functional.",
|
|
211
|
+
required=True,
|
|
217
212
|
)
|
|
218
213
|
group = parser.add_mutually_exclusive_group(required=True)
|
|
219
214
|
group.add_argument(
|
|
220
215
|
"-f",
|
|
221
|
-
"--
|
|
222
|
-
metavar="<
|
|
216
|
+
"--file",
|
|
217
|
+
metavar="<file>",
|
|
223
218
|
nargs="+",
|
|
224
219
|
default=None,
|
|
225
220
|
type=file_type,
|
|
226
|
-
help="
|
|
221
|
+
help="File to deprecate",
|
|
227
222
|
)
|
|
228
223
|
group.add_argument(
|
|
229
224
|
"-i",
|
|
@@ -231,20 +226,36 @@ def parse_args(args: Iterable[str] = None) -> Namespace:
|
|
|
231
226
|
metavar="<input_path>",
|
|
232
227
|
default=None,
|
|
233
228
|
type=directory_type,
|
|
234
|
-
help="Path to
|
|
229
|
+
help="Path to a directory where all files should be deprecated.",
|
|
230
|
+
)
|
|
231
|
+
group.add_argument(
|
|
232
|
+
"--from-file",
|
|
233
|
+
metavar="<from_file>",
|
|
234
|
+
default=None,
|
|
235
|
+
type=existing_file_type,
|
|
236
|
+
help=(
|
|
237
|
+
"Path to a single file that contains a list of files "
|
|
238
|
+
"to be deprecated, separated by new lines."
|
|
239
|
+
),
|
|
235
240
|
)
|
|
236
241
|
return parser.parse_args(args)
|
|
237
242
|
|
|
238
243
|
|
|
239
244
|
def main():
|
|
240
245
|
args = parse_args()
|
|
246
|
+
terminal = ConsoleTerminal()
|
|
241
247
|
input_path = args.input_path if args.input_path else None
|
|
242
|
-
|
|
248
|
+
files = []
|
|
243
249
|
|
|
244
|
-
|
|
245
|
-
|
|
250
|
+
if input_path:
|
|
251
|
+
files = get_files_from_path(input_path)
|
|
252
|
+
elif args.from_file:
|
|
253
|
+
files = from_file(include_file=args.from_file, term=terminal)
|
|
254
|
+
elif args.file:
|
|
255
|
+
files = args.file
|
|
246
256
|
|
|
247
|
-
|
|
257
|
+
to_be_deprecated = parse_files(files)
|
|
258
|
+
deprecate(args.output_path, to_be_deprecated, args.deprecation_reason)
|
|
248
259
|
|
|
249
260
|
|
|
250
261
|
if __name__ == "__main__":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: troubadix
|
|
3
|
-
Version: 24.10.
|
|
3
|
+
Version: 24.10.1
|
|
4
4
|
Summary: A linting and QA check tool for NASL files
|
|
5
5
|
Home-page: https://github.com/greenbone/troubadix
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
21
|
Requires-Dist: chardet (>=4,<6)
|
|
21
22
|
Requires-Dist: charset-normalizer (>=3.2.0,<4.0.0)
|
|
@@ -23,7 +24,7 @@ Requires-Dist: codespell (>=2.0.0,<3.0.0)
|
|
|
23
24
|
Requires-Dist: gitpython (>=3.1.31,<4.0.0)
|
|
24
25
|
Requires-Dist: pontos (>=22.7,<25.0)
|
|
25
26
|
Requires-Dist: python-magic (>=0.4.25,<0.5.0)
|
|
26
|
-
Requires-Dist: validators (
|
|
27
|
+
Requires-Dist: validators (>=0.34.0,<0.35.0)
|
|
27
28
|
Project-URL: Repository, https://github.com/greenbone/troubadix
|
|
28
29
|
Description-Content-Type: text/markdown
|
|
29
30
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
troubadix/__init__.py,sha256=K7sIXXDrC7YRb7BvIpdQ6ZfG_QkT0qUH_wAlHROVRfM,716
|
|
2
|
-
troubadix/__version__.py,sha256=
|
|
2
|
+
troubadix/__version__.py,sha256=QzxNhvE2FNP2xdsM9j8IJSuyjqWoBaVmQ_l5mtbnUWw,104
|
|
3
3
|
troubadix/argparser.py,sha256=YAo8cGJt0k2GMICXrDj3Z124GrM8oRwgNm2Bn3J_gYI,7001
|
|
4
4
|
troubadix/codespell/codespell.additions,sha256=OaHe66OE0Yx4VTkhIeITZqB7_ERiv0fsDnpikGUgZ-Q,488
|
|
5
5
|
troubadix/codespell/codespell.exclude,sha256=6HEOtHrMBBdm4E4794W4g1H9nmGLlYbgZpQiJzKio-A,139033
|
|
@@ -52,7 +52,7 @@ troubadix/plugins/script_tag_whitespaces.py,sha256=2ZqiNufPIyr5Wmcuap3Wy8RXO_CHG
|
|
|
52
52
|
troubadix/plugins/script_tags_mandatory.py,sha256=t9GiueHwCjWq-2jQszYNufWpfIKTLdUbbvXPyiw3HeY,2630
|
|
53
53
|
troubadix/plugins/script_version_and_last_modification_tags.py,sha256=Yz9dQwrsRfIqXwPd8Re8aDu--SBjgufWOA6U7tW4JW4,7638
|
|
54
54
|
troubadix/plugins/script_xref_form.py,sha256=5L1KPUHiKbe-71o-X0cUBT844XvIOsAJbB14gnYTod0,1848
|
|
55
|
-
troubadix/plugins/script_xref_url.py,sha256
|
|
55
|
+
troubadix/plugins/script_xref_url.py,sha256=qKeRgcZEka4Xm0EYYSq9_J_y8jVn6lrLPYan2FljN4E,2895
|
|
56
56
|
troubadix/plugins/security_messages.py,sha256=EPu3-YB0iP5_hfbQjrfvvTrQRiPgDjC85GTz3V-by0Q,4629
|
|
57
57
|
troubadix/plugins/set_get_kb_calls.py,sha256=WGu1CKLjn3VhbDo33IJ4TtWQ-kz9gInkJskTqOSMM6k,3415
|
|
58
58
|
troubadix/plugins/solution_text.py,sha256=4Gs84Qsyg-1iTDP7Y7o8Bo5AH4hKlwGPW0NfwMpx2fU,5852
|
|
@@ -87,14 +87,14 @@ troubadix/standalone_plugins/changed_packages/marker/dropped_architecture.py,sha
|
|
|
87
87
|
troubadix/standalone_plugins/changed_packages/marker/marker.py,sha256=7uZXR2Ds_8soB_2wugCkOSz_3hoX03KMh2NAW0G5Dzg,1278
|
|
88
88
|
troubadix/standalone_plugins/changed_packages/package.py,sha256=Pcr2tcwiPTzD3jB0iteqA7-TajL-dl5Onh1dvC_H9xk,2743
|
|
89
89
|
troubadix/standalone_plugins/common.py,sha256=PkScV-lisNY4WyrzwjV3dK1DF26hJv5JXTcREblJ0v0,1028
|
|
90
|
-
troubadix/standalone_plugins/deprecate_vts.py,sha256=
|
|
90
|
+
troubadix/standalone_plugins/deprecate_vts.py,sha256=WjhJb9YkUp_5TScE9wKI856tfi7ZZ6mBQQdrE-BqQE0,7889
|
|
91
91
|
troubadix/standalone_plugins/file_extensions.py,sha256=QLQt02WIc4SWLDTKKnG8q2g-atC7Mgus-opuXf_SX1A,2630
|
|
92
92
|
troubadix/standalone_plugins/last_modification.py,sha256=oYzQq7xV3YzSvi6ZtuHuupXsJwBtO93tKfbwaIeqiJI,4616
|
|
93
93
|
troubadix/standalone_plugins/no_solution.py,sha256=81r20kP8otRob2NTaCea-sgVRIM6ARvhddFdibsG6Ao,8877
|
|
94
94
|
troubadix/standalone_plugins/version_updated.py,sha256=RlzVuXgFOvcjrRTOhiTYlmzV4vvcn7ntCz0lDTjePMU,4316
|
|
95
95
|
troubadix/troubadix.py,sha256=foA7Loi67cCKieN3ea4s3QOfOWOkgwQVR1H-pNXtXn0,6041
|
|
96
|
-
troubadix-24.10.
|
|
97
|
-
troubadix-24.10.
|
|
98
|
-
troubadix-24.10.
|
|
99
|
-
troubadix-24.10.
|
|
100
|
-
troubadix-24.10.
|
|
96
|
+
troubadix-24.10.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
97
|
+
troubadix-24.10.1.dist-info/METADATA,sha256=c7uJGlMtz-hbHkJJDpRsU-1kPAr8_QOjJvtyajMKK84,4417
|
|
98
|
+
troubadix-24.10.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
99
|
+
troubadix-24.10.1.dist-info/entry_points.txt,sha256=LplOk4nzKrS4B8Jz0SPkQLPlIDesdraCO8Vp_eoycpc,737
|
|
100
|
+
troubadix-24.10.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|