Skip to content

Commit c9823f0

Browse files
timopollmeierbjoernricks
authored andcommitted
Add: New GMP version 22.8 with agent installers
This adds the GMP version 22.8 with the new commands get_agent_installer, get_agent_installer_file and get_agent_installers.
1 parent 9a3da9d commit c9823f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3267
-10
lines changed

docs/api/gmp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ gmpv224
1818
gmpv225
1919
gmpv226
2020
gmpv227
21+
gmpv228
2122
```

docs/api/gmpv228.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
(gmpv228)=
2+
3+
# GMP v22.8
4+
5+
```{eval-rst}
6+
.. automodule:: gvm.protocols.gmp._gmp228
7+
```
8+
9+
## Protocol
10+
11+
```{eval-rst}
12+
.. autoclass:: gvm.protocols.gmp.GMPv228
13+
:members:
14+
:inherited-members:
15+
```
16+
17+
## Enums
18+
19+
```{eval-rst}
20+
.. autoclass:: gvm.protocols.gmp.requests.v228.AlertCondition
21+
:members:
22+
:undoc-members:
23+
:no-index:
24+
```
25+
26+
```{eval-rst}
27+
.. autoclass:: gvm.protocols.gmp.requests.v228.AlertEvent
28+
:members:
29+
:undoc-members:
30+
:no-index:
31+
```
32+
33+
```{eval-rst}
34+
.. autoclass:: gvm.protocols.gmp.requests.v228.AlertMethod
35+
:members:
36+
:undoc-members:
37+
:no-index:
38+
```
39+
40+
```{eval-rst}
41+
.. autoclass:: gvm.protocols.gmp.requests.v228.AliveTest
42+
:members:
43+
:undoc-members:
44+
:no-index:
45+
```
46+
47+
```{eval-rst}
48+
.. autoclass:: gvm.protocols.gmp.requests.v228.CredentialFormat
49+
:members:
50+
:undoc-members:
51+
:no-index:
52+
```
53+
54+
```{eval-rst}
55+
.. autoclass:: gvm.protocols.gmp.requests.v228.CredentialType
56+
:members:
57+
:undoc-members:
58+
:no-index:
59+
```
60+
61+
```{eval-rst}
62+
.. autoclass:: gvm.protocols.gmp.requests.v228.EntityType
63+
:members:
64+
:undoc-members:
65+
:no-index:
66+
```
67+
68+
```{eval-rst}
69+
.. autoclass:: gvm.protocols.gmp.requests.v228.FeedType
70+
:members:
71+
:undoc-members:
72+
:no-index:
73+
```
74+
75+
```{eval-rst}
76+
.. autoclass:: gvm.protocols.gmp.requests.v228.FilterType
77+
:members:
78+
:undoc-members:
79+
:no-index:
80+
```
81+
82+
```{eval-rst}
83+
.. autoclass:: gvm.protocols.gmp.requests.v228.HostsOrdering
84+
:members:
85+
:undoc-members:
86+
:no-index:
87+
```
88+
89+
```{eval-rst}
90+
.. autoclass:: gvm.protocols.gmp.requests.v228.HelpFormat
91+
:members:
92+
:undoc-members:
93+
:no-index:
94+
```
95+
96+
```{eval-rst}
97+
.. autoclass:: gvm.protocols.gmp.requests.v228.InfoType
98+
:members:
99+
:undoc-members:
100+
:no-index:
101+
```
102+
103+
```{eval-rst}
104+
.. autoclass:: gvm.protocols.gmp.requests.v228.PermissionSubjectType
105+
:members:
106+
:undoc-members:
107+
:no-index:
108+
```
109+
110+
```{eval-rst}
111+
.. autoclass:: gvm.protocols.gmp.requests.v228.PortRangeType
112+
:members:
113+
:undoc-members:
114+
:no-index:
115+
```
116+
117+
```{eval-rst}
118+
.. autoclass:: gvm.protocols.gmp.requests.v228.ReportFormatType
119+
:members:
120+
:undoc-members:
121+
:no-index:
122+
```
123+
124+
```{eval-rst}
125+
.. autoclass:: gvm.protocols.gmp.requests.v228.ResourceType
126+
:members:
127+
:undoc-members:
128+
:no-index:
129+
```
130+
131+
```{eval-rst}
132+
.. autoclass:: gvm.protocols.gmp.requests.v228.ScannerType
133+
:members:
134+
:undoc-members:
135+
:no-index:
136+
```
137+
138+
```{eval-rst}
139+
.. autoclass:: gvm.protocols.gmp.requests.v228.SnmpAuthAlgorithm
140+
:members:
141+
:undoc-members:
142+
:no-index:
143+
```
144+
145+
```{eval-rst}
146+
.. autoclass:: gvm.protocols.gmp.requests.v228.SnmpPrivacyAlgorithm
147+
:members:
148+
:undoc-members:
149+
:no-index:
150+
```
151+
152+
```{eval-rst}
153+
.. autoclass:: gvm.protocols.gmp.requests.v228.TicketStatus
154+
:members:
155+
:undoc-members:
156+
:no-index:
157+
```

gvm/protocols/gmp/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@
99
dynamically selects the supported GMP protocol of the remote manager daemon.
1010
1111
If you need to use a specific GMP version, you can use the :class:`GMPv224`,
12-
:class:`GMPv225`, :class:`GMPv226` or :class:`GMPv227` classes.
12+
:class:`GMPv225`, :class:`GMPv226`, :class:`GMPv227` or :class:`GMPv228` classes.
1313
1414
* :class:`GMP` - Dynamically select supported GMP protocol of the remote manager daemon.
1515
* :class:`GMPv224` - GMP version 22.4
1616
* :class:`GMPv225` - GMP version 22.5
1717
* :class:`GMPv226` - GMP version 22.6
1818
* :class:`GMPv227` - GMP version 22.7
19+
* :class:`GMPv228` - GMP version 22.8
1920
"""
2021

2122
from ._gmp import GMP
2223
from ._gmp224 import GMPv224
2324
from ._gmp225 import GMPv225
2425
from ._gmp226 import GMPv226
2526
from ._gmp227 import GMPv227
27+
from ._gmp228 import GMPv228
2628

2729
Gmp = GMP # for backwards compatibility
2830

@@ -33,4 +35,5 @@
3335
"GMPv225",
3436
"GMPv226",
3537
"GMPv227",
38+
"GMPv228",
3639
)

gvm/protocols/gmp/_gmp.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
from ._gmp225 import GMPv225
1717
from ._gmp226 import GMPv226
1818
from ._gmp227 import GMPv227
19+
from ._gmp228 import GMPv228
1920
from .requests import Version
2021

21-
SUPPORTED_GMP_VERSIONS = Union[GMPv224[T], GMPv225[T], GMPv226[T], GMPv227[T]]
22-
_SUPPORTED_GMP_VERSION_STRINGS = ["22.4", "22.5", "22.6", "22.7"]
22+
SUPPORTED_GMP_VERSIONS = Union[
23+
GMPv224[T], GMPv225[T], GMPv226[T], GMPv227[T], GMPv228[T]
24+
]
25+
_SUPPORTED_GMP_VERSION_STRINGS = ["22.4", "22.5", "22.6", "22.7", "22.8"]
2326

2427

2528
class GMP(GvmProtocol[T]):
@@ -38,7 +41,8 @@ class GMP(GvmProtocol[T]):
3841
# gvm.protocols.gmp.GMPv224,
3942
# gvm.protocols.gmp.GMPv225,
4043
# gvm.protocols.gmp.GMPv226,
41-
# or gvm.protocols.gmp.GMPv227
44+
# gvm.protocols.gmp.GMPv227,
45+
# or gvm.protocols.gmp.GMPv228
4246
# depending on the supported GMP version of the remote manager daemon
4347
resp = gmp.get_tasks()
4448
"""
@@ -93,9 +97,11 @@ def determine_supported_gmp(self) -> SUPPORTED_GMP_VERSIONS:
9397
gmp_class = GMPv225
9498
elif major_version == 22 and minor_version == 6:
9599
gmp_class = GMPv226
96-
elif major_version == 22 and minor_version >= 7:
100+
elif major_version == 22 and minor_version == 7:
97101
gmp_class = GMPv227
98-
if minor_version > 7:
102+
elif major_version == 22 and minor_version >= 8:
103+
gmp_class = GMPv228
104+
if minor_version > 8:
99105
warnings.warn(
100106
"Remote manager daemon uses a newer GMP version than "
101107
f"supported by python-gvm {__version__}. Please update to "

gvm/protocols/gmp/_gmp228.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# SPDX-FileCopyrightText: 2025 Greenbone AG
2+
#
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
from typing import Optional
6+
7+
from gvm.protocols.gmp.requests import EntityID
8+
9+
from .._protocol import T
10+
from ._gmp227 import GMPv227
11+
from .requests.v228 import AgentInstallers
12+
13+
14+
class GMPv228(GMPv227[T]):
15+
"""
16+
A class implementing the Greenbone Management Protocol (GMP) version 22.8
17+
18+
Example:
19+
20+
.. code-block:: python
21+
22+
from gvm.protocols.gmp import GMPv228 as GMP
23+
24+
with GMP(connection) as gmp:
25+
resp = gmp.get_tasks()
26+
"""
27+
28+
@staticmethod
29+
def get_protocol_version() -> tuple[int, int]:
30+
return (22, 8)
31+
32+
def get_agent_installers(
33+
self,
34+
*,
35+
filter_string: Optional[str] = None,
36+
filter_id: Optional[EntityID] = None,
37+
trash: Optional[bool] = None,
38+
details: Optional[bool] = None,
39+
) -> T:
40+
"""Request a list of agent installers
41+
42+
Args:
43+
filter_string: Filter term to use for the query
44+
filter_id: UUID of an existing filter to use for the query
45+
trash: Whether to get the trashcan agent installers instead
46+
details: Whether to include extra details like tasks using this
47+
scanner
48+
"""
49+
return self._send_request_and_transform_response(
50+
AgentInstallers.get_agent_installers(
51+
filter_string=filter_string,
52+
filter_id=filter_id,
53+
trash=trash,
54+
details=details,
55+
)
56+
)
57+
58+
def get_agent_installer(self, agent_installer_id: EntityID) -> T:
59+
"""Request a single agent installer
60+
61+
Args:
62+
agent_installer_id: UUID of an existing agent installer
63+
"""
64+
return self._send_request_and_transform_response(
65+
AgentInstallers.get_agent_installer(agent_installer_id)
66+
)
67+
68+
def get_agent_installer_file(self, agent_installer_id: EntityID) -> T:
69+
"""Request a single agent installer file
70+
71+
Args:
72+
agent_installer_id: UUID of an existing agent installer
73+
"""
74+
return self._send_request_and_transform_response(
75+
AgentInstallers.get_agent_installer_file(agent_installer_id)
76+
)

0 commit comments

Comments
 (0)