|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
# Copyright (C) 2020 Greenbone Networks GmbH |
|
3
|
|
|
# |
|
4
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later |
|
5
|
|
|
# |
|
6
|
|
|
# This program is free software: you can redistribute it and/or modify |
|
7
|
|
|
# it under the terms of the GNU General Public License as published by |
|
8
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
|
9
|
|
|
# (at your option) any later version. |
|
10
|
|
|
# |
|
11
|
|
|
# This program is distributed in the hope that it will be useful, |
|
12
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
# GNU General Public License for more details. |
|
15
|
|
|
# |
|
16
|
|
|
# You should have received a copy of the GNU General Public License |
|
17
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
|
|
19
|
|
|
# pylint: disable=too-many-lines,redefined-builtin |
|
20
|
|
|
|
|
21
|
|
|
""" |
|
22
|
|
|
Module for communication with gvmd in |
|
23
|
|
|
`Greenbone Management Protocol version 21.04`_ |
|
24
|
|
|
|
|
25
|
|
|
.. _Greenbone Management Protocol version 21.04: |
|
26
|
|
|
https://docs.greenbone.net/API/GMP/gmp-21.04.html |
|
27
|
|
|
""" |
|
28
|
|
|
|
|
29
|
|
|
from typing import Any, Callable, Optional |
|
30
|
|
|
|
|
31
|
|
|
from gvm.protocols.gmpv214.gmpv214 import GmpV214Mixin |
|
32
|
|
|
from gvm.protocols.gmpv208.gmpv208 import GmpV208Mixin |
|
33
|
|
|
from gvm.protocols.gmpv9.gmpv9 import GmpV9Mixin |
|
34
|
|
|
from gvm.protocols.gmpv8.gmpv8 import GmpV8Mixin |
|
35
|
|
|
from gvm.protocols.gmpv7.gmpv7 import GmpV7Mixin |
|
36
|
|
|
from gvm.connections import GvmConnection |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
from . import types |
|
40
|
|
|
from .types import * # pylint: disable=unused-wildcard-import, wildcard-import |
|
41
|
|
|
|
|
42
|
|
|
PROTOCOL_VERSION = (21, 4) |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
View Code Duplication |
class Gmp(GmpV214Mixin, GmpV208Mixin, GmpV9Mixin, GmpV8Mixin, GmpV7Mixin): |
|
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
types = types |
|
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
def __init__( |
|
50
|
|
|
self, |
|
51
|
|
|
connection: GvmConnection, |
|
52
|
|
|
*, |
|
53
|
|
|
transform: Optional[Callable[[str], Any]] = None |
|
54
|
|
|
): |
|
55
|
|
|
super().__init__(connection, transform=transform) |
|
56
|
|
|
|
|
57
|
|
|
# Is authenticated on gvmd |
|
58
|
|
|
self._authenticated = False |
|
59
|
|
|
|
|
60
|
|
|
@staticmethod |
|
61
|
|
|
def get_protocol_version() -> tuple: |
|
62
|
|
|
"""Determine the Greenbone Management Protocol version. |
|
63
|
|
|
|
|
64
|
|
|
Returns: |
|
65
|
|
|
tuple: Implemented version of the Greenbone Management Protocol |
|
66
|
|
|
""" |
|
67
|
|
|
return PROTOCOL_VERSION |
|
68
|
|
|
|