python-gvm 23.12.0__py3-none-any.whl → 24.3.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.
Files changed (80) hide show
  1. gvm/__init__.py +1 -14
  2. gvm/__version__.py +1 -1
  3. gvm/_enum.py +38 -0
  4. gvm/connections.py +83 -66
  5. gvm/errors.py +2 -15
  6. gvm/protocols/__init__.py +2 -15
  7. gvm/protocols/base.py +1 -14
  8. gvm/protocols/gmp.py +1 -14
  9. gvm/protocols/gmpv208/__init__.py +1 -14
  10. gvm/protocols/gmpv208/entities/__init__.py +1 -14
  11. gvm/protocols/gmpv208/entities/alerts.py +2 -65
  12. gvm/protocols/gmpv208/entities/audits.py +1 -15
  13. gvm/protocols/gmpv208/entities/credentials.py +3 -87
  14. gvm/protocols/gmpv208/entities/entities.py +3 -30
  15. gvm/protocols/gmpv208/entities/filter.py +5 -27
  16. gvm/protocols/gmpv208/entities/groups.py +1 -14
  17. gvm/protocols/gmpv208/entities/hosts.py +3 -37
  18. gvm/protocols/gmpv208/entities/notes.py +1 -15
  19. gvm/protocols/gmpv208/entities/operating_systems.py +1 -14
  20. gvm/protocols/gmpv208/entities/overrides.py +1 -14
  21. gvm/protocols/gmpv208/entities/permissions.py +3 -39
  22. gvm/protocols/gmpv208/entities/policies.py +1 -14
  23. gvm/protocols/gmpv208/entities/port_lists.py +3 -40
  24. gvm/protocols/gmpv208/entities/report_formats.py +2 -32
  25. gvm/protocols/gmpv208/entities/reports.py +1 -14
  26. gvm/protocols/gmpv208/entities/results.py +1 -14
  27. gvm/protocols/gmpv208/entities/roles.py +1 -14
  28. gvm/protocols/gmpv208/entities/scan_configs.py +1 -14
  29. gvm/protocols/gmpv208/entities/scanners.py +1 -14
  30. gvm/protocols/gmpv208/entities/schedules.py +1 -14
  31. gvm/protocols/gmpv208/entities/secinfo.py +3 -32
  32. gvm/protocols/gmpv208/entities/severity.py +2 -35
  33. gvm/protocols/gmpv208/entities/tags.py +1 -14
  34. gvm/protocols/gmpv208/entities/targets.py +1 -15
  35. gvm/protocols/gmpv208/entities/tasks.py +1 -15
  36. gvm/protocols/gmpv208/entities/tickets.py +5 -35
  37. gvm/protocols/gmpv208/entities/tls_certificates.py +1 -15
  38. gvm/protocols/gmpv208/entities/users.py +3 -34
  39. gvm/protocols/gmpv208/entities/vulnerabilities.py +1 -14
  40. gvm/protocols/gmpv208/system/__init__.py +1 -14
  41. gvm/protocols/gmpv208/system/aggregates.py +3 -61
  42. gvm/protocols/gmpv208/system/authentication.py +1 -14
  43. gvm/protocols/gmpv208/system/feed.py +3 -30
  44. gvm/protocols/gmpv208/system/help.py +3 -37
  45. gvm/protocols/gmpv208/system/system_reports.py +1 -14
  46. gvm/protocols/gmpv208/system/trashcan.py +1 -14
  47. gvm/protocols/gmpv208/system/user_settings.py +1 -14
  48. gvm/protocols/gmpv208/system/version.py +1 -14
  49. gvm/protocols/gmpv214/__init__.py +1 -14
  50. gvm/protocols/gmpv214/entities/__init__.py +1 -14
  51. gvm/protocols/gmpv214/entities/notes.py +1 -15
  52. gvm/protocols/gmpv214/entities/overrides.py +1 -15
  53. gvm/protocols/gmpv214/entities/scanners.py +1 -14
  54. gvm/protocols/gmpv214/entities/targets.py +1 -14
  55. gvm/protocols/gmpv214/entities/users.py +1 -14
  56. gvm/protocols/gmpv214/system/__init__.py +1 -14
  57. gvm/protocols/gmpv214/system/version.py +1 -14
  58. gvm/protocols/gmpv224/__init__.py +1 -14
  59. gvm/protocols/gmpv224/entities/__init__.py +1 -14
  60. gvm/protocols/gmpv224/entities/scan_configs.py +1 -14
  61. gvm/protocols/gmpv224/entities/scanners.py +1 -14
  62. gvm/protocols/gmpv224/entities/users.py +1 -14
  63. gvm/protocols/gmpv224/system/__init__.py +1 -14
  64. gvm/protocols/gmpv224/system/version.py +1 -14
  65. gvm/protocols/gmpv225/__init__.py +1 -14
  66. gvm/protocols/gmpv225/entities/__init__.py +1 -14
  67. gvm/protocols/gmpv225/entities/resourcenames.py +13 -46
  68. gvm/protocols/gmpv225/system/__init__.py +1 -14
  69. gvm/protocols/gmpv225/system/version.py +1 -15
  70. gvm/protocols/latest.py +2 -15
  71. gvm/protocols/next.py +1 -14
  72. gvm/protocols/ospv1.py +6 -23
  73. gvm/transforms.py +1 -14
  74. gvm/utils.py +2 -14
  75. gvm/xml.py +1 -14
  76. {python_gvm-23.12.0.dist-info → python_gvm-24.3.0.dist-info}/METADATA +5 -6
  77. python_gvm-24.3.0.dist-info/RECORD +80 -0
  78. {python_gvm-23.12.0.dist-info → python_gvm-24.3.0.dist-info}/WHEEL +1 -1
  79. python_gvm-23.12.0.dist-info/RECORD +0 -79
  80. {python_gvm-23.12.0.dist-info → python_gvm-24.3.0.dist-info}/LICENSE +0 -0
