1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# Copyright (C) 2018-2021 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=arguments-differ, redefined-builtin, too-many-lines |
20
|
|
|
|
21
|
|
|
from numbers import Integral |
22
|
|
|
from typing import Any, Optional |
23
|
|
|
|
24
|
|
|
from gvm.errors import InvalidArgument |
25
|
|
|
from gvm.utils import to_bool |
26
|
|
|
from gvm.xml import XmlCommand |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
class SystemReportsMixin: |
30
|
|
|
def get_system_reports( |
31
|
|
|
self, |
32
|
|
|
*, |
33
|
|
|
name: Optional[str] = None, |
34
|
|
|
duration: Optional[int] = None, |
35
|
|
|
start_time: Optional[str] = None, |
36
|
|
|
end_time: Optional[str] = None, |
37
|
|
|
brief: Optional[bool] = None, |
38
|
|
|
slave_id: Optional[str] = None, |
39
|
|
|
) -> Any: |
40
|
|
|
"""Request a list of system reports |
41
|
|
|
|
42
|
|
|
Arguments: |
43
|
|
|
name: A string describing the required system report |
44
|
|
|
duration: The number of seconds into the past that the system report |
45
|
|
|
should include |
46
|
|
|
start_time: The start of the time interval the system report should |
47
|
|
|
include in ISO time format |
48
|
|
|
end_time: The end of the time interval the system report should |
49
|
|
|
include in ISO time format |
50
|
|
|
brief: Whether to include the actual system reports |
51
|
|
|
slave_id: UUID of GMP scanner from which to get the system reports |
52
|
|
|
|
53
|
|
|
Returns: |
54
|
|
|
The response. See :py:meth:`send_command` for details. |
55
|
|
|
""" |
56
|
|
|
cmd = XmlCommand("get_system_reports") |
57
|
|
|
|
58
|
|
|
if name: |
59
|
|
|
cmd.set_attribute("name", name) |
60
|
|
|
|
61
|
|
|
if duration is not None: |
62
|
|
|
if not isinstance(duration, Integral): |
63
|
|
|
raise InvalidArgument("duration needs to be an integer number") |
64
|
|
|
|
65
|
|
|
cmd.set_attribute("duration", str(duration)) |
66
|
|
|
|
67
|
|
|
if start_time: |
68
|
|
|
cmd.set_attribute("start_time", str(start_time)) |
69
|
|
|
|
70
|
|
|
if end_time: |
71
|
|
|
cmd.set_attribute("end_time", str(end_time)) |
72
|
|
|
|
73
|
|
|
if brief is not None: |
74
|
|
|
cmd.set_attribute("brief", to_bool(brief)) |
75
|
|
|
|
76
|
|
|
if slave_id: |
77
|
|
|
cmd.set_attribute("slave_id", slave_id) |
78
|
|
|
|
79
|
|
|
return self._send_xml_command(cmd) |
80
|
|
|
|