troubadix 24.9.1__py3-none-any.whl → 24.9.2__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__ = "24.9.1"
5
+ __version__ = "24.9.2"
troubadix/plugins/qod.py CHANGED
@@ -15,23 +15,24 @@
15
15
  # You should have received a copy of the GNU General Public License
16
16
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
+ import re
18
19
  from typing import Iterator
19
20
 
20
21
  from troubadix.helper.patterns import ScriptTag, get_script_tag_pattern
21
22
  from troubadix.plugin import FilePlugin, LinterError, LinterResult
22
23
 
23
24
  VALID_QOD_NUM_VALUES = [
24
- 1,
25
- 30,
26
- 50,
27
- 70,
28
- 75,
29
- 80,
30
- 95,
31
- 97,
32
- 98,
33
- 99,
34
- 100,
25
+ "1",
26
+ "30",
27
+ "50",
28
+ "70",
29
+ "75",
30
+ "80",
31
+ "95",
32
+ "97",
33
+ "98",
34
+ "99",
35
+ "100",
35
36
  ]
36
37
 
37
38
  VALID_QOD_TYPES = [
@@ -51,6 +52,12 @@ VALID_QOD_TYPES = [
51
52
  "package_unreliable",
52
53
  ]
53
54
 
55
+ # needed due to script_tag_pattern value not including the quotes
56
+ QOD_WITH_QUOTES_PATTERN = re.compile(
57
+ r'script_tag\(\s*name\s*:\s*(?P<quote>[\'"])qod(?P=quote)\s*,'
58
+ r'\s*value\s*:\s*(?P<value_with_quotes>[\'"]?(?P<value>.+?)[\'"]?)\s*\)\s*;'
59
+ )
60
+
54
61
 
55
62
  class CheckQod(FilePlugin):
56
63
  name = "check_qod"
@@ -68,10 +75,9 @@ class CheckQod(FilePlugin):
68
75
  if "# troubadix: disable=template_nd_test_files_fps" in file_content:
69
76
  return
70
77
 
71
- qod_pattern = get_script_tag_pattern(ScriptTag.QOD)
72
78
  qod_type_pattern = get_script_tag_pattern(ScriptTag.QOD_TYPE)
73
79
 
74
- match_qod = list(qod_pattern.finditer(file_content))
80
+ match_qod = list(QOD_WITH_QUOTES_PATTERN.finditer(file_content))
75
81
  match_qod_type = list(qod_type_pattern.finditer(file_content))
76
82
 
77
83
  num_matches = len(match_qod) + len(match_qod_type)
@@ -89,21 +95,25 @@ class CheckQod(FilePlugin):
89
95
  )
90
96
 
91
97
  for match in match_qod:
92
- try:
93
- qod = int(match.group("value"))
94
- if qod not in VALID_QOD_NUM_VALUES:
98
+ full_match = match.group(0)
99
+ full_value = match.group("value_with_quotes")
100
+ value = match.group("value")
101
+
102
+ # Check if the value is enclosed in double quotes
103
+ if full_value.startswith('"') and full_value.endswith('"'):
104
+
105
+ # Compare against valid values
106
+ if value not in VALID_QOD_NUM_VALUES:
95
107
  yield LinterError(
96
- f"{match.group(0)}: '{qod}' is an invalid QoD number"
97
- " value. Allowed are"
98
- f" {', '.join(str(x) for x in VALID_QOD_NUM_VALUES)}",
108
+ f"Invalid QOD value '{value}' in {full_match}."
109
+ " Allowed are"
110
+ f" {', '.join(x for x in VALID_QOD_NUM_VALUES)}",
99
111
  file=self.context.nasl_file,
100
112
  plugin=self.name,
101
113
  )
