Skip to content

Commit ca61549

Browse files
timopollmeierbjoernricks
authored andcommitted
Create GMP 22.7 protocol and move scanner changes there
1 parent 46528e8 commit ca61549

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

+3440
-278
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/_gmp226.py

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
Reports,
2222
ResourceNames,
2323
ResourceType,
24-
Scanners,
25-
ScannerType,
2624
)
2725

2826

@@ -448,156 +446,3 @@ def modify_report_config(
448446
report_config_id, name=name, comment=comment, params=params
449447
)
450448
)
451-
452-
def create_scanner(
453-
self,
454-
name: str,
455-
host: str,
456-
port: Union[str, int],
457-
scanner_type: ScannerType,
458-
credential_id: str,
459-
*,
460-
ca_pub: Optional[str] = None,
461-
comment: Optional[str] = None,
462-
relay_host: Optional[str] = None,
463-
relay_port: Optional[Union[str, int]] = None,
464-
) -> T:
465-
"""Create a new scanner
466-
467-
Args:
468-
name: Name of the new scanner
469-
host: Hostname or IP address of the scanner
470-
port: Port of the scanner
471-
scanner_type: Type of the scanner
472-
credential_id: UUID of client certificate credential for the
473-
scanner
474-
ca_pub: Certificate of CA to verify scanner certificate
475-
comment: Comment for the scanner
476-
relay_host: Hostname or IP address of the scanner relay
477-
relay_port: Port of the scanner relay
478-
"""
479-
return self._send_request_and_transform_response(
480-
Scanners.create_scanner(
481-
name,
482-
host,
483-
port,
484-
scanner_type,
485-
credential_id,
486-
ca_pub=ca_pub,
487-
comment=comment,
488-
relay_host=relay_host,
489-
relay_port=relay_port,
490-
)
491-
)
492-
493-
def modify_scanner(
494-
self,
495-
scanner_id: EntityID,
496-
*,
497-
name: Optional[str] = None,
498-
host: Optional[str] = None,
499-
port: Optional[int] = None,
500-
scanner_type: Optional[ScannerType] = None,
501-
credential_id: Optional[EntityID] = None,
502-
ca_pub: Optional[str] = None,
503-
comment: Optional[str] = None,
504-
relay_host: Optional[str] = None,
505-
relay_port: Optional[Union[str, int]] = None,
506-
) -> T:
507-
"""Modify an existing scanner
508-
509-
Args:
510-
scanner_id: UUID of the scanner to modify
511-
name: New name of the scanner
512-
host: New hostname or IP address of the scanner
513-
port: New port of the scanner
514-
scanner_type: New type of the scanner
515-
credential_id: New UUID of client certificate credential for the
516-
scanner
517-
ca_pub: New certificate of CA to verify scanner certificate
518-
comment: New comment for the scanner
519-
relay_host: Hostname or IP address of the scanner relay
520-
relay_port: Port of the scanner relay
521-
"""
522-
return self._send_request_and_transform_response(
523-
Scanners.modify_scanner(
524-
scanner_id,
525-
name=name,
526-
host=host,
527-
port=port,
528-
scanner_type=scanner_type,
529-
credential_id=credential_id,
530-
ca_pub=ca_pub,
531-
comment=comment,
532-
relay_host=relay_host,
533-
relay_port=relay_port,
534-
)
535-
)
536-
537-
def get_scanners(
538-
self,
539-
*,
540-
filter_string: Optional[str] = None,
541-
filter_id: Optional[EntityID] = None,
542-
trash: Optional[bool] = None,
543-
details: Optional[bool] = None,
544-
) -> T:
545-
"""Request a list of scanners
546-
547-
Args:
548-
filter_string: Filter term to use for the query
549-
filter_id: UUID of an existing filter to use for the query
550-
trash: Whether to get the trashcan scanners instead
551-
details: Whether to include extra details like tasks using this
552-
scanner
553-
"""
554-
return self._send_request_and_transform_response(
555-
Scanners.get_scanners(
556-
filter_string=filter_string,
557-
filter_id=filter_id,
558-
trash=trash,
559-
details=details,
560-
)
561-
)
562-
563-
def get_scanner(self, scanner_id: EntityID) -> T:
564-
"""Request a single scanner
565-
566-
Args:
567-
scanner_id: UUID of an existing scanner
568-
"""
569-
return self._send_request_and_transform_response(
570-
Scanners.get_scanner(scanner_id)
571-
)
572-
573-
def verify_scanner(self, scanner_id: EntityID) -> T:
574-
"""Verify an existing scanner
575-
576-
Args:
577-
scanner_id: UUID of an existing scanner
578-
"""
579-
return self._send_request_and_transform_response(
580-
Scanners.verify_scanner(scanner_id)
581-
)
582-
583-
def clone_scanner(self, scanner_id: EntityID) -> T:
584-
"""Clone an existing scanner
585-
586-
Args:
587-
scanner_id: UUID of an existing scanner
588-
"""
589-
return self._send_request_and_transform_response(
590-
Scanners.clone_scanner(scanner_id)
591-
)
592-
593-
def delete_scanner(
594-
self, scanner_id: EntityID, ultimate: Optional[bool] = False
595-
) -> T:
596-
"""Delete an existing scanner
597-
598-
Args:
599-
scanner_id: UUID of an existing scanner
600-
"""
601-
return self._send_request_and_transform_response(
602-
Scanners.delete_scanner(scanner_id, ultimate=ultimate)
603-
)

0 commit comments

Comments
 (0)