gvm/__init__.py CHANGED
@@ -1,20 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2018-2022 Greenbone AG
1
+ # SPDX-FileCopyrightText: 2018-2024 Greenbone AG
3
2
  #
4
3
  # SPDX-License-Identifier: GPL-3.0-or-later
5
4
  #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
5
  """
19
6
  Main module of python-gvm.
20
7
  """
gvm/__version__.py CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  # THIS IS AN AUTOGENERATED FILE. DO NOT TOUCH!
4
4
 
5
- __version__ = "23.12.0"
5
+ __version__ = "24.3.0"
gvm/_enum.py ADDED
@@ -0,0 +1,38 @@
1
+ # SPDX-FileCopyrightText: 2024 Greenbone AG
2
+ #
3
+ # SPDX-License-Identifier: GPL-3.0-or-later
4
+ #
5
+
6
+ from enum import Enum as PythonEnum
7
+ from typing import Optional
8
+
9
+ from typing_extensions import Self
10
+
11
+ from gvm.errors import InvalidArgument
12
+
13
+
14
+ class Enum(PythonEnum):
15
+ """
16
+ Base class for Enums in python-gvm
17
+ """
18
+
19
+ @classmethod
20
+ def from_string(
21
+ cls,
22
+ value: Optional[str],
23
+ ) -> Optional[Self]:
24
+ """
25
+ Convert a string value into an Enum instance
26
+
27
+ If value is None or empty None is returned
28
+ """
29
+ if not value:
30
+ return None
31
+
32
+ try:
33
+ return cls[value.replace(" ", "_").upper()]
34
+ except KeyError:
35
+ raise InvalidArgument(
36
+ f"Invalid argument {value} for {cls.__name__}.from_string. "
37
+ f"Allowed values are {','.join(e.name for e in cls)}."
38
+ ) from None
gvm/connections.py CHANGED
@@ -1,20 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2018-2022 Greenbone AG
1
+ # SPDX-FileCopyrightText: 2018-2024 Greenbone AG
3
2
  #
