gvm-tools 25.3.3__tar.gz → 25.4.1__tar.gz
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.
Potentially problematic release.
This version of gvm-tools might be problematic. Click here for more details.
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/PKG-INFO +4 -2
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/gvmtools/__version__.py +1 -1
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/pyproject.toml +1 -1
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/bulk-modify-schedules.gmp.py +1 -1
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-cve-report-from-json.gmp.py +5 -4
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/delete-overrides-by-filter.gmp.py +1 -1
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/export-xml-report.gmp.py +6 -11
- gvm_tools-25.4.1/scripts/monthly-report-gos24.10.gmp.py +193 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/start-multiple-alerts-scan.gmp.py +5 -5
- gvm_tools-25.3.3/scripts/monthly-report-gos24.10.gmp.py +0 -118
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/LICENSE +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/README.md +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/gvmtools/__init__.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/gvmtools/cli.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/gvmtools/config.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/gvmtools/helper.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/gvmtools/parser.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/gvmtools/pyshell.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/gvmtools/script.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/.pylintrc +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/README.md +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/application-detection.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/certbund-report.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/cfg-gen-for-certs.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/check-gmp-gos22.04.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/check-gmp-gos24.10.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/clean-sensor.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/combine-reports.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-alerts-from-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-consolidated-report.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-credentials-from-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-dummy-data.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-filters-from-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-report-format-from-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-schedules-from-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-tags-from-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-targets-from-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-targets-from-host-list.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/create-tasks-from-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/default_report_data.json +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/empty-trash.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/export-certificates.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/export-csv-report.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/export-hosts-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/export-operatingsystems-csv.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/export-pdf-report.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/generate-random-reports.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/generate-random-targets.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-alerts.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-credentials.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-feeds.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-filters.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-groups.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-hosts.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-policies.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-portlists.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-report-formats.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-reports.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-roles.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-scan-configs.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-scanners.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-schedules.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-tags.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-targets.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-tasks.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-tickets.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/list-users.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/monthly-report-gos3.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/monthly-report-gos4.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/nvt-scan.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/requirements.txt +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/ruff.toml +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/scan-new-system.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/send-delta-emails.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/send-schedules.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/send-targets.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/send-tasks.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/ssv_csv.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/start-alert-scan.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/start-nvt-scan.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/start-scans-from-csv.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/stop-all-scans.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/stop-scans-from-csv.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/sync-hosts.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/update-task-target.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/scripts/verify-scanners.gmp.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/__init__.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/root_help.3.10.snap +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/root_help.snap +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/__init__.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/example_schedules.xml +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/example_target.xml +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/example_task.xml +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/get_alerts.xml +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/get_scan_configs.xml +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/invalid_xml.xml +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/test_combine_reports.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/test_create_consolidated_report.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/test_list_tasks.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/test_send_schedules.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/test_send_targets.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/test_send_tasks.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/scripts/test_start_alert_scan.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/socket_help.3.10.snap +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/socket_help.snap +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/ssh_help.3.10.snap +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/ssh_help.snap +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/test.cfg +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/test_auth.cfg +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/test_config.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/test_helper.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/test_parser.py +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/tls_help.3.10.snap +0 -0
- {gvm_tools-25.3.3 → gvm_tools-25.4.1}/tests/tls_help.snap +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: gvm-tools
|
|
3
|
-
Version: 25.
|
|
3
|
+
Version: 25.4.1
|
|
4
4
|
Summary: Tools to control a GSM/GVM over GMP or OSP
|
|
5
5
|
License: GPL-3.0-or-later
|
|
6
|
+
License-File: LICENSE
|
|
6
7
|
Author: Greenbone AG
|
|
7
8
|
Author-email: info@greenbone.net
|
|
8
9
|
Requires-Python: >=3.9.2,<4.0.0
|
|
@@ -18,6 +19,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
18
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
21
|
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
23
|
Classifier: Programming Language :: Python :: 3.9
|
|
22
24
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
25
|
Requires-Dist: python-gvm (>=26.0.0)
|
|
@@ -30,7 +30,7 @@ def check_args(args):
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
def bulk_modify_schedules(gmp, filter_term, new_timezone, new_icalendar):
|
|
33
|
-
get_response = gmp.get_schedules(
|
|
33
|
+
get_response = gmp.get_schedules(filter_string=filter_term)
|
|
34
34
|
schedules = get_response.findall("schedule")
|
|
35
35
|
|
|
36
36
|
for schedule in schedules:
|
|
@@ -159,7 +159,7 @@ class ListGenerator:
|
|
|
159
159
|
step will make the list generation faster.
|
|
160
160
|
"""
|
|
161
161
|
resp = self.gmp.get_info_list(
|
|
162
|
-
info_type=self.gmp.types.InfoType.CVE,
|
|
162
|
+
info_type=self.gmp.types.InfoType.CVE, filter_string="rows=1"
|
|
163
163
|
)
|
|
164
164
|
count = resp.find("info_count").text
|
|
165
165
|
|
|
@@ -170,7 +170,7 @@ class ListGenerator:
|
|
|
170
170
|
while (first + step) < count:
|
|
171
171
|
resp = self.gmp.get_info_list(
|
|
172
172
|
info_type=self.gmp.types.InfoType.CVE,
|
|
173
|
-
|
|
173
|
+
filter_string=f"rows={step} first={first}",
|
|
174
174
|
)
|
|
175
175
|
self._cpe_to_cve(resp)
|
|
176
176
|
first = first + step
|
|
@@ -179,7 +179,7 @@ class ListGenerator:
|
|
|
179
179
|
# find the rest
|
|
180
180
|
resp = self.gmp.get_info_list(
|
|
181
181
|
info_type=self.gmp.types.InfoType.CVE,
|
|
182
|
-
|
|
182
|
+
filter_string=f"rows={count - first} first={first}",
|
|
183
183
|
)
|
|
184
184
|
self._cpe_to_cve(resp)
|
|
185
185
|
progress_bar.done()
|
|
@@ -448,7 +448,8 @@ class Parser:
|
|
|
448
448
|
|
|
449
449
|
cpes = []
|
|
450
450
|
cpe_xml = self.gmp.get_info_list(
|
|
451
|
-
info_type=gmp.types.InfoType.CPE,
|
|
451
|
+
info_type=gmp.types.InfoType.CPE,
|
|
452
|
+
filter_string=f'rows=-1 uuid~"{cpe[0]}:"',
|
|
452
453
|
)
|
|
453
454
|
infos = cpe_xml.findall("info")
|
|
454
455
|
for cpe in infos[:-1]: # -1 because the last info tag is a wrongy. :D
|
|
@@ -27,7 +27,7 @@ def check_args(args):
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
def delete_overrides(gmp, filter_value):
|
|
30
|
-
filters = gmp.get_overrides(
|
|
30
|
+
filters = gmp.get_overrides(filter_string=filter_value)
|
|
31
31
|
|
|
32
32
|
if not filters.xpath("override"):
|
|
33
33
|
print(f"No overrides with filter: {filter_value}")
|
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import sys
|
|
6
6
|
from argparse import Namespace
|
|
7
|
-
from base64 import b64decode
|
|
8
7
|
from pathlib import Path
|
|
9
8
|
|
|
10
9
|
from gvm.protocols.gmp import Gmp
|
|
11
|
-
from
|
|
10
|
+
from lxml import etree
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
def check_args(args):
|
|
@@ -51,9 +50,8 @@ def main(gmp: Gmp, args: Namespace) -> None:
|
|
|
51
50
|
)
|
|
52
51
|
|
|
53
52
|
report_element = response.find("report")
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
content = report_element.find("report_format").tail
|
|
53
|
+
# get the full content of the report element as bytestring
|
|
54
|
+
content = etree.tostring(report_element.find("report"))
|
|
57
55
|
|
|
58
56
|
if not content:
|
|
59
57
|
print(
|
|
@@ -64,16 +62,13 @@ def main(gmp: Gmp, args: Namespace) -> None:
|
|
|
64
62
|
)
|
|
65
63
|
sys.exit(1)
|
|
66
64
|
|
|
67
|
-
#
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
# decode base64
|
|
71
|
-
binary_xml = b64decode(binary_base64_encoded_xml)
|
|
65
|
+
# decode content
|
|
66
|
+
dcontent = content.decode("utf-8")
|
|
72
67
|
|
|
73
68
|
# write to file and support ~ in filename path
|
|
74
69
|
xml_path = Path(xml_filename).expanduser()
|
|
75
70
|
|
|
76
|
-
xml_path.
|
|
71
|
+
xml_path.write_text(dcontent)
|
|
77
72
|
|
|
78
73
|
print("Done. xml created: " + str(xml_path))
|
|
79
74
|
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2017-2024 Greenbone AG
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
4
|
+
|
|
5
|
+
from argparse import ArgumentParser, Namespace, RawDescriptionHelpFormatter
|
|
6
|
+
from datetime import date, datetime, timedelta
|
|
7
|
+
|
|
8
|
+
from gvm.protocols.gmp import Gmp
|
|
9
|
+
from terminaltables import AsciiTable
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def print_reports(
|
|
13
|
+
gmp: Gmp, from_date: date, to_date: date, reports_choice: str
|
|
14
|
+
) -> None:
|
|
15
|
+
host_filter = (
|
|
16
|
+
f"rows=-1 and modified>{from_date.isoformat()} "
|
|
17
|
+
f"and created<{to_date.isoformat()}"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
hosts_xml = gmp.get_hosts(filter_string=host_filter)
|
|
21
|
+
|
|
22
|
+
sum_critical = 0
|
|
23
|
+
sum_high = 0
|
|
24
|
+
sum_medium = 0
|
|
25
|
+
sum_low = 0
|
|
26
|
+
|
|
27
|
+
if reports_choice == "last":
|
|
28
|
+
table_header = [
|
|
29
|
+
"Hostname",
|
|
30
|
+
"IP",
|
|
31
|
+
"Report",
|
|
32
|
+
"Critical",
|
|
33
|
+
"High",
|
|
34
|
+
"Medium",
|
|
35
|
+
"Low",
|
|
36
|
+
]
|
|
37
|
+
elif reports_choice == "list":
|
|
38
|
+
table_header = [
|
|
39
|
+
"Hostname",
|
|
40
|
+
"IP",
|
|
41
|
+
"Reports",
|
|
42
|
+
"Critical",
|
|
43
|
+
"High",
|
|
44
|
+
"Medium",
|
|
45
|
+
"Low",
|
|
46
|
+
]
|
|
47
|
+
else:
|
|
48
|
+
table_header = ["Hostname", "IP", "Critical", "High", "Medium", "Low"]
|
|
49
|
+
|
|
50
|
+
table_data = [table_header]
|
|
51
|
+
|
|
52
|
+
for host in hosts_xml.xpath("asset"):
|
|
53
|
+
ip = host.xpath("name/text()")[0]
|
|
54
|
+
|
|
55
|
+
hostnames = host.xpath(
|
|
56
|
+
'identifiers/identifier/name[text()="hostname"]/../value/text()'
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
if len(hostnames) == 0:
|
|
60
|
+
continue
|
|
61
|
+
|
|
62
|
+
hostname = hostnames[0]
|
|
63
|
+
|
|
64
|
+
results = gmp.get_results(
|
|
65
|
+
details=False,
|
|
66
|
+
filter_string=(
|
|
67
|
+
f"rows=-1 host={ip} and severity>0.0"
|
|
68
|
+
f" and modified>{from_date.isoformat()}"
|
|
69
|
+
f" and modified<{to_date.isoformat()}"
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
unique_vt_results = results.xpath(
|
|
74
|
+
"result["
|
|
75
|
+
" not (./nvt/@oid = preceding-sibling::result/nvt/@oid)"
|
|
76
|
+
"]"
|
|
77
|
+
)
|
|
78
|
+
if len(unique_vt_results) == 0:
|
|
79
|
+
continue
|
|
80
|
+
|
|
81
|
+
low = medium = high = critical = 0
|
|
82
|
+
for result in unique_vt_results:
|
|
83
|
+
threat = result.findtext("threat")
|
|
84
|
+
if threat == "Critical":
|
|
85
|
+
critical += 1
|
|
86
|
+
elif threat == "High":
|
|
87
|
+
high += 1
|
|
88
|
+
elif threat == "Medium":
|
|
89
|
+
medium += 1
|
|
90
|
+
elif threat == "Low":
|
|
91
|
+
low += 1
|
|
92
|
+
|
|
93
|
+
sum_low += low
|
|
94
|
+
sum_medium += medium
|
|
95
|
+
sum_high += high
|
|
96
|
+
sum_critical += critical
|
|
97
|
+
|
|
98
|
+
if reports_choice == "none":
|
|
99
|
+
table_data.append([hostname, ip, critical, high, medium, low])
|
|
100
|
+
else:
|
|
101
|
+
report_host_identifiers = host.xpath(
|
|
102
|
+
"identifiers/identifier[source/deleted = 0 and"
|
|
103
|
+
' (source/type = "Report Host"'
|
|
104
|
+
' or source/type = "Report Host Detail")]'
|
|
105
|
+
)
|
|
106
|
+
report_ids = []
|
|
107
|
+
for identifier in report_host_identifiers:
|
|
108
|
+
mod_date = datetime.fromisoformat(
|
|
109
|
+
identifier.findtext("modification_time")
|
|
110
|
+
).date()
|
|
111
|
+
|
|
112
|
+
if mod_date >= to_date or mod_date < from_date:
|
|
113
|
+
continue
|
|
114
|
+
|
|
115
|
+
report_ids.append(identifier.find("source").get("id"))
|
|
116
|
+
if reports_choice == "last":
|
|
117
|
+
break
|
|
118
|
+
|
|
119
|
+
if reports_choice == "last":
|
|
120
|
+
table_data.append(
|
|
121
|
+
[hostname, ip, report_ids[0], critical, high, medium, low]
|
|
122
|
+
)
|
|
123
|
+
else:
|
|
124
|
+
table_data.append(
|
|
125
|
+
[
|
|
126
|
+
hostname,
|
|
127
|
+
ip,
|
|
128
|
+
",\n".join(report_ids) + "\n",
|
|
129
|
+
critical,
|
|
130
|
+
high,
|
|
131
|
+
medium,
|
|
132
|
+
low,
|
|
133
|
+
]
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
table = AsciiTable(table_data)
|
|
137
|
+
print(f"{table.table}\n")
|
|
138
|
+
print(
|
|
139
|
+
f"Summary of results from {from_date.isoformat()} "
|
|
140
|
+
f"to {to_date.isoformat()}"
|
|
141
|
+
)
|
|
142
|
+
print(f"Critical: {int(sum_critical)}")
|
|
143
|
+
print(f"High: {int(sum_high)}")
|
|
144
|
+
print(f"Medium: {int(sum_medium)}")
|
|
145
|
+
print(f"Low: {int(sum_low)}\n\n")
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def main(gmp: Gmp, args: Namespace) -> None:
|
|
149
|
+
# pylint: disable=undefined-variable
|
|
150
|
+
|
|
151
|
+
description_message = """
|
|
152
|
+
This script will display all vulnerabilities from the hosts of the \
|
|
153
|
+
reports in a given month and year.
|
|
154
|
+
These must be given after the script name as plain numbers.
|
|
155
|
+
|
|
156
|
+
This version is explicitly made for GOS 24.10.
|
|
157
|
+
|
|
158
|
+
Example:
|
|
159
|
+
$ gvm-script --gmp-username name --gmp-password pass \
|
|
160
|
+
ssh --hostname <gsm> scripts/monthly-report2.gmp.py 05 2019
|
|
161
|
+
"""
|
|
162
|
+
|
|
163
|
+
parser = ArgumentParser(
|
|
164
|
+
prog=("gvm-script [...] " + args.script[0]),
|
|
165
|
+
formatter_class=RawDescriptionHelpFormatter,
|
|
166
|
+
prefix_chars="+",
|
|
167
|
+
description=description_message,
|
|
168
|
+
)
|
|
169
|
+
parser.add_argument("month", type=int, help="month of the monthly report")
|
|
170
|
+
parser.add_argument("year", type=int, help="year of the monthly report")
|
|
171
|
+
parser.add_argument(
|
|
172
|
+
"++reports",
|
|
173
|
+
choices=["none", "last", "list"],
|
|
174
|
+
default="last",
|
|
175
|
+
help=(
|
|
176
|
+
"what to show in the reports column:"
|
|
177
|
+
' "none": do not show a reports column;'
|
|
178
|
+
' "last": show the last report in the selected month;'
|
|
179
|
+
' "list": show a list of reports in the selected month.'
|
|
180
|
+
),
|
|
181
|
+
)
|
|
182
|
+
script_args, _ = parser.parse_known_args(args.script[1:])
|
|
183
|
+
|
|
184
|
+
from_date = date(script_args.year, script_args.month, 1)
|
|
185
|
+
to_date = from_date + timedelta(days=31)
|
|
186
|
+
# To have the first day in month
|
|
187
|
+
to_date = to_date.replace(day=1)
|
|
188
|
+
|
|
189
|
+
print_reports(gmp, from_date, to_date, script_args.reports)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
if __name__ == "__gmp__":
|
|
193
|
+
main(gmp, args)
|
|
@@ -137,7 +137,7 @@ def get_alerts(gmp, sender_email, recipient_email, debug=False) -> List[str]:
|
|
|
137
137
|
alert_name = recipient_email
|
|
138
138
|
|
|
139
139
|
# create alert if necessary
|
|
140
|
-
alert_object = gmp.get_alerts(
|
|
140
|
+
alert_object = gmp.get_alerts(filter_string=f"name={alert_name}")
|
|
141
141
|
alert_id = None
|
|
142
142
|
alert = alert_object.xpath("alert")
|
|
143
143
|
if len(alert) == 0:
|
|
@@ -170,7 +170,7 @@ should not have received it.
|
|
|
170
170
|
recipient_email: "to_address",
|
|
171
171
|
},
|
|
172
172
|
)
|
|
173
|
-
alert_object = gmp.get_alerts(
|
|
173
|
+
alert_object = gmp.get_alerts(filter_string=f"name={recipient_email}")
|
|
174
174
|
alert = alert_object.xpath("alert")
|
|
175
175
|
alert_id = alert[0].get("id", "no id found")
|
|
176
176
|
else:
|
|
@@ -182,7 +182,7 @@ should not have received it.
|
|
|
182
182
|
alert_name2 = f"{recipient_email}-2"
|
|
183
183
|
|
|
184
184
|
# create second alert if necessary
|
|
185
|
-
alert_object2 = gmp.get_alerts(
|
|
185
|
+
alert_object2 = gmp.get_alerts(filter_string=f"name={alert_name2}")
|
|
186
186
|
alert_id2 = None
|
|
187
187
|
alert2 = alert_object2.xpath("alert")
|
|
188
188
|
if len(alert2) == 0:
|
|
@@ -214,7 +214,7 @@ should not have received it.
|
|
|
214
214
|
recipient_email: "to_address",
|
|
215
215
|
},
|
|
216
216
|
)
|
|
217
|
-
alert_object2 = gmp.get_alerts(
|
|
217
|
+
alert_object2 = gmp.get_alerts(filter_string=f"name={recipient_email}")
|
|
218
218
|
alert2 = alert_object2.xpath("alert")
|
|
219
219
|
alert_id2 = alert2[0].get("id", "no id found")
|
|
220
220
|
else:
|
|
@@ -235,7 +235,7 @@ def create_and_start_task(
|
|
|
235
235
|
gmp, config_id, target_id, scanner_id, alerts, debug=False
|
|
236
236
|
):
|
|
237
237
|
# Create the task
|
|
238
|
-
tasks = gmp.get_tasks(
|
|
238
|
+
tasks = gmp.get_tasks(filter_string="name~ScanDoneMultipleAlert")
|
|
239
239
|
task_name = f"ScanDoneMultipleAlert{len(tasks.xpath('tasks/@id'))}"
|
|
240
240
|
task_comment = "test comment"
|
|
241
241
|
res = gmp.create_task(
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: 2017-2024 Greenbone AG
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
4
|
-
|
|
5
|
-
import sys
|
|
6
|
-
from argparse import Namespace
|
|
7
|
-
from datetime import date, timedelta
|
|
8
|
-
|
|
9
|
-
from gvm.protocols.gmp import Gmp
|
|
10
|
-
from terminaltables import AsciiTable
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def check_args(args: Namespace) -> None:
|
|
14
|
-
len_args = len(args.script) - 1
|
|
15
|
-
if len_args < 2:
|
|
16
|
-
message = """
|
|
17
|
-
This script will display all vulnerabilities from the hosts of the
|
|
18
|
-
reports in a given month!
|
|
19
|
-
It needs two parameters after the script name.
|
|
20
|
-
First one is the month and second one is the year.
|
|
21
|
-
Both parameters are plain numbers, so no text.
|
|
22
|
-
|
|
23
|
-
Explicitly made for GOS 24.10.
|
|
24
|
-
|
|
25
|
-
1. <month> -- month of the monthly report
|
|
26
|
-
2. <year> -- year of the monthly report
|
|
27
|
-
|
|
28
|
-
Example:
|
|
29
|
-
$ gvm-script --gmp-username name --gmp-password pass \
|
|
30
|
-
ssh --hostname <gsm> scripts/monthly-report2.gmp.py 05 2019
|
|
31
|
-
"""
|
|
32
|
-
print(message)
|
|
33
|
-
sys.exit()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def print_reports(gmp: Gmp, from_date: date, to_date: date) -> None:
|
|
37
|
-
host_filter = (
|
|
38
|
-
f"rows=-1 and modified>{from_date.isoformat()} "
|
|
39
|
-
f"and modified<{to_date.isoformat()}"
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
hosts_xml = gmp.get_hosts(filter_string=host_filter)
|
|
43
|
-
|
|
44
|
-
sum_critical = 0
|
|
45
|
-
sum_high = 0
|
|
46
|
-
sum_medium = 0
|
|
47
|
-
sum_low = 0
|
|
48
|
-
table_data = [
|
|
49
|
-
["Hostname", "IP", "Bericht", "critical", "high", "medium", "low"]
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
for host in hosts_xml.xpath("asset"):
|
|
53
|
-
ip = host.xpath("name/text()")[0]
|
|
54
|
-
|
|
55
|
-
hostnames = host.xpath(
|
|
56
|
-
'identifiers/identifier/name[text()="hostname"]/../value/text()'
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
if len(hostnames) == 0:
|
|
60
|
-
continue
|
|
61
|
-
|
|
62
|
-
hostname = hostnames[0]
|
|
63
|
-
|
|
64
|
-
results = gmp.get_results(
|
|
65
|
-
details=False, filter=f"host={ip} and severity>0.0"
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
low = int(results.xpath('count(//result/threat[text()="Low"])'))
|
|
69
|
-
sum_low += low
|
|
70
|
-
|
|
71
|
-
medium = int(results.xpath('count(//result/threat[text()="Medium"])'))
|
|
72
|
-
sum_medium += medium
|
|
73
|
-
|
|
74
|
-
high = int(results.xpath('count(//result/threat[text()="High"])'))
|
|
75
|
-
sum_high += high
|
|
76
|
-
|
|
77
|
-
critical = int(
|
|
78
|
-
results.xpath('count(//result/threat[text()="Critical"])')
|
|
79
|
-
)
|
|
80
|
-
sum_critical += critical
|
|
81
|
-
|
|
82
|
-
best_os_cpe_report_id = host.xpath(
|
|
83
|
-
'host/detail/name[text()="best_os_cpe"]/../source/@id'
|
|
84
|
-
)[0]
|
|
85
|
-
|
|
86
|
-
table_data.append(
|
|
87
|
-
[hostname, ip, best_os_cpe_report_id, critical, high, medium, low]
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
table = AsciiTable(table_data)
|
|
91
|
-
print(f"{table.table}\n")
|
|
92
|
-
print(
|
|
93
|
-
f"Summary of results from {from_date.isoformat()} "
|
|
94
|
-
f"to {to_date.isoformat()}"
|
|
95
|
-
)
|
|
96
|
-
print(f"Critical: {int(sum_critical)}")
|
|
97
|
-
print(f"High: {int(sum_high)}")
|
|
98
|
-
print(f"Medium: {int(sum_medium)}")
|
|
99
|
-
print(f"Low: {int(sum_low)}\n\n")
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def main(gmp: Gmp, args: Namespace) -> None:
|
|
103
|
-
# pylint: disable=undefined-variable
|
|
104
|
-
|
|
105
|
-
check_args(args)
|
|
106
|
-
|
|
107
|
-
month = int(args.script[1])
|
|
108
|
-
year = int(args.script[2])
|
|
109
|
-
from_date = date(year, month, 1)
|
|
110
|
-
to_date = from_date + timedelta(days=31)
|
|
111
|
-
# To have the first day in month
|
|
112
|
-
to_date = to_date.replace(day=1)
|
|
113
|
-
|
|
114
|
-
print_reports(gmp, from_date, to_date)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if __name__ == "__gmp__":
|
|
118
|
-
main(gmp, args)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|