python-gvm 27.6.0__py3-none-any.whl → 27.7.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.
- gvm/__version__.py +1 -1
- gvm/protocols/gmp/_gmpnext.py +50 -0
- gvm/protocols/gmp/requests/next/_scan_report.py +74 -0
- gvm/protocols/http/openvasd/_client.py +45 -31
- gvm/protocols/http/openvasd/_openvasd1.py +3 -0
- {python_gvm-27.6.0.dist-info → python_gvm-27.7.0.dist-info}/METADATA +3 -3
- {python_gvm-27.6.0.dist-info → python_gvm-27.7.0.dist-info}/RECORD +9 -9
- {python_gvm-27.6.0.dist-info → python_gvm-27.7.0.dist-info}/WHEEL +1 -1
- {python_gvm-27.6.0.dist-info → python_gvm-27.7.0.dist-info}/licenses/LICENSE +0 -0
gvm/__version__.py
CHANGED
gvm/protocols/gmp/_gmpnext.py
CHANGED
|
@@ -1758,3 +1758,53 @@ class GMPNext(GMPv227[T]):
|
|
|
1758
1758
|
ignore_pagination=ignore_pagination,
|
|
1759
1759
|
details=details,
|
|
1760
1760
|
)
|
|
1761
|
+
|
|
1762
|
+
def export_scan_report(
|
|
1763
|
+
self,
|
|
1764
|
+
report_id: EntityID,
|
|
1765
|
+
format_id: EntityID,
|
|
1766
|
+
*,
|
|
1767
|
+
config_id: EntityID | None = None,
|
|
1768
|
+
filter_string: str | None = None,
|
|
1769
|
+
ignore_pagination: bool = False,
|
|
1770
|
+
lean: bool = False,
|
|
1771
|
+
notes_details: bool = False,
|
|
1772
|
+
overrides_details: bool = False,
|
|
1773
|
+
result_tags: bool = False,
|
|
1774
|
+
) -> T:
|
|
1775
|
+
"""Request an asynchronous export of a scan report.
|
|
1776
|
+
|
|
1777
|
+
If an identical export is already pending or running, the existing
|
|
1778
|
+
report export is returned instead of creating a duplicate.
|
|
1779
|
+
|
|
1780
|
+
Args:
|
|
1781
|
+
report_id: UUID of the scan report to export.
|
|
1782
|
+
format_id: UUID of the report format to apply.
|
|
1783
|
+
config_id: UUID of an optional report configuration.
|
|
1784
|
+
filter_string: Filter term to apply while generating the report.
|
|
1785
|
+
ignore_pagination: Whether pagination settings in the filter
|
|
1786
|
+
should be ignored.
|
|
1787
|
+
lean: Whether lean report data should be generated.
|
|
1788
|
+
notes_details: Whether note details should be included.
|
|
1789
|
+
overrides_details: Whether override details should be included.
|
|
1790
|
+
result_tags: Whether result tags should be included.
|
|
1791
|
+
|
|
1792
|
+
Returns:
|
|
1793
|
+
A request for the export_scan_report GMP command.
|
|
1794
|
+
|
|
1795
|
+
Raises:
|
|
1796
|
+
RequiredArgument: If report_id or format_id is not provided.
|
|
1797
|
+
"""
|
|
1798
|
+
return self._send_request_and_transform_response(
|
|
1799
|
+
ScanReports.export_scan_report(
|
|
1800
|
+
report_id=report_id,
|
|
1801
|
+
format_id=format_id,
|
|
1802
|
+
config_id=config_id,
|
|
1803
|
+
filter_string=filter_string,
|
|
1804
|
+
ignore_pagination=ignore_pagination,
|
|
1805
|
+
lean=lean,
|
|
1806
|
+
notes_details=notes_details,
|
|
1807
|
+
overrides_details=overrides_details,
|
|
1808
|
+
result_tags=result_tags,
|
|
1809
|
+
)
|
|
1810
|
+
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from gvm.errors import RequiredArgument
|
|
2
2
|
from gvm.protocols.core import Request
|
|
3
3
|
from gvm.protocols.gmp.requests import EntityID
|
|
4
|
+
from gvm.utils import to_bool
|
|
4
5
|
from gvm.xml import XmlCommand
|
|
5
6
|
|
|
6
7
|
|
|
@@ -37,3 +38,76 @@ class ScanReports:
|
|
|
37
38
|
cmd.add_filter(filter_string, filter_id)
|
|
38
39
|
|
|
39
40
|
return cmd
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def export_scan_report(
|
|
44
|
+
cls,
|
|
45
|
+
report_id: EntityID,
|
|
46
|
+
format_id: EntityID,
|
|
47
|
+
*,
|
|
48
|
+
config_id: EntityID | None = None,
|
|
49
|
+
filter_string: str | None = None,
|
|
50
|
+
ignore_pagination: bool = False,
|
|
51
|
+
lean: bool = False,
|
|
52
|
+
notes_details: bool = False,
|
|
53
|
+
overrides_details: bool = False,
|
|
54
|
+
result_tags: bool = False,
|
|
55
|
+
) -> Request:
|
|
56
|
+
"""Request an asynchronous export of a scan report.
|
|
57
|
+
|
|
58
|
+
If an identical export is already pending or running, the existing
|
|
59
|
+
report export is returned instead of creating a duplicate.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
report_id: UUID of the scan report to export.
|
|
63
|
+
format_id: UUID of the report format to apply.
|
|
64
|
+
config_id: UUID of an optional report configuration.
|
|
65
|
+
filter_string: Filter term to apply while generating the report.
|
|
66
|
+
ignore_pagination: Whether pagination settings in the filter
|
|
67
|
+
should be ignored.
|
|
68
|
+
lean: Whether lean report data should be generated.
|
|
69
|
+
notes_details: Whether note details should be included.
|
|
70
|
+
overrides_details: Whether override details should be included.
|
|
71
|
+
result_tags: Whether result tags should be included.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
A request for the export_scan_report GMP command.
|
|
75
|
+
|
|
76
|
+
Raises:
|
|
77
|
+
RequiredArgument: If report_id is not provided.
|
|
78
|
+
"""
|
|
79
|
+
if not report_id:
|
|
80
|
+
raise RequiredArgument(
|
|
81
|
+
function=cls.export_scan_report.__name__,
|
|
82
|
+
argument="report_id",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
cmd = XmlCommand("export_scan_report")
|
|
86
|
+
cmd.set_attribute("report_id", str(report_id))
|
|
87
|
+
cmd.set_attribute("format_id", str(format_id))
|
|
88
|
+
|
|
89
|
+
if config_id:
|
|
90
|
+
cmd.set_attribute("config_id", str(config_id))
|
|
91
|
+
|
|
92
|
+
if filter_string is not None:
|
|
93
|
+
cmd.set_attribute("filter", filter_string)
|
|
94
|
+
|
|
95
|
+
cmd.set_attribute(
|
|
96
|
+
"ignore_pagination",
|
|
97
|
+
to_bool(ignore_pagination),
|
|
98
|
+
)
|
|
99
|
+
cmd.set_attribute("lean", to_bool(lean))
|
|
100
|
+
cmd.set_attribute(
|
|
101
|
+
"notes_details",
|
|
102
|
+
to_bool(notes_details),
|
|
103
|
+
)
|
|
104
|
+
cmd.set_attribute(
|
|
105
|
+
"overrides_details",
|
|
106
|
+
to_bool(overrides_details),
|
|
107
|
+
)
|
|
108
|
+
cmd.set_attribute(
|
|
109
|
+
"result_tags",
|
|
110
|
+
to_bool(result_tags),
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
return cmd
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
4
4
|
|
|
5
5
|
"""
|
|
6
|
-
http client for initializing a connection to the openvasd HTTP API
|
|
6
|
+
http client for initializing a connection to the openvasd HTTP API.
|
|
7
|
+
|
|
8
|
+
HTTPS with mTLS is used by default. Plain HTTP can be enabled explicitly
|
|
9
|
+
with `insecure_http=True`.
|
|
7
10
|
"""
|
|
8
11
|
|
|
9
12
|
import ssl
|
|
@@ -22,11 +25,14 @@ def create_openvasd_http_client(
|
|
|
22
25
|
client_cert_paths: StrOrPathLike
|
|
23
26
|
| tuple[StrOrPathLike, StrOrPathLike]
|
|
24
27
|
| None = None,
|
|
28
|
+
insecure_http: bool = False,
|
|
25
29
|
port: int = 3000,
|
|
26
30
|
) -> Client:
|
|
27
31
|
"""
|
|
28
|
-
Create a `httpx.Client` configured for
|
|
29
|
-
|
|
32
|
+
Create a `httpx.Client` configured for the OpenVASD HTTP API.
|
|
33
|
+
|
|
34
|
+
mTLS is used by default. Set `insecure_http=True` to use plain HTTP.
|
|
35
|
+
In this case, an API key can be used for authorization.
|
|
30
36
|
|
|
31
37
|
Args:
|
|
32
38
|
host_name: Hostname or IP of the OpenVASD server (e.g., "localhost").
|
|
@@ -34,46 +40,54 @@ def create_openvasd_http_client(
|
|
|
34
40
|
server_ca_path: Path to the server's CA certificate (for verifying the server).
|
|
35
41
|
client_cert_paths: Path to the client certificate (str) or a tuple of
|
|
36
42
|
(cert_path, key_path) for mTLS authentication.
|
|
43
|
+
insecure_http: If True, disables SSL verification and uses HTTP instead of HTTPS.
|
|
37
44
|
port: The port to connect to (default: 3000).
|
|
38
45
|
|
|
39
46
|
Behavior:
|
|
40
|
-
- If
|
|
41
|
-
|
|
42
|
-
- If
|
|
43
|
-
|
|
47
|
+
- If `insecure_http=True`, HTTP is used instead of HTTPS.
|
|
48
|
+
An API key can be used for authorization.
|
|
49
|
+
- If `insecure_http=False` (default), HTTPS with mTLS is used.
|
|
50
|
+
Both `server_ca_path` and `client_cert_paths` are required.
|
|
51
|
+
|
|
52
|
+
Raises:
|
|
53
|
+
ValueError: If `insecure_http=False` and either
|
|
54
|
+
`server_ca_path` or `client_cert_paths` is missing.
|
|
44
55
|
"""
|
|
45
56
|
headers = {}
|
|
57
|
+
if api_key:
|
|
58
|
+
headers["X-API-KEY"] = api_key
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
if insecure_http:
|
|
61
|
+
return Client(
|
|
62
|
+
base_url=f"http://{host_name}:{port}",
|
|
63
|
+
headers=headers,
|
|
64
|
+
http2=True,
|
|
65
|
+
timeout=10.0,
|
|
53
66
|
)
|
|
54
|
-
if isinstance(client_cert_paths, tuple):
|
|
55
|
-
context.load_cert_chain(
|
|
56
|
-
certfile=client_cert_paths[0], keyfile=client_cert_paths[1]
|
|
57
|
-
)
|
|
58
|
-
else:
|
|
59
|
-
context.load_cert_chain(certfile=client_cert_paths)
|
|
60
|
-
|
|
61
|
-
context.check_hostname = False
|
|
62
|
-
context.verify_mode = ssl.CERT_REQUIRED
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
if not server_ca_path or not client_cert_paths:
|
|
69
|
+
raise ValueError(
|
|
70
|
+
"Both server_ca_path and client_cert_paths must be provided "
|
|
71
|
+
"when insecure_http is False."
|
|
72
|
+
)
|
|
73
|
+
# Prepare mTLS SSL context
|
|
74
|
+
context = ssl.create_default_context(
|
|
75
|
+
ssl.Purpose.SERVER_AUTH, cafile=server_ca_path
|
|
76
|
+
)
|
|
77
|
+
if isinstance(client_cert_paths, tuple):
|
|
78
|
+
context.load_cert_chain(
|
|
79
|
+
certfile=client_cert_paths[0], keyfile=client_cert_paths[1]
|
|
80
|
+
)
|
|
81
|
+
else:
|
|
82
|
+
context.load_cert_chain(certfile=client_cert_paths)
|
|
69
83
|
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
context.check_hostname = False
|
|
85
|
+
context.verify_mode = ssl.CERT_REQUIRED
|
|
72
86
|
|
|
73
87
|
return Client(
|
|
74
|
-
base_url=
|
|
88
|
+
base_url=f"https://{host_name}:{port}",
|
|
75
89
|
headers=headers,
|
|
76
|
-
verify=
|
|
90
|
+
verify=context,
|
|
77
91
|
http2=True,
|
|
78
92
|
timeout=10.0,
|
|
79
93
|
)
|
|
@@ -37,6 +37,7 @@ class OpenvasdHttpAPIv1:
|
|
|
37
37
|
client_cert_paths: StrOrPathLike
|
|
38
38
|
| tuple[StrOrPathLike, StrOrPathLike]
|
|
39
39
|
| None = None,
|
|
40
|
+
insecure_http: bool = False,
|
|
40
41
|
suppress_exceptions: bool = False,
|
|
41
42
|
):
|
|
42
43
|
"""
|
|
@@ -48,6 +49,7 @@ class OpenvasdHttpAPIv1:
|
|
|
48
49
|
api_key: Optional API key to be used for authentication.
|
|
49
50
|
server_ca_path: Path to the server CA certificate (for HTTPS/mTLS).
|
|
50
51
|
client_cert_paths: Path to client certificate or (cert, key) tuple for mTLS.
|
|
52
|
+
insecure_http: If True, use HTTP instead of HTTPS and disable certificate verification.
|
|
51
53
|
suppress_exceptions: If True, suppress exceptions and return structured error
|
|
52
54
|
responses. Default is False, which means exceptions will be raised.
|
|
53
55
|
"""
|
|
@@ -57,6 +59,7 @@ class OpenvasdHttpAPIv1:
|
|
|
57
59
|
api_key=api_key,
|
|
58
60
|
server_ca_path=server_ca_path,
|
|
59
61
|
client_cert_paths=client_cert_paths,
|
|
62
|
+
insecure_http=insecure_http,
|
|
60
63
|
)
|
|
61
64
|
|
|
62
65
|
# Sub-API modules
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: python-gvm
|
|
3
|
-
Version: 27.
|
|
3
|
+
Version: 27.7.0
|
|
4
4
|
Summary: Library to communicate with remote servers over GMP or OSP
|
|
5
5
|
Project-URL: Homepage, https://github.com/greenbone/python-gvm/
|
|
6
6
|
Project-URL: Repository, https://github.com/greenbone/python-gvm/
|
|
@@ -22,7 +22,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
22
22
|
Requires-Python: <4,>=3.10
|
|
23
23
|
Requires-Dist: httpx[http2]<0.29,>=0.28.1
|
|
24
24
|
Requires-Dist: lxml>=4.5.0
|
|
25
|
-
Requires-Dist: paramiko
|
|
25
|
+
Requires-Dist: paramiko<6,>=5.0.0
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
|
|
28
28
|

|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
gvm/__init__.py,sha256=Eu3a8hRdlixDFn34Q-BwPXVN65KHpgFk_i0CYUdbfF8,412
|
|
2
|
-
gvm/__version__.py,sha256=
|
|
2
|
+
gvm/__version__.py,sha256=4TQ-2iqDj-a7CEfg_6neCIN7PJ6wsiqaJaZGgEq46OA,103
|
|
3
3
|
gvm/_enum.py,sha256=n--ztwQQW2MU4M9E_4qJrw-32IGc4Laj6auZ8glMw_0,1168
|
|
4
4
|
gvm/errors.py,sha256=FnZoe3ROKlAm8LMJ25uKRaG9cp-SG8hYIVtDMwwp0l0,5263
|
|
5
5
|
gvm/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -27,7 +27,7 @@ gvm/protocols/gmp/_gmp224.py,sha256=NO-ufzkGW1RNzMHrIjlFm7r8QzSH0uRZK5xc9mWLRVI,
|
|
|
27
27
|
gvm/protocols/gmp/_gmp225.py,sha256=3lz_AHTIQdBEr4DIYJ5o9D0Eke-Df3jUb0IZytITRdo,2227
|
|
28
28
|
gvm/protocols/gmp/_gmp226.py,sha256=YqQ7CJIbUtM7s8wQPYX5BgePdhX-tUjCemanW0_DZtE,14543
|
|
29
29
|
gvm/protocols/gmp/_gmp227.py,sha256=-q4Aci1I4FRtLle21qTwtkchE2ixWn1-Kug58X4dU5I,5713
|
|
30
|
-
gvm/protocols/gmp/_gmpnext.py,sha256
|
|
30
|
+
gvm/protocols/gmp/_gmpnext.py,sha256=-hZUiOZf0fd6DElCG97Bq0IkzmzThNl1EHRkWzDw_mE,64464
|
|
31
31
|
gvm/protocols/gmp/requests/__init__.py,sha256=XH1zSifyz9Rx4FqY2lJ1mwurnUepHk7REZ-fSMC_Wx0,200
|
|
32
32
|
gvm/protocols/gmp/requests/_entity_id.py,sha256=V96VhTg7_CF2AduaAHRYrGgTaOVA8_mG1lFiCl8-CMA,136
|
|
33
33
|
gvm/protocols/gmp/requests/_version.py,sha256=GdHQnEVzJ6PbxoU4pxP36Oze1XvK5llWqB9bkC16Pf8,393
|
|
@@ -49,7 +49,7 @@ gvm/protocols/gmp/requests/next/_report_operating_systems.py,sha256=qN6-94OYKXGQ
|
|
|
49
49
|
gvm/protocols/gmp/requests/next/_report_ports.py,sha256=xTzdBFKqYHv1ulH1BduWEE-wO3SzuMu0yU7pnB5jx5E,1477
|
|
50
50
|
gvm/protocols/gmp/requests/next/_report_tls_certificates.py,sha256=-h1d3OVn873DLEHHvjeLVpOpvErJo5C3u5tyxIrXUI8,1559
|
|
51
51
|
gvm/protocols/gmp/requests/next/_report_vulnerabilities.py,sha256=8TOQm-CyaHtTOL1dXDUrFYEzuohdeSs_TeonCeVJJzg,1543
|
|
52
|
-
gvm/protocols/gmp/requests/next/_scan_report.py,sha256=
|
|
52
|
+
gvm/protocols/gmp/requests/next/_scan_report.py,sha256=uJTnoBxSGGRjFyI0v0AOTCDkgs0VEBoWwdoDdBO6Deo,3662
|
|
53
53
|
gvm/protocols/gmp/requests/next/_targets.py,sha256=EIiYyPNrzflxjr3pmY0ZT25KSHn-ISERD3IfrzVauZI,12707
|
|
54
54
|
gvm/protocols/gmp/requests/next/_tasks.py,sha256=4faG2a3wey9-fj-el4TiAwBUbu4H8M7EZ9WyO3SJ0QM,27016
|
|
55
55
|
gvm/protocols/gmp/requests/next/_web_application_targets.py,sha256=03EYFVXKmVf0ZS_CTaXGsD-ALclSu9Hc2hm6p0LLV8o,6563
|
|
@@ -108,14 +108,14 @@ gvm/protocols/gmp/requests/v227/_scanners.py,sha256=-hxjO2gHZE2J2rNH51wJRAfVzbPY
|
|
|
108
108
|
gvm/protocols/http/__init__.py,sha256=HnS3bXYZiYzU0E167TWDX5Egd9aCetsCrFTojVFIrd4,239
|
|
109
109
|
gvm/protocols/http/openvasd/__init__.py,sha256=7AVS1dhfl5JsrnMyI9l7uVPSKEGsQq8dNAwfHGcucUk,392
|
|
110
110
|
gvm/protocols/http/openvasd/_api.py,sha256=3p_DxXtWJNzN5yw2mxRCsDqaECVyftYO4mZAWaj3mNA,696
|
|
111
|
-
gvm/protocols/http/openvasd/_client.py,sha256=
|
|
111
|
+
gvm/protocols/http/openvasd/_client.py,sha256=ZMItdYHG0jmJUSsygqmfaK44W-bpGnFKQ33puuuSsRU,2924
|
|
112
112
|
gvm/protocols/http/openvasd/_health.py,sha256=lHXyBs4i1He7jogvnn9y8-ElGmiHyU3SyCFUUC0Dlmc,2607
|
|
113
113
|
gvm/protocols/http/openvasd/_metadata.py,sha256=W3TQeeNN-X-5vZ89WvsxwEym8EjQmOFPcBsya_bd3F8,3302
|
|
114
114
|
gvm/protocols/http/openvasd/_notus.py,sha256=FwX5fFsx-FWXf4Rl_5seequkQ6XVS8jZ0NWb_5Lsk2s,1907
|
|
115
|
-
gvm/protocols/http/openvasd/_openvasd1.py,sha256=
|
|
115
|
+
gvm/protocols/http/openvasd/_openvasd1.py,sha256=VS-fErATsT25SJxk0UVQRFETJ5OtGnrhk8aNsFqs7Ew,4074
|
|
116
116
|
gvm/protocols/http/openvasd/_scans.py,sha256=U8aYmHudMQFtVzl9khjNsRRewY0sf8G376zTYZN6HQQ,16667
|
|
117
117
|
gvm/protocols/http/openvasd/_vts.py,sha256=_T4j4SdXe0DthBA7pCehx4FXKYbQyhzpq72YNO4fKt4,2136
|
|
118
|
-
python_gvm-27.
|
|
119
|
-
python_gvm-27.
|
|
120
|
-
python_gvm-27.
|
|
121
|
-
python_gvm-27.
|
|
118
|
+
python_gvm-27.7.0.dist-info/METADATA,sha256=4DiJ-kw4PfsYTZToseS8ZgpbN7JMep_F7HNQmxN4J6A,5699
|
|
119
|
+
python_gvm-27.7.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
120
|
+
python_gvm-27.7.0.dist-info/licenses/LICENSE,sha256=WJ7YI-moTFb-uVrFjnzzhGJrnL9P2iqQe8NuED3hutI,35141
|
|
121
|
+
python_gvm-27.7.0.dist-info/RECORD,,
|
|
File without changes
|