102
- except ValueError:
114
+ else:
103
115
  yield LinterError(
104
- f"{match.group(0)}: '{match.group('value')}' is an invalid"
105
- " QoD number value. Allowed are"
106
- f" {', '.join(str(x) for x in VALID_QOD_NUM_VALUES)}",
116
+ f"QOD value not properly enclosed in double quotes in {full_match}",
107
117
  file=self.context.nasl_file,
108
118
  plugin=self.name,
109
119
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: troubadix
3
- Version: 24.9.1
3
+ Version: 24.9.2
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
@@ -1,5 +1,5 @@
1
1
  troubadix/__init__.py,sha256=K7sIXXDrC7YRb7BvIpdQ6ZfG_QkT0qUH_wAlHROVRfM,716
2
- troubadix/__version__.py,sha256=ZDcSR0f7wqcHYyLlgRk4AVKxvoiWRm7FEU79mNRfj3k,103
2
+ troubadix/__version__.py,sha256=MEfWYDaxHJ7AE6AmB08MD8l6RuK4byEL9BZ3UJ3ZoPg,103
3
3
  troubadix/argparser.py,sha256=YAo8cGJt0k2GMICXrDj3Z124GrM8oRwgNm2Bn3J_gYI,7001
4
4
  troubadix/codespell/codespell.additions,sha256=9hUrzjJF4Q8T5rVLx8CQa01oICvmsjzE6sCPjVRDOEU,418
5
5
  troubadix/codespell/codespell.exclude,sha256=qALEzLglEbPwcTRwGcobM_MTJzZyJekYRdJY3ws5yeM,138030
@@ -39,7 +39,7 @@ troubadix/plugins/newlines.py,sha256=aEQOzkzd3rl9DjEi7q0EOB1M8h41WXr0O5Qf4jMFEvM
39
39
  troubadix/plugins/overlong_description_lines.py,sha256=dF7UQ7tphkWuiXeLj4-y0zi86RumkwCCPCn2My1SIDo,3130
40
40
  troubadix/plugins/overlong_script_tags.py,sha256=LKJQxX9s2fkExkM0MOIqYZGOKbEe9eth7DEcxFo3A8k,2356
41
41
  troubadix/plugins/prod_svc_detect_in_vulnvt.py,sha256=AnHF5jPNz4wEr-etZ2fkJNqqMH2he-9ofOdzWJyPeK4,4292
42
- troubadix/plugins/qod.py,sha256=u4VPFAjzidnnPrmwuSPZuK8KKMZBFi30XqaRGLcYPhc,3816
42
+ troubadix/plugins/qod.py,sha256=OMEjZR3fbimLX4F3LsMZZn4IZi32j4soMYp1uQFv5Sc,4164
43
43
  troubadix/plugins/reporting_consistency.py,sha256=xBLd3ASa2zlPg61ONpBFSt_RtblTQ70vKWm05MS0tew,4027
44
44
  troubadix/plugins/script_add_preference_type.py,sha256=KhVYU24g-OJF1XqPOsqX1k8LU7-BciSXQ2EbCcnJezw,3193
45
45
  troubadix/plugins/script_calls_empty_values.py,sha256=XdtqTGWI3k_3eId-XAgxwXLxucENqC5CIQJG8Ncn1_M,2512
@@ -92,8 +92,8 @@ troubadix/standalone_plugins/last_modification.py,sha256=oYzQq7xV3YzSvi6ZtuHuupX
92
92
  troubadix/standalone_plugins/no_solution.py,sha256=81r20kP8otRob2NTaCea-sgVRIM6ARvhddFdibsG6Ao,8877
93
93
  troubadix/standalone_plugins/version_updated.py,sha256=dIGj81rbluyNjINn9kA1yPY2hUo6fqbNa-kg0Zi9Clc,4263
94
94
  troubadix/troubadix.py,sha256=foA7Loi67cCKieN3ea4s3QOfOWOkgwQVR1H-pNXtXn0,6041
95
- troubadix-24.9.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
96
- troubadix-24.9.1.dist-info/METADATA,sha256=ZunmHinfrP5DbBKTWljuhyqXUzQrI58-6Iyj947GFTI,4357
97
- troubadix-24.9.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
98
- troubadix-24.9.1.dist-info/entry_points.txt,sha256=LplOk4nzKrS4B8Jz0SPkQLPlIDesdraCO8Vp_eoycpc,737
99
- troubadix-24.9.1.dist-info/RECORD,,
95
+ troubadix-24.9.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
96
+ troubadix-24.9.2.dist-info/METADATA,sha256=NMi0sb35_hF-MTp5NuaaxJYmzMTr_tGWxCykoHB2asg,4357
97
+ troubadix-24.9.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
98
+ troubadix-24.9.2.dist-info/entry_points.txt,sha256=LplOk4nzKrS4B8Jz0SPkQLPlIDesdraCO8Vp_eoycpc,737
99
+ troubadix-24.9.2.dist-info/RECORD,,