4
3
  # SPDX-License-Identifier: GPL-3.0-or-later
5
4
  #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
5
  """
19
6
  Module for connections to GVM server daemons like gvmd and ospd.
20
7
  """
@@ -26,11 +13,14 @@ import socket as socketlib
26
13
  import ssl
27
14
  import sys
28
15
  import time
16
+ from abc import ABC, abstractmethod
17
+ from os import PathLike
29
18
  from pathlib import Path
30
- from typing import Optional, Union
19
+ from typing import Optional, Protocol, Union, runtime_checkable
31
20
 
32
21
  import paramiko
33
22
  import paramiko.ssh_exception
23
+ import paramiko.transport
34
24
  from lxml import etree
35
25
 
36
26
  from gvm.errors import GvmError
@@ -49,13 +39,28 @@ DEFAULT_HOSTNAME = "127.0.0.1"
49
39
  DEFAULT_KNOWN_HOSTS_FILE = ".ssh/known_hosts"
50
40
  MAX_SSH_DATA_LENGTH = 4095
51
41
 
42
+ Data = Union[str, bytes]
43
+
44
+
45
+ @runtime_checkable
46
+ class GvmConnection(Protocol):
47
+ def connect(self) -> None: ...
48
+
49
+ def disconnect(self) -> None: ...
50
+
51
+ def send(self, data: Data) -> None: ...
52
+
53
+ def read(self) -> str: ...
54
+
55
+ def finish_send(self): ...
56
+
52
57
 
53
58
  class XmlReader:
54
59
  """
55
60
  Read a XML command until its closing element
56
61
  """
57
62
 
58
- def _start_xml(self):
63
+ def start_xml(self) -> None:
59
64
  self._first_element = None
60
65
  # act on start and end element events and
61
66
  # allow huge text data (for report content)
@@ -63,7 +68,7 @@ class XmlReader:
63
68
  events=("start", "end"), huge_tree=True
64
69
  )
65
70
 
66
- def _is_end_xml(self):
71
+ def is_end_xml(self) -> bool:
67
72
  for action, obj in self._parser.read_events():
68
73
  if not self._first_element and action in "start":
69
74
  self._first_element = obj.tag
@@ -76,7 +81,7 @@ class XmlReader:
76
81
  return True
77
82
  return False
78
83
 
79
- def _feed_xml(self, data):
84
+ def feed_xml(self, data: Data) -> None:
80
85
  try:
81
86
  self._parser.feed(data)
82
87
  except etree.ParseError as e:
@@ -86,7 +91,7 @@ class XmlReader:
86
91
  ) from None
87
92
 
88
93
 
89
- class GvmConnection(XmlReader):
94
+ class AbstractGvmConnection(ABC):
90
95
  """
91
96
  Base class for establishing a connection to a remote server daemon.
92
97
 
@@ -95,18 +100,23 @@ class GvmConnection(XmlReader):
95
100
  wait indefinitely
96
101
  """
97
102
 
98
- def __init__(self, timeout: Optional[int] = DEFAULT_TIMEOUT):
103
+ def __init__(self, timeout: Optional[Union[int, float]] = DEFAULT_TIMEOUT):
99
104
  self._socket = None
100
105
  self._timeout = timeout if timeout is not None else DEFAULT_TIMEOUT
106
+ self._xml_reader = XmlReader()
101
107
 
102
108
  def _read(self) -> bytes:
109
+ if self._socket is None:
110
+ raise GvmError("Socket is not connected")
111
+
103
112
  return self._socket.recv(BUF_SIZE)
104
113
 
105
- def connect(self):
114
+ @abstractmethod
115
+ def connect(self) -> None:
106
116
  """Establish a connection to a remote server"""
107
117
  raise NotImplementedError
108
118
 
