Skip to content

Commit 80ad3c7

Browse files
committed
Merge branch 'main' into add-openvasd
2 parents 3246e52 + b022e8a commit 80ad3c7

Some content is hidden

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

71 files changed

+3777
-22
lines changed

gvm/protocols/gmp/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88
In most circumstances you will want to use the :class:`GMP` class which
99
dynamically selects the supported GMP protocol of the remote manager daemon.
1010
11-
If you need to use a specific GMP version, you can use the :class:`GMPv224` or
12-
:class:`GMPv225` classes.
11+
If you need to use a specific GMP version, you can use the :class:`GMPv224`,
12+
:class:`GMPv225`, :class:`GMPv226` or :class:`GMPv227` 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
17+
* :class:`GMPv226` - GMP version 22.6
18+
* :class:`GMPv227` - GMP version 22.7
1719
"""
1820

1921
from ._gmp import GMP
2022
from ._gmp224 import GMPv224
2123
from ._gmp225 import GMPv225
2224
from ._gmp226 import GMPv226
25+
from ._gmp227 import GMPv227
2326

2427
Gmp = GMP # for backwards compatibility
2528

@@ -29,4 +32,5 @@
2932
"GMPv224",
3033
"GMPv225",
3134
"GMPv226",
35+
"GMPv227",
3236
)

gvm/protocols/gmp/_gmp.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
from ._gmp224 import GMPv224
1616
from ._gmp225 import GMPv225
1717
from ._gmp226 import GMPv226
18+
from ._gmp227 import GMPv227
1819
from .requests import Version
1920

20-
SUPPORTED_GMP_VERSIONS = Union[GMPv224[T], GMPv225[T], GMPv226[T]]
21-
_SUPPORTED_GMP_VERSION_STRINGS = ["22.4", "22.5", "22.6"]
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"]
2223

2324

2425
class GMP(GvmProtocol[T]):
@@ -36,8 +37,9 @@ class GMP(GvmProtocol[T]):
3637
with GMP(connection) as gmp:
3738
# gmp can be an instance of
3839
# gvm.protocols.gmp.GMPv224,
39-
# gvm.protocols.gmp.GMPv225
40-
# or gvm.protocols.gmp.GMPv226
40+
# gvm.protocols.gmp.GMPv225,
41+
# gvm.protocols.gmp.GMPv226,
42+
# or gvm.protocols.gmp.GMPv227
4143
# depending on the supported GMP version of the remote manager daemon
4244
resp = gmp.get_tasks()
4345

gvm/protocols/gmp/_gmp227.py

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# SPDX-FileCopyrightText: 2025 Greenbone AG
2+
#
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
"""
6+
Greenbone Management Protocol (GMP) version 22.7
7+
"""
8+
9+
from typing import Optional, Union
10+
11+
from .._protocol import T
12+
from ._gmp226 import GMPv226
13+
from .requests.v227 import (
14+
EntityID,
15+
Scanners,
16+
ScannerType,
17+
)
18+
19+
20+
class GMPv227(GMPv226[T]):
21+
"""
22+
A class implementing the Greenbone Management Protocol (GMP) version 22.7
23+
24+
Example:
25+
26+
.. code-block:: python
27+
28+
from gvm.protocols.gmp import GMPv227 as GMP
29+
30+
with GMP(connection) as gmp:
31+
resp = gmp.get_tasks()
32+
"""
33+
34+
@staticmethod
35+
def get_protocol_version() -> tuple[int, int]:
36+
return (22, 7)
37+
38+
def create_scanner( # type:ignore[override]
39+
self,
40+
name: str,
41+
host: str,
42+
port: Union[str, int],
43+
scanner_type: ScannerType,
44+
credential_id: str,
45+
*,
46+
ca_pub: Optional[str] = None,
47+
comment: Optional[str] = None,
48+
relay_host: Optional[str] = None,
49+
relay_port: Optional[Union[str, int]] = None,
50+
) -> T:
51+
"""Create a new scanner
52+
53+
Args:
54+
name: Name of the new scanner
55+
host: Hostname or IP address of the scanner
56+
port: Port of the scanner
57+
scanner_type: Type of the scanner
58+
credential_id: UUID of client certificate credential for the
59+
scanner
60+
ca_pub: Certificate of CA to verify scanner certificate
61+
comment: Comment for the scanner
62+
relay_host: Hostname or IP address of the scanner relay
63+
relay_port: Port of the scanner relay
64+
"""
65+
return self._send_request_and_transform_response(
66+
Scanners.create_scanner(
67+
name,
68+
host,
69+
port,
70+
scanner_type,
71+
credential_id,
72+
ca_pub=ca_pub,
73+
comment=comment,
74+
relay_host=relay_host,
75+
relay_port=relay_port,
76+
)
77+
)
78+
79+
def modify_scanner( # type:ignore[override]
80+
self,
81+
scanner_id: EntityID,
82+
*,
83+
name: Optional[str] = None,
84+
host: Optional[str] = None,
85+
port: Optional[int] = None,
86+
scanner_type: Optional[ScannerType] = None,
87+
credential_id: Optional[EntityID] = None,
88+
ca_pub: Optional[str] = None,
89+
comment: Optional[str] = None,
90+
relay_host: Optional[str] = None,
91+
relay_port: Optional[Union[str, int]] = None,
92+
) -> T:
93+
"""Modify an existing scanner
94+
95+
Args:
96+
scanner_id: UUID of the scanner to modify
97+
name: New name of the scanner
98+
host: New hostname or IP address of the scanner
99+
port: New port of the scanner
100+
scanner_type: New type of the scanner
101+
credential_id: New UUID of client certificate credential for the
102+
scanner
103+
ca_pub: New certificate of CA to verify scanner certificate
104+
comment: New comment for the scanner
105+
relay_host: Hostname or IP address of the scanner relay
106+
relay_port: Port of the scanner relay
107+
"""
108+
return self._send_request_and_transform_response(
109+
Scanners.modify_scanner(
110+
scanner_id,
111+
name=name,
112+
host=host,
113+
port=port,
114+
scanner_type=scanner_type,
115+
credential_id=credential_id,
116+
ca_pub=ca_pub,
117+
comment=comment,
118+
relay_host=relay_host,
119+
relay_port=relay_port,
120+
)
121+
)
122+
123+
def get_scanners(
124+
self,
125+
*,
126+
filter_string: Optional[str] = None,
127+
filter_id: Optional[EntityID] = None,
128+
trash: Optional[bool] = None,
129+
details: Optional[bool] = None,
130+
) -> T:
131+
"""Request a list of scanners
132+
133+
Args:
134+
filter_string: Filter term to use for the query
135+
filter_id: UUID of an existing filter to use for the query
136+
trash: Whether to get the trashcan scanners instead
137+
details: Whether to include extra details like tasks using this
138+
scanner
139+
"""
140+
return self._send_request_and_transform_response(
141+
Scanners.get_scanners(
142+
filter_string=filter_string,
143+
filter_id=filter_id,
144+
trash=trash,
145+
details=details,
146+
)
147+
)
148+
149+
def get_scanner(self, scanner_id: EntityID) -> T:
150+
"""Request a single scanner
151+
152+
Args:
153+
scanner_id: UUID of an existing scanner
154+
"""
155+
return self._send_request_and_transform_response(
156+
Scanners.get_scanner(scanner_id)
157+
)
158+
159+
def verify_scanner(self, scanner_id: EntityID) -> T:
160+
"""Verify an existing scanner
161+
162+
Args:
163+
scanner_id: UUID of an existing scanner
164+
"""
165+
return self._send_request_and_transform_response(
166+
Scanners.verify_scanner(scanner_id)
167+
)
168+
169+
def clone_scanner(self, scanner_id: EntityID) -> T:
170+
"""Clone an existing scanner
171+
172+
Args:
173+
scanner_id: UUID of an existing scanner
174+
"""
175+
return self._send_request_and_transform_response(
176+
Scanners.clone_scanner(scanner_id)
177+
)
178+
179+
def delete_scanner(
180+
self, scanner_id: EntityID, ultimate: Optional[bool] = False
181+
) -> T:
182+
"""Delete an existing scanner
183+
184+
Args:
185+
scanner_id: UUID of an existing scanner
186+
ultimate: Whether to remove entirely, or to the trashcan.
187+
"""
188+
return self._send_request_and_transform_response(
189+
Scanners.delete_scanner(scanner_id, ultimate=ultimate)
190+
)
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# SPDX-FileCopyrightText: 2025 Greenbone AG
2+
#
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
"""
6+
GMP Request implementations for GMP version 22.7.
7+
"""
8+
9+
from gvm.protocols.gmp.requests.v227._scanners import Scanners, ScannerType
10+
11+
from .._entity_id import EntityID
12+
from .._version import Version
13+
from ..v226 import (
14+
Aggregates,
15+
AggregateStatistic,
16+
AlertCondition,
17+
AlertEvent,
18+
AlertMethod,
19+
Alerts,
20+
AliveTest,
21+
AuditReports,
22+
Audits,
23+
Authentication,
24+
CertBundAdvisories,
25+
Cpes,
26+
CredentialFormat,
27+
Credentials,
28+
CredentialType,
29+
Cves,
30+
DfnCertAdvisories,
31+
EntityType,
32+
Feed,
33+
FeedType,
34+
Filters,
35+
FilterType,
36+
Groups,
37+
Help,
38+
HelpFormat,
39+
Hosts,
40+
HostsOrdering,
41+
InfoType,
42+
Notes,
43+
Nvts,
44+
OperatingSystems,
45+
Overrides,
46+
Permissions,
47+
PermissionSubjectType,
48+
Policies,
49+
PortLists,
50+
PortRangeType,
51+
ReportConfigParameter,
52+
ReportConfigs,
53+
ReportFormats,
54+
ReportFormatType,
55+
Reports,
56+
ResourceNames,
57+
ResourceType,
58+
Results,
59+
Roles,
60+
ScanConfigs,
61+
Schedules,
62+
SecInfo,
63+
Severity,
64+
SnmpAuthAlgorithm,
65+
SnmpPrivacyAlgorithm,
66+
SortOrder,
67+
SystemReports,
68+
Tags,
69+
Targets,
70+
Tasks,
71+
Tickets,
72+
TicketStatus,
73+
TLSCertificates,
74+
TrashCan,
75+
UserAuthType,
76+
Users,
77+
UserSettings,
78+
Vulnerabilities,
79+
)
80+
81+
__all__ = (
82+
"Aggregates",
83+
"AggregateStatistic",
84+
"Alerts",
85+
"AlertCondition",
86+
"AlertEvent",
87+
"AlertMethod",
88+
"AliveTest",
89+
"AuditReports",
90+
"Audits",
91+
"Authentication",
92+
"CertBundAdvisories",
93+
"Cpes",
94+
"Credentials",
95+
"CredentialFormat",
96+
"CredentialType",
97+
"Cves",
98+
"DfnCertAdvisories",
99+
"EntityID",
100+
"EntityType",
101+
"Feed",
102+
"FeedType",
103+
"Filters",
104+
"FilterType",
105+
"Groups",
106+
"Help",
107+
"HelpFormat",
108+
"Hosts",
109+
"HostsOrdering",
110+
"InfoType",
111+
"Notes",
112+
"Nvts",
113+
"OperatingSystems",
114+
"Overrides",
115+
"Permissions",
116+
"PermissionSubjectType",
117+
"Policies",
118+
"PortLists",
119+
"PortRangeType",
120+
"ReportConfigs",
121+
"ReportConfigParameter",
122+
"ReportFormatType",
123+
"ReportFormats",
124+
"Reports",
125+
"ResourceNames",
126+
"ResourceType",
127+
"Results",
128+
"Roles",
129+
"ScanConfigs",
130+
"Scanners",
131+
"ScannerType",
132+
"Schedules",
133+
"SecInfo",
134+
"Severity",
135+
"SortOrder",
136+
"SnmpAuthAlgorithm",
137+
"SnmpPrivacyAlgorithm",
138+
"SystemReports",
139+
"Tags",
140+
"Targets",
141+
"Tasks",
142+
"Tickets",
143+
"TicketStatus",
144+
"TLSCertificates",
145+
"TrashCan",
146+
"UserAuthType",
147+
"UserSettings",
148+
"Users",
149+
"Version",
150+
"Vulnerabilities",
151+
)

0 commit comments

Comments
 (0)