troubadix 25.10.10__py3-none-any.whl → 25.11.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 CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  # THIS IS AN AUTOGENERATED FILE. DO NOT TOUCH!
4
4
 
5
- __version__ = "25.10.10"
5
+ __version__ = "25.11.1"
@@ -78,3 +78,29 @@ def is_position_in_string(text: str, position: int) -> bool:
78
78
  string_state.process_next_char(char)
79
79
 
80
80
  return string_state.in_string
81
+
82
+
83
+ def find_matching_brace(
84
+ text: str, opening_pos: int, braces: tuple[str, str] = ("(", ")")
85
+ ) -> int | None:
86
+ """
87
+ Return the index of the matching closing brace for the brace at opening_pos.
88
+ """
89
+ opening, closing = braces
90
+ depth = 1
91
+ string_state = StringState()
92
+
93
+ for pos in range(opening_pos + 1, len(text)):
94
+ char = text[pos]
95
+ string_state.process_next_char(char)
96
+
97
+ if string_state.in_string:
98
+ continue
99
+
100
+ if char == opening:
101
+ depth += 1
102
+ elif char == closing:
103
+ depth -= 1
104
+ if depth == 0:
105
+ return pos
106
+ return None
@@ -53,6 +53,7 @@ from .overlong_script_tags import CheckOverlongScriptTags
53
53
  from .prod_svc_detect_in_vulnvt import CheckProdSvcDetectInVulnvt
54
54
  from .qod import CheckQod
55
55
  from .reporting_consistency import CheckReportingConsistency
56
+ from .script_add_preference_id import CheckScriptAddPreferenceId
56
57
  from .script_add_preference_type import CheckScriptAddPreferenceType
57
58
  from .script_calls_empty_values import CheckScriptCallsEmptyValues
58
59
  from .script_calls_recommended import CheckScriptCallsRecommended
@@ -151,6 +152,7 @@ _FILE_PLUGINS = [
151
152
  CheckWrongSetGetKBCalls,
152
153
  CheckSpacesBeforeDots,
153
154
  CheckIfStatementSyntax,
155
+ CheckScriptAddPreferenceId,
154
156
  ]
155
157
 
156
158
  # plugins checking all files
@@ -176,6 +176,8 @@ class CheckHttpLinksInTags(FilePlugin):
176
176
  # For example: 'http://[::1]/'.
177
177
  "http://[::1]/",
178
178
  "https://[::1]/",
179
+ "https://target",
180
+ "http://target",
179
181
  ]
180
182
 