109
- def send(self, data: Union[bytes, str]) -> None:
119
+ def send(self, data: Data) -> None:
110
120
  """Send data to the connected remote server
111
121
 
112
122
  Arguments:
@@ -117,9 +127,9 @@ class GvmConnection(XmlReader):
117
127
  raise GvmError("Socket is not connected")
118
128
 
119
129
  if isinstance(data, str):
120
- return self._socket.sendall(data.encode())
130
+ self._socket.sendall(data.encode())
121
131
  else:
122
- return self._socket.sendall(data)
132
+ self._socket.sendall(data)
123
133
 
124
134
  def read(self) -> str:
125
135
  """Read data from the remote server
@@ -129,12 +139,11 @@ class GvmConnection(XmlReader):
129
139
  """
130
140
  response = ""
131
141
 
132
- self._start_xml()
142
+ self._xml_reader.start_xml()
133
143
 
134
- if self._timeout is not None:
135
- now = time.time()
136
-
137
- break_timeout = now + self._timeout
144
+ break_timeout = (
145
+ time.time() + self._timeout if self._timeout is not None else None
146
+ )
138
147
 
139
148
  while True:
140
149
  data = self._read()
@@ -143,19 +152,19 @@ class GvmConnection(XmlReader):
143
152
  # Connection was closed by server
144
153
  raise GvmError("Remote closed the connection")
145
154
 
146
- self._feed_xml(data)
155
+ self._xml_reader.feed_xml(data)
147
156
 
148
157
  response += data.decode("utf-8", errors="ignore")
149
158
 
150
- if self._is_end_xml():
159
+ if self._xml_reader.is_end_xml():
151
160
  break
152
161
 
153
- if time.time() > break_timeout:
162
+ if break_timeout and time.time() > break_timeout:
154
163
  raise GvmError("Timeout while reading the response")
155
164
 
156
165
  return response
157
166
 
158
- def disconnect(self):
167
+ def disconnect(self) -> None:
159
168
  """Disconnect and close the connection to the remote server"""
160
169
  try:
161
170
  if self._socket is not None:
@@ -165,11 +174,12 @@ class GvmConnection(XmlReader):
165
174
 
166
175
  def finish_send(self):
167
176
  """Indicate to the remote server you are done with sending data"""
168
- # shutdown socket for sending. only allow reading data afterwards
169
- self._socket.shutdown(socketlib.SHUT_WR)
177
+ if self._socket is not None:
178
+ # shutdown socket for sending. only allow reading data afterwards
179
+ self._socket.shutdown(socketlib.SHUT_WR)
170
180
 
171
181
 
172
- class SSHConnection(GvmConnection):
182
+ class SSHConnection(AbstractGvmConnection):
173
183
  """
174
184
  SSH Class to connect, read and write from GVM via SSH
175
185
 
@@ -179,22 +189,21 @@ class SSHConnection(GvmConnection):
179
189
  127.0.0.1.
180
190
  port: Port of the remote SSH server. Default is port 22.
181
191
  username: Username to use for SSH login. Default is "gmp".
