Skip to content

Commit 715b899

Browse files
authored
Merge branch 'main' into add/get-report-closed-cves
2 parents a4b7685 + b145895 commit 715b899

5 files changed

Lines changed: 158 additions & 0 deletions

File tree

gvm/protocols/gmp/_gmpnext.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
ReportHosts,
2626
ReportOperatingSystems,
2727
ReportPorts,
28+
ReportTlsCertificates,
2829
Tasks,
2930
)
3031
from .requests.v224 import HostsOrdering
@@ -1089,6 +1090,36 @@ def get_report_ports(
10891090
)
10901091
)
10911092

1093+
def get_report_tls_certificates(
1094+
self,
1095+
report_id: EntityID,
1096+
*,
1097+
filter_string: str | None = None,
1098+
filter_id: str | None = None,
1099+
ignore_pagination: bool | None = None,
1100+
details: bool | None = True,
1101+
) -> T:
1102+
"""Request TLS certificates of a single report.
1103+
1104+
Args:
1105+
report_id: UUID of an existing report.
1106+
filter_string: Filter term to use to filter results in the report
1107+
filter_id: UUID of filter to use to filter results in the report
1108+
ignore_pagination: Whether to ignore the filter terms "first" and
1109+
"rows".
1110+
details: Request additional report TLS certificate information details.
1111+
Defaults to True.
1112+
"""
1113+
return self._send_request_and_transform_response(
1114+
ReportTlsCertificates.get_report_tls_certificates(
1115+
report_id=report_id,
1116+
filter_string=filter_string,
1117+
filter_id=filter_id,
1118+
ignore_pagination=ignore_pagination,
1119+
details=details,
1120+
)
1121+
)
1122+
10921123
def get_report_applications(
10931124
self,
10941125
report_id: EntityID,

gvm/protocols/gmp/requests/next/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
from gvm.protocols.gmp.requests.next._report_ports import (
3333
ReportPorts,
3434
)
35+
from gvm.protocols.gmp.requests.next._report_tls_certificates import (
36+
ReportTlsCertificates,
37+
)
3538
from gvm.protocols.gmp.requests.next._tasks import Tasks
3639

3740
from .._entity_id import EntityID
@@ -160,6 +163,7 @@
160163
"ReportHosts",
161164
"ReportOperatingSystems",
162165
"ReportPorts",
166+
"ReportTlsCertificates",
163167
"Reports",
164168
"ResourceNames",
165169
"ResourceType",
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from gvm.errors import RequiredArgument
2+
from gvm.protocols.core import Request
3+
from gvm.protocols.gmp.requests import EntityID
4+
from gvm.utils import to_bool
5+
from gvm.xml import XmlCommand
6+
7+
8+
class ReportTlsCertificates:
9+
@classmethod
10+
def get_report_tls_certificates(
11+
cls,
12+
report_id: EntityID,
13+
*,
14+
filter_string: str | None = None,
15+
filter_id: str | None = None,
16+
ignore_pagination: bool | None = None,
17+
details: bool | None = True,
18+
) -> Request:
19+
"""Request TLS certificates of a single report.
20+
21+
Args:
22+
report_id: UUID of an existing report.
23+
filter_string: Filter term to use to filter results in the report
24+
filter_id: UUID of filter to use to filter results in the report
25+
ignore_pagination: Whether to ignore the filter terms "first" and
26+
"rows".
27+
details: Request additional report TLS certificate information details.
28+
Defaults to True.
29+
"""
30+
cmd = XmlCommand("get_report_tls_certificates")
31+
32+
if not report_id:
33+
raise RequiredArgument(
34+
function=cls.get_report_tls_certificates.__name__,
35+
argument="report_id",
36+
)
37+
38+
cmd.set_attribute("report_id", str(report_id))
39+
40+
cmd.add_filter(filter_string, filter_id)
41+
42+
if ignore_pagination is not None:
43+
cmd.set_attribute("ignore_pagination", to_bool(ignore_pagination))
44+
45+
cmd.set_attribute("details", to_bool(details))
46+
47+
return cmd
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SPDX-FileCopyrightText: 2026 Greenbone AG
2+
#
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
#
5+
6+
from gvm.errors import RequiredArgument
7+
8+
9+
class GmpGetReportTlsCertificatesTestMixin:
10+
def test_get_report_tls_certificates_without_id(self):
11+
with self.assertRaises(RequiredArgument):
12+
self.gmp.get_report_tls_certificates(None)
13+
14+
with self.assertRaises(RequiredArgument):
15+
self.gmp.get_report_tls_certificates("")
16+
17+
def test_get_report_tls_certificates_with_filter_string(self):
18+
self.gmp.get_report_tls_certificates(
19+
report_id="r1", filter_string="name=foo"
20+
)
21+
22+
self.connection.send.has_been_called_with(
23+
b'<get_report_tls_certificates report_id="r1" filter="name=foo" details="1"/>'
24+
)
25+
26+
def test_get_report_tls_certificates_with_filter_id(self):
27+
self.gmp.get_report_tls_certificates(report_id="r1", filter_id="f1")
28+
29+
self.connection.send.has_been_called_with(
30+
b'<get_report_tls_certificates report_id="r1" filt_id="f1" details="1"/>'
31+
)
32+
33+
def test_get_report_tls_certificates_with_ignore_pagination(self):
34+
self.gmp.get_report_tls_certificates(
35+
report_id="r1", ignore_pagination=True
36+
)
37+
38+
self.connection.send.has_been_called_with(
39+
b'<get_report_tls_certificates report_id="r1" ignore_pagination="1" details="1"/>'
40+
)
41+
42+
self.gmp.get_report_tls_certificates(
43+
report_id="r1", ignore_pagination=False
44+
)
45+
46+
self.connection.send.has_been_called_with(
47+
b'<get_report_tls_certificates report_id="r1" ignore_pagination="0" details="1"/>'
48+
)
49+
50+
def test_get_report_tls_certificates_with_details(self):
51+
self.gmp.get_report_tls_certificates(report_id="r1", details=True)
52+
53+
self.connection.send.has_been_called_with(
54+
b'<get_report_tls_certificates report_id="r1" details="1"/>'
55+
)
56+
57+
self.gmp.get_report_tls_certificates(report_id="r1", details=False)
58+
59+
self.connection.send.has_been_called_with(
60+
b'<get_report_tls_certificates report_id="r1" details="0"/>'
61+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-FileCopyrightText: 2026 Greenbone AG
2+
#
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
#
5+
6+
from ...gmpnext import GMPTestCase
7+
from .report_tls_certificates.test_get_report_tls_certificates import (
8+
GmpGetReportTlsCertificatesTestMixin,
9+
)
10+
11+
12+
class GmpGetReportTlsCertificatesTestCase(
13+
GmpGetReportTlsCertificatesTestMixin, GMPTestCase
14+
):
15+
pass

0 commit comments

Comments
 (0)