181
183
  return any(
@@ -0,0 +1,53 @@
1
+ # SPDX-License-Identifier: GPL-3.0-or-later
2
+ # SPDX-FileCopyrightText: 2025 Greenbone AG
3
+
4
+ import re
5
+ from collections.abc import Iterator
6
+ from pathlib import Path
7
+
8
+ from troubadix.helper.text_utils import find_matching_brace
9
+ from troubadix.plugin import FileContentPlugin, LinterError, LinterResult
10
+
11
+ SCRIPT_CALL_PATTERN = re.compile(r"script_add_preference\s*\(")
12
+ ID_PATTERN = re.compile(r"id\s*:\s*(?P<id>\d+)")
13
+
14
+
15
+ def iter_script_add_preference_values(
16
+ source: str,
17
+ ) -> Iterator[str]:
18
+ for match in SCRIPT_CALL_PATTERN.finditer(source):
19
+ opening_paren = match.end() - 1
20
+ closing_paren = find_matching_brace(source, opening_paren, ("(", ")"))
21
+ if closing_paren is None:
22
+ continue
23
+ yield source[opening_paren + 1 : closing_paren]
24
+
25
+
26
+ class CheckScriptAddPreferenceId(FileContentPlugin):
27
+ name = "check_script_add_preference_id"
28
+
29
+ def check_content(
30
+ self, nasl_file: Path, file_content: str
31
+ ) -> Iterator[LinterResult]:
32
+ if (
33
+ nasl_file.suffix == ".inc"
34
+ or "script_add_preference" not in file_content
35
+ ):
36
+ return
37
+
38
+ seen_ids: set[int] = set()
39
+
40
+ for index, value in enumerate(
41
+ iter_script_add_preference_values(file_content), 1
42
+ ):
43
+ id_match = ID_PATTERN.search(value)
44
+ pref_id = int(id_match.group("id")) if id_match else index
45
+
46
+ if pref_id in seen_ids:
47
+ yield LinterError(
48
+ f"script_add_preference id {pref_id} is used multiple times",
49
+ file=nasl_file,
50
+ plugin=self.name,
51
+ )
52
+
53
+ seen_ids.add(pref_id)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: troubadix
3
- Version: 25.10.10
3
+ Version: 25.11.1
4
4
  Summary: A linting and QA check tool for NASL files
5
5
  License: GPL-3.0-or-later
6
6
  License-File: LICENSE
@@ -1,5 +1,5 @@
1
1
  troubadix/__init__.py,sha256=K7sIXXDrC7YRb7BvIpdQ6ZfG_QkT0qUH_wAlHROVRfM,716
2
- troubadix/__version__.py,sha256=tM6XBs928mas3m_SEaK-UlVtWoA2w4UXHge5R3tqxRc,105
2
+ troubadix/__version__.py,sha256=zPiZVhAKwIBkVkLDI46rjtCwh0J5OHdqk6CDeKVhYVk,104
3
3
  troubadix/argparser.py,sha256=-H07Jhqh68_M4Mbjq9qJjTr3MShy_N2pxl2qHA6cfRU,7481
4
4
  troubadix/codespell/codespell.additions,sha256=SJPlIo8vEKEOTftY6ZBSXzcfyv6y9aFAXl9FdpcMxD0,561
5
5
  troubadix/codespell/codespell.exclude,sha256=1zLTC45y7o1pVWUju35IFRNFG1Tj-r5HbgJwtCb8FRk,148569
@@ -11,9 +11,9 @@ troubadix/helper/if_block_parser.py,sha256=_51UlsYrELt4GwWzJIU7qc7HIZPdpmExLG8WM
11
11
  troubadix/helper/linguistic_exception_handler.py,sha256=Bq7ULjDdWTKUpFNTUX6XMPdD4s4v8eIjZPyqBe8VLws,6811
12
12
  troubadix/helper/patterns.py,sha256=qhiAtNQs89Hk6-yRGrjjRO4DdVIMhYLd8IEQ48REpu4,9752
13
13
  troubadix/helper/remove_comments.py,sha256=zjhXPQXgKaEOparAdu4aBXcJlEul8LbNaP3uLCYGwHw,1244
14
- troubadix/helper/text_utils.py,sha256=gBX0box9VtgA0CMfE0u2Vvi1IuOopxUfCQFYn_1wVjE,2543
14
+ troubadix/helper/text_utils.py,sha256=YM0qaiBDsWJSUkQoRPFjVGEvQsLVDxN90GwNb240Lb8,3184
15
15
  troubadix/plugin.py,sha256=3fQPj3Qe_hgwHerlYE4hbdzYMzRU557NxJ-UwtE9mOI,3525
16
- troubadix/plugins/__init__.py,sha256=7NqTzddmptQZJ_s1yxpamVo0Y8zohAWlEQU2lf103_Y,8745
16
+ troubadix/plugins/__init__.py,sha256=C6ym0txssNcF7a4MiSl6uhDOeWYL3b-GcTa03pm5Edk,8842
17
17
  troubadix/plugins/badwords.py,sha256=ppTJT7yl6kPo51PT-mHxpbmuKMJpBgEKzLDU0sLktig,5014
18
18
  troubadix/plugins/copyright_text.py,sha256=jYsLWmTbT_A78XQQxQFK-5kMMHkh3xdvlh7mEF2dZGU,3583
19
19
  troubadix/plugins/copyright_year.py,sha256=XzM9MHVzOXwNLwHpfuaWj8PUOmswr56SBVOLBdvxjd4,5478
@@ -31,7 +31,7 @@ troubadix/plugins/encoding.py,sha256=Ow_ZpyjtL2_nqhbukY_3EUhiR0agfSxMxJ4IcMSGsT4
31
31
  troubadix/plugins/forking_nasl_functions.py,sha256=IUtCrTK_sGDx79jAPS8lF_aN8zSG2AkzfC6duTMvJOw,6069
32
32
  troubadix/plugins/get_kb_on_services.py,sha256=oFmcjiF7ZD3x5tEbJEoZNn80y1qUzNgeSZNsogSqaZ0,3401
33
33
  troubadix/plugins/grammar.py,sha256=-53McZsKFuEavIS8-8CG7fUbW8VO3FuZv0PXenD42Bk,10239
34
- troubadix/plugins/http_links_in_tags.py,sha256=DOAsN16av2UdMJUvK3nDi44ertBIi9EauK821GwGLKY,7448
34
+ troubadix/plugins/http_links_in_tags.py,sha256=MmjMkjjlhLDrn-GvYQhPuXR4BSHImOrYi_nede-H-8w,7507
35
35
  troubadix/plugins/if_statement_syntax.py,sha256=5BRJwCCghvZn1AfvYzmk8l9S7aRqbVaLHhSKod_Q9zw,1429
36
36
  troubadix/plugins/illegal_characters.py,sha256=B6q_RU85AxCjLry56Oc-RhMSpnJU8mTrxclRzi1FVFU,4406
37
37
  troubadix/plugins/log_messages.py,sha256=COrnp3bXMG8PRIAD2x5Ka9hk-jI16We9ifXj6JBZI0c,2960
@@ -46,6 +46,7 @@ troubadix/plugins/overlong_script_tags.py,sha256=LKJQxX9s2fkExkM0MOIqYZGOKbEe9et
46
46
  troubadix/plugins/prod_svc_detect_in_vulnvt.py,sha256=AnHF5jPNz4wEr-etZ2fkJNqqMH2he-9ofOdzWJyPeK4,4292
47
47
  troubadix/plugins/qod.py,sha256=OMEjZR3fbimLX4F3LsMZZn4IZi32j4soMYp1uQFv5Sc,4164
48
48
  troubadix/plugins/reporting_consistency.py,sha256=yp4FQ8T6gVPzLDF5334mGG5m8n9x8c2I_ApfHzZpVRA,4024
49
+ troubadix/plugins/script_add_preference_id.py,sha256=LcmvhMLnYNqEp3S1j9HdMZ1w-cUWdmMTlts8Pru0aR8,1669
49
50
  troubadix/plugins/script_add_preference_type.py,sha256=PHySUVWqI8dG51xI0CIzaB2a83GicCryPtbcugE8jgE,3643
50
51
  troubadix/plugins/script_calls_empty_values.py,sha256=XdtqTGWI3k_3eId-XAgxwXLxucENqC5CIQJG8Ncn1_M,2512
51
52
  troubadix/plugins/script_calls_recommended.py,sha256=GHnfCKBlmutfCXrkvvujvDR7TJDxr2Dx2KZDMa1z_TU,3180
@@ -108,8 +109,8 @@ troubadix/standalone_plugins/no_solution.py,sha256=p_-az9Igl4GH6HnhLLYbYlWIiEP64
108
109
  troubadix/standalone_plugins/util.py,sha256=JTXGmi-_BJouTNe6QzEosLlXUt9jKW-3fz4db05RJJw,696
109
110
  troubadix/standalone_plugins/version_updated.py,sha256=6YHF0OjL5NWszQdsSh7XzlSji1e6Uaqwu_Y6m3R0mvI,4203
110
111
  troubadix/troubadix.py,sha256=5__Jz3bYSrya4aG6RCBWxqnsDepXfwXZ3v0bjCzEFi0,6039
111
- troubadix-25.10.10.dist-info/METADATA,sha256=leca1P8z5zmMk5RnLALX8jqEqKMPY1ilL3ii1eH4aLo,4537
112
- troubadix-25.10.10.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
113
- troubadix-25.10.10.dist-info/entry_points.txt,sha256=ETEPBi4fKv3o7hzkzceX4838G6g5_5wRdEddYot8N6A,920
114
- troubadix-25.10.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
115
- troubadix-25.10.10.dist-info/RECORD,,
112
+ troubadix-25.11.1.dist-info/METADATA,sha256=JOeJ31wxrvA_zI8iX4kQ60NFzyxZ3C_Cf_0cyVlo84M,4536
113
+ troubadix-25.11.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
114
+ troubadix-25.11.1.dist-info/entry_points.txt,sha256=ETEPBi4fKv3o7hzkzceX4838G6g5_5wRdEddYot8N6A,920
115
+ troubadix-25.11.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
116
+ troubadix-25.11.1.dist-info/RECORD,,