182
- password: Passwort to use for SSH login. Default is "".
192
+ password: Password to use for SSH login. Default is "".
183
193
  """
184
194
 
185
195
  def __init__(
186
196
  self,
187
197
  *,
188
- timeout: Optional[int] = DEFAULT_TIMEOUT,
198
+ timeout: Optional[Union[int, float]] = DEFAULT_TIMEOUT,
189
199
  hostname: Optional[str] = DEFAULT_HOSTNAME,
190
200
  port: Optional[int] = DEFAULT_SSH_PORT,
191
201
  username: Optional[str] = DEFAULT_SSH_USERNAME,
192
202
  password: Optional[str] = DEFAULT_SSH_PASSWORD,
193
- known_hosts_file: Optional[str] = None,
203
+ known_hosts_file: Optional[Union[str, PathLike]] = None,
194
204
  auto_accept_host: Optional[bool] = None,
195
- ):
196
- super().__init__(timeout=timeout)
197
-
205
+ ) -> None:
206
+ super().__init__(timeout)
198
207
  self.hostname = hostname if hostname is not None else DEFAULT_HOSTNAME
199
208
  self.port = int(port) if port is not None else DEFAULT_SSH_PORT
200
209
  self.username = (
@@ -210,7 +219,7 @@ class SSHConnection(GvmConnection):
210
219
  )
211
220
  self.auto_accept_host = auto_accept_host
212
221
 
213
- def _send_all(self, data) -> int:
222
+ def _send_all(self, data: bytes) -> int:
214
223
  """Returns the sum of sent bytes if success"""
215
224
  sent_sum = 0
216
225
  while data:
@@ -237,13 +246,15 @@ class SSHConnection(GvmConnection):
237
246
  key,
238
247
  )
239
248
  try:
240
- hostkeys.save(filename=self.known_hosts_file)
249
+ hostkeys.save(filename=str(self.known_hosts_file))
241
250
  except OSError as e:
242
251
  raise GvmError(
243
252
  "Something went wrong with writing "
244
253
  f"the known_hosts file: {e}"
245
254
  ) from None
255
+
246
256
  key_type = key.get_name().replace("ssh-", "").upper()
257
+
247
258
  logger.info(
248
259
  "Warning: Permanently added '%s' (%s) to "
249
260
  "the list of known hosts.",
@@ -260,12 +271,14 @@ class SSHConnection(GvmConnection):
260
271
  hashlib.sha256(base64.b64decode(key.get_base64())).digest()
261
272
  ).decode("utf-8")[:-1]
262
273
  key_type = key.get_name().replace("ssh-", "").upper()
274
+
263
275
  print(
264
276
  f"The authenticity of host '{self.hostname}' can't "
265
277
  "be established."
266
278
  )
267
279
  print(f"{key_type} key fingerprint is {sha64_fingerprint}.")
268
280
  print("Are you sure you want to continue connecting (yes/no)? ", end="")
281
+
269
282
  add = input()
270
283
  while True:
271
284
  if add == "yes":
@@ -277,22 +290,25 @@ class SSHConnection(GvmConnection):
277
290
  key.get_name(),
278
291
  key,
279
292
  )
293
+
280
294
  # ask user if the key should be added permanently
281
295
  print(
282
296
  f"Do you want to add {self.hostname} "
283
297
  "to known_hosts (yes/no)? ",
284
298
  end="",
285
299
  )
300
+
286
301
  save = input()
287
302
  while True:
288
303
  if save == "yes":
289
304
  try:
290
- hostkeys.save(filename=self.known_hosts_file)
305
+ hostkeys.save(filename=str(self.known_hosts_file))
291
306
  except OSError as e:
292
307
  raise GvmError(
293
308
  "Something went wrong with writing "
294
309
  f"the known_hosts file: {e}"
295
310
  ) from None
311
+
296
312
  logger.info(
297
313
  "Warning: Permanently added '%s' (%s) to "
298
314
  "the list of known hosts.",
@@ -313,14 +329,12 @@ class SSHConnection(GvmConnection):
313
329
  save = input()
314
330
  break
315
331
  elif add == "no":
316
- return sys.exit(
317
- "User denied key. Host key verification failed."
318
- )
332
+ sys.exit("User denied key. Host key verification failed.")
319
333
  else:
320
334
  print("Please type 'yes' or 'no': ", end="")
321
335
  add = input()
322
336
 
323
- def _get_remote_host_key(self):
337
+ def _get_remote_host_key(self) -> paramiko.PKey:
324
338
  """Get the remote host key for ssh connection"""
325
339
  try:
326
340
  tmp_socket = socketlib.socket()
@@ -357,7 +371,7 @@ class SSHConnection(GvmConnection):
357
371
  # https://stackoverflow.com/q/32945533
358
372
  try:
359
373
  # load the keys into paramiko and check if remote is in the list
360
- self._socket.load_host_keys(filename=self.known_hosts_file)
374
+ self._socket.load_host_keys(filename=str(self.known_hosts_file))
361
375
  except OSError as e:
362
376
  if e.errno != errno.ENOENT:
363
377
  raise GvmError(
@@ -414,10 +428,13 @@ class SSHConnection(GvmConnection):
414
428
  def _read(self) -> bytes:
415
429
  return self._stdout.channel.recv(BUF_SIZE)
416
430
 
417
- def send(self, data: Union[bytes, str]) -> int:
418
- return self._send_all(data)
431
+ def send(self, data: Data) -> None:
432
+ if isinstance(data, str):
433
+ self._send_all(data.encode())
434
+ else:
435
+ self._send_all(data)
419
436
 
420
- def finish_send(self):
437
+ def finish_send(self) -> None:
421
438
  # shutdown socket for sending. only allow reading data afterwards
422
439
  self._stdout.channel.shutdown(socketlib.SHUT_WR)
423
440
 
@@ -436,7 +453,7 @@ class SSHConnection(GvmConnection):
436
453
  del self._socket, self._stdin, self._stdout, self._stderr
437
454
 
438
455
 
439
- class TLSConnection(GvmConnection):
456
+ class TLSConnection(AbstractGvmConnection):
440
457
  """
