Skip to content

Commit 71b85ff

Browse files
Chrxxxxsgreenbonebot
authored andcommitted
add argument scan_config_id for get_report to get customizable reports
1 parent acbfce4 commit 71b85ff

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

gvm/protocols/gmp/_gmp226.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def get_report(
103103
filter_id: Optional[str] = None,
104104
delta_report_id: Optional[EntityID] = None,
105105
report_format_id: Optional[Union[str, ReportFormatType]] = None,
106+
report_config_id: Optional[str] = None,
106107
ignore_pagination: Optional[bool] = None,
107108
details: Optional[bool] = True,
108109
) -> T:
@@ -115,6 +116,7 @@ def get_report(
115116
delta_report_id: UUID of an existing report to compare report to.
116117
report_format_id: UUID of report format to use
117118
or ReportFormatType (enum)
119+
report_config_id: UUID of report format config to use
118120
ignore_pagination: Whether to ignore the filter terms "first" and
119121
"rows".
120122
details: Request additional report information details
@@ -127,6 +129,7 @@ def get_report(
127129
filter_id=filter_id,
128130
delta_report_id=delta_report_id,
129131
report_format_id=report_format_id,
132+
report_config_id=report_config_id,
130133
ignore_pagination=ignore_pagination,
131134
details=details,
132135
)

gvm/protocols/gmp/requests/v226/_reports.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def get_report(
4141
filter_id: Optional[str] = None,
4242
delta_report_id: Optional[EntityID] = None,
4343
report_format_id: Optional[Union[str, ReportFormatType]] = None,
44+
report_config_id: Optional[str] = None,
4445
ignore_pagination: Optional[bool] = None,
4546
details: Optional[bool] = True,
4647
) -> Request:
@@ -53,6 +54,7 @@ def get_report(
5354
delta_report_id: UUID of an existing report to compare report to.
5455
report_format_id: UUID of report format to use
5556
or ReportFormatType (enum)
57+
report_config_id: UUID of report format config to use
5658
ignore_pagination: Whether to ignore the filter terms "first" and
5759
"rows".
5860
details: Request additional report information details
@@ -76,6 +78,9 @@ def get_report(
7678
if report_format_id:
7779
cmd.set_attribute("format_id", str(report_format_id))
7880

81+
if report_config_id:
82+
cmd.set_attribute("config_id", str(report_config_id))
83+
7984
if ignore_pagination is not None:
8085
cmd.set_attribute("ignore_pagination", to_bool(ignore_pagination))
8186

tests/protocols/gmp/requests/v226/test_reports.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ def test_get_report_with_report_format_id(self):
7272
b'<get_reports report_id="report_id" usage_type="scan" format_id="report_format_id" details="1"/>',
7373
)
7474

75+
def test_get_report_with_report_format_id_and_config_id(self):
76+
request = Reports.get_report(
77+
"report_id",
78+
report_format_id="report_format_id",
79+
report_config_id="report_config_id",
80+
)
81+
self.assertEqual(
82+
bytes(request),
83+
b'<get_reports report_id="report_id" usage_type="scan" format_id="report_format_id" config_id="report_config_id" details="1"/>',
84+
)
85+
7586
def test_get_report_with_ignore_pagination(self):
7687
request = Reports.get_report("report_id", ignore_pagination=True)
7788
self.assertEqual(

tests/protocols/gmpv226/entities/reports/test_get_report.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ def test_get_report_with_report_format_id(self):
3636
b'<get_reports report_id="r1" usage_type="scan" format_id="bar" details="1"/>'
3737
)
3838

39+
def test_get_report_with_report_format_id_and_config_id(self):
40+
self.gmp.get_report(
41+
report_id="r1", report_format_id="bar", report_config_id="c1"
42+
)
43+
44+
self.connection.send.has_been_called_with(
45+
b'<get_reports report_id="r1" usage_type="scan" format_id="bar" config_id="c1" details="1"/>'
46+
)
47+
3948
def test_get_report_with_report_format_type(self):
4049
self.gmp.get_report(
4150
report_id="r1", report_format_id=ReportFormatType.TXT

0 commit comments

Comments
 (0)