gvm-tools 25.3.2__tar.gz → 25.4.0__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.

Files changed (114) hide show
  1. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/PKG-INFO +1 -1
  2. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/gvmtools/__version__.py +1 -1
  3. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/pyproject.toml +1 -1
  4. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/bulk-modify-schedules.gmp.py +1 -1
  5. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-cve-report-from-json.gmp.py +5 -4
  6. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/delete-overrides-by-filter.gmp.py +1 -1
  7. gvm_tools-25.4.0/scripts/monthly-report-gos24.10.gmp.py +193 -0
  8. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/start-multiple-alerts-scan.gmp.py +5 -5
  9. gvm_tools-25.3.2/scripts/monthly-report-gos24.10.gmp.py +0 -118
  10. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/LICENSE +0 -0
  11. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/README.md +0 -0
  12. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/gvmtools/__init__.py +0 -0
  13. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/gvmtools/cli.py +0 -0
  14. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/gvmtools/config.py +0 -0
  15. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/gvmtools/helper.py +0 -0
  16. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/gvmtools/parser.py +0 -0
  17. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/gvmtools/pyshell.py +0 -0
  18. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/gvmtools/script.py +0 -0
  19. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/.pylintrc +0 -0
  20. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/README.md +0 -0
  21. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/application-detection.gmp.py +0 -0
  22. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/certbund-report.gmp.py +0 -0
  23. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/cfg-gen-for-certs.gmp.py +0 -0
  24. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/check-gmp-gos22.04.gmp.py +0 -0
  25. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/check-gmp-gos24.10.gmp.py +0 -0
  26. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/clean-sensor.gmp.py +0 -0
  27. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/combine-reports.gmp.py +0 -0
  28. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-alerts-from-csv.gmp.py +0 -0
  29. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-consolidated-report.gmp.py +0 -0
  30. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-credentials-from-csv.gmp.py +0 -0
  31. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-dummy-data.gmp.py +0 -0
  32. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-filters-from-csv.gmp.py +0 -0
  33. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-report-format-from-csv.gmp.py +0 -0
  34. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-schedules-from-csv.gmp.py +0 -0
  35. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-tags-from-csv.gmp.py +0 -0
  36. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-targets-from-csv.gmp.py +0 -0
  37. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-targets-from-host-list.gmp.py +0 -0
  38. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/create-tasks-from-csv.gmp.py +0 -0
  39. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/default_report_data.json +0 -0
  40. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/empty-trash.gmp.py +0 -0
  41. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/export-certificates.gmp.py +0 -0
  42. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/export-csv-report.gmp.py +0 -0
  43. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/export-hosts-csv.gmp.py +0 -0
  44. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/export-operatingsystems-csv.gmp.py +0 -0
  45. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/export-pdf-report.gmp.py +0 -0
  46. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/export-xml-report.gmp.py +0 -0
  47. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/generate-random-reports.gmp.py +0 -0
  48. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/generate-random-targets.gmp.py +0 -0
  49. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-alerts.gmp.py +0 -0
  50. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-credentials.gmp.py +0 -0
  51. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-feeds.gmp.py +0 -0
  52. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-filters.gmp.py +0 -0
  53. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-groups.gmp.py +0 -0
  54. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-hosts.gmp.py +0 -0
  55. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-policies.gmp.py +0 -0
  56. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-portlists.gmp.py +0 -0
  57. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-report-formats.gmp.py +0 -0
  58. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-reports.gmp.py +0 -0
  59. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-roles.gmp.py +0 -0
  60. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-scan-configs.gmp.py +0 -0
  61. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-scanners.gmp.py +0 -0
  62. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-schedules.gmp.py +0 -0
  63. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-tags.gmp.py +0 -0
  64. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-targets.gmp.py +0 -0
  65. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-tasks.gmp.py +0 -0
  66. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-tickets.gmp.py +0 -0
  67. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/list-users.gmp.py +0 -0
  68. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/monthly-report-gos3.gmp.py +0 -0
  69. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/monthly-report-gos4.gmp.py +0 -0
  70. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/nvt-scan.gmp.py +0 -0
  71. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/requirements.txt +0 -0
  72. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/ruff.toml +0 -0
  73. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/scan-new-system.gmp.py +0 -0
  74. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/send-delta-emails.gmp.py +0 -0
  75. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/send-schedules.gmp.py +0 -0
  76. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/send-targets.gmp.py +0 -0
  77. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/send-tasks.gmp.py +0 -0
  78. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/ssv_csv.py +0 -0
  79. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/start-alert-scan.gmp.py +0 -0
  80. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/start-nvt-scan.gmp.py +0 -0
  81. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/start-scans-from-csv.py +0 -0
  82. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/stop-all-scans.gmp.py +0 -0
  83. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/stop-scans-from-csv.py +0 -0
  84. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/sync-hosts.gmp.py +0 -0
  85. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/update-task-target.gmp.py +0 -0
  86. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/scripts/verify-scanners.gmp.py +0 -0
  87. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/__init__.py +0 -0
  88. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/root_help.3.10.snap +0 -0
  89. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/root_help.snap +0 -0
  90. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/__init__.py +0 -0
  91. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/example_schedules.xml +0 -0
  92. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/example_target.xml +0 -0
  93. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/example_task.xml +0 -0
  94. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/get_alerts.xml +0 -0
  95. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/get_scan_configs.xml +0 -0
  96. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/invalid_xml.xml +0 -0
  97. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/test_combine_reports.py +0 -0
  98. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/test_create_consolidated_report.py +0 -0
  99. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/test_list_tasks.py +0 -0
  100. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/test_send_schedules.py +0 -0
  101. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/test_send_targets.py +0 -0
  102. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/test_send_tasks.py +0 -0
  103. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/scripts/test_start_alert_scan.py +0 -0
  104. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/socket_help.3.10.snap +0 -0
  105. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/socket_help.snap +0 -0
  106. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/ssh_help.3.10.snap +0 -0
  107. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/ssh_help.snap +0 -0
  108. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/test.cfg +0 -0
  109. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/test_auth.cfg +0 -0
  110. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/test_config.py +0 -0
  111. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/test_helper.py +0 -0
  112. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/test_parser.py +0 -0
  113. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/tls_help.3.10.snap +0 -0
  114. {gvm_tools-25.3.2 → gvm_tools-25.4.0}/tests/tls_help.snap +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: gvm-tools
3
- Version: 25.3.2
3
+ Version: 25.4.0
4
4
  Summary: Tools to control a GSM/GVM over GMP or OSP
5
5
  License: GPL-3.0-or-later
6
6
  Author: Greenbone AG
@@ -2,4 +2,4 @@
2
2
 
3
3
  # THIS IS AN AUTOGENERATED FILE. DO NOT TOUCH!
4
4
 
5
- __version__ = "25.3.2"
5
+ __version__ = "25.4.0"
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "gvm-tools"
7
- version = "25.3.2"
7
+ version = "25.4.0"
8
8
  authors = ["Greenbone AG <info@greenbone.net>"]
9
9
  description = "Tools to control a GSM/GVM over GMP or OSP"
10
10
  license = "GPL-3.0-or-later"
@@ -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(filter=filter_term)
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, filter="rows=1"
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
- filter=f"rows={step} first={first}",
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
- filter=f"rows={count - first} first={first}",
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, filter=f'rows=-1 uuid~"{cpe[0]}:"'
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(filter=filter_value)
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}")
@@ -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(filter=f"name={alert_name}")
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(filter=f"name={recipient_email}")
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(filter=f"name={alert_name2}")
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(filter=f"name={recipient_email}")
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(filter="name~ScanDoneMultipleAlert")
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