441
458
  TLS class to connect, read and write from a remote GVM daemon via TLS
442
459
  secured socket.
@@ -468,8 +485,8 @@ class TLSConnection(GvmConnection):
468
485
  hostname: Optional[str] = DEFAULT_HOSTNAME,
469
486
  port: Optional[int] = DEFAULT_GVM_PORT,
470
487
  password: Optional[str] = None,
471
- timeout: Optional[int] = DEFAULT_TIMEOUT,
472
- ):
488
+ timeout: Optional[Union[int, float]] = DEFAULT_TIMEOUT,
489
+ ) -> None:
473
490
  super().__init__(timeout=timeout)
474
491
 
475
492
  self.hostname = hostname if hostname is not None else DEFAULT_HOSTNAME
@@ -507,7 +524,7 @@ class TLSConnection(GvmConnection):
507
524
 
508
525
  return sock
509
526
 
510
- def connect(self):
527
+ def connect(self) -> None:
511
528
  self._socket = self._new_socket()
512
529
  self._socket.connect((self.hostname, int(self.port)))
513
530
 
@@ -518,10 +535,10 @@ class TLSConnection(GvmConnection):
518
535
  self._socket = self._socket.unwrap()
519
536
  except OSError as e:
520
537
  logger.debug("Connection closing error: %s", e)
521
- return super(TLSConnection, self).disconnect()
538
+ return super().disconnect()
522
539
 
523
540
 
524
- class UnixSocketConnection(GvmConnection):
541
+ class UnixSocketConnection(AbstractGvmConnection):
525
542
  """
526
543
  UNIX-Socket class to connect, read, write from a daemon via direct
527
544
  communicating UNIX-Socket
@@ -535,7 +552,7 @@ class UnixSocketConnection(GvmConnection):
535
552
  self,
536
553
  *,
537
554
  path: Optional[str] = DEFAULT_UNIX_SOCKET_PATH,
538
- timeout: Optional[int] = DEFAULT_TIMEOUT,
555
+ timeout: Optional[Union[int, float]] = DEFAULT_TIMEOUT,
539
556
  ) -> None:
540
557
  super().__init__(timeout=timeout)
541
558
 
@@ -574,8 +591,8 @@ class DebugConnection:
574
591
 
575
592
  logging.basicConfig(level=logging.DEBUG)
576
593
 
577
- socketconnection = UnixSocketConnection(path='/var/run/gvm.sock')
578
- connection = DebugConnection(socketconnection)
594
+ socket_connection = UnixSocketConnection(path='/var/run/gvm.sock')
595
+ connection = DebugConnection(socket_connection)
579
596
  gmp = Gmp(connection=connection)
580
597
 
581
598
  Arguments:
@@ -596,24 +613,24 @@ class DebugConnection:
596
613
  self.last_read_data = data
597
614
  return data
598
615
 
599
- def send(self, data):
616
+ def send(self, data: Data) -> None:
600
617
  self.last_send_data = data
601
618
 
602
619
  logger.debug("Sending %s characters. Data %s", len(data), data)
603
620
 
604
621
  return self._connection.send(data)
605
622
 
606
- def connect(self):
623
+ def connect(self) -> None:
607
624
  logger.debug("Connecting")
608
625
 
609
626
  return self._connection.connect()
610
627
 
611
- def disconnect(self):
628
+ def disconnect(self) -> None:
612
629
  logger.debug("Disconnecting")
613
630
 
614
631
  return self._connection.disconnect()
615
632
 
616
- def finish_send(self):
633
+ def finish_send(self) -> None:
617
634
  logger.debug("Finish send")
618
635
 
619
636
  self._connection.finish_send()
gvm/errors.py CHANGED
@@ -1,20 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2018-2022 Greenbone AG
1
+ # SPDX-FileCopyrightText: 2018-2024 Greenbone AG
3
2
  #
4
3
  # SPDX-License-Identifier: GPL-3.0-or-later
5
4
  #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
5
  """
19
6
  Module for GVM errors
20
7
  """
@@ -150,7 +137,7 @@ class InvalidArgumentType(GvmError):
150
137
  *,
151
138
  function: Optional[str] = None,
152
139
  ):
153
- # pylint: disable=super-init-not-called
140
+ super().__init__(None)
154
141
  self.argument = argument
155
142
  self.function = function
156
143
  self.arg_type = arg_type
gvm/protocols/__init__.py CHANGED
@@ -1,25 +1,12 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2018-2022 Greenbone AG
1
+ # SPDX-FileCopyrightText: 2018-2024 Greenbone AG
3
2
  #
4
3
  # SPDX-License-Identifier: GPL-3.0-or-later
5
4
  #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
5
  """
19
6
  Package for supported Greenbone Protocol versions.
20
7
 
21
8
  Currently `GMP version 20.08`_, `GMP version 21.04`_
22
- `GMP version 22.04`, `GMP version 22.05`
9
+ `GMP version 22.04`_, `GMP version 22.05`_
23
10
  and `OSP version 1`_ are supported.
24
11
 
25
12
  .. _GMP version 20.08:
gvm/protocols/base.py CHANGED
@@ -1,20 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2018-2022 Greenbone AG
1
+ # SPDX-FileCopyrightText: 2018-2024 Greenbone AG
3
2
  #
4
3
  # SPDX-License-Identifier: GPL-3.0-or-later
5
4
  #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
5
 
19
6
  from typing import Any, Callable, Optional
20
7
 
gvm/protocols/gmp.py CHANGED
@@ -1,20 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2019-2022 Greenbone AG
1
+ # SPDX-FileCopyrightText: 2019-2024 Greenbone AG
3
2
  #
4
3
  # SPDX-License-Identifier: GPL-3.0-or-later
5
4
  #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
5
 
19
6
  """
20
7
  Module for communication with gvmd
@@ -1,20 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2018-2022 Greenbone AG
1
+ # SPDX-FileCopyrightText: 2018-2024 Greenbone AG
3
2
  #
4
3
  # SPDX-License-Identifier: GPL-3.0-or-later
5
4
  #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
5
 
19
6
  # pylint: disable=too-many-lines,redefined-builtin
20
7
  """
@@ -1,17 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright (C) 2021-2022 Greenbone AG
1
+ # SPDX-FileCopyrightText: 2021-2024 Greenbone AG
3
2
  #
4
3
  # SPDX-License-Identifier: GPL-3.0-or-later
5
4
  #
6
- # This program is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # This program is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program. If not, see <http://www.gnu.org/licenses/>.