From e09c9d051b4bfb24b1cdb5df6c1709a73b3ec724 Mon Sep 17 00:00:00 2001 From: Chrxxxxs <134285960+Chrxxxxs@users.noreply.github.com> Date: Fri, 23 May 2025 13:40:43 +0200 Subject: [PATCH] add argument scan_config_id for get_report to get customizable reports --- gvm/protocols/gmp/_gmp226.py | 3 +++ gvm/protocols/gmp/requests/v226/_reports.py | 5 +++++ tests/protocols/gmp/requests/v226/test_reports.py | 11 +++++++++++ .../gmpv226/entities/reports/test_get_report.py | 9 +++++++++ 4 files changed, 28 insertions(+) diff --git a/gvm/protocols/gmp/_gmp226.py b/gvm/protocols/gmp/_gmp226.py index da989404..10dfe971 100644 --- a/gvm/protocols/gmp/_gmp226.py +++ b/gvm/protocols/gmp/_gmp226.py @@ -103,6 +103,7 @@ def get_report( filter_id: Optional[str] = None, delta_report_id: Optional[EntityID] = None, report_format_id: Optional[Union[str, ReportFormatType]] = None, + report_config_id: Optional[str] = None, ignore_pagination: Optional[bool] = None, details: Optional[bool] = True, ) -> T: @@ -115,6 +116,7 @@ def get_report( delta_report_id: UUID of an existing report to compare report to. report_format_id: UUID of report format to use or ReportFormatType (enum) + report_config_id: UUID of report format config to use ignore_pagination: Whether to ignore the filter terms "first" and "rows". details: Request additional report information details @@ -127,6 +129,7 @@ def get_report( filter_id=filter_id, delta_report_id=delta_report_id, report_format_id=report_format_id, + report_config_id=report_config_id, ignore_pagination=ignore_pagination, details=details, ) diff --git a/gvm/protocols/gmp/requests/v226/_reports.py b/gvm/protocols/gmp/requests/v226/_reports.py index 1c381f73..8b5ef253 100644 --- a/gvm/protocols/gmp/requests/v226/_reports.py +++ b/gvm/protocols/gmp/requests/v226/_reports.py @@ -41,6 +41,7 @@ def get_report( filter_id: Optional[str] = None, delta_report_id: Optional[EntityID] = None, report_format_id: Optional[Union[str, ReportFormatType]] = None, + report_config_id: Optional[str] = None, ignore_pagination: Optional[bool] = None, details: Optional[bool] = True, ) -> Request: @@ -53,6 +54,7 @@ def get_report( delta_report_id: UUID of an existing report to compare report to. report_format_id: UUID of report format to use or ReportFormatType (enum) + report_config_id: UUID of report format config to use ignore_pagination: Whether to ignore the filter terms "first" and "rows". details: Request additional report information details @@ -76,6 +78,9 @@ def get_report( if report_format_id: cmd.set_attribute("format_id", str(report_format_id)) + if report_config_id: + cmd.set_attribute("config_id", str(report_config_id)) + if ignore_pagination is not None: cmd.set_attribute("ignore_pagination", to_bool(ignore_pagination)) diff --git a/tests/protocols/gmp/requests/v226/test_reports.py b/tests/protocols/gmp/requests/v226/test_reports.py index 5e6867e4..e1bfdbe1 100644 --- a/tests/protocols/gmp/requests/v226/test_reports.py +++ b/tests/protocols/gmp/requests/v226/test_reports.py @@ -72,6 +72,17 @@ def test_get_report_with_report_format_id(self): b'', ) + def test_get_report_with_report_format_id_and_config_id(self): + request = Reports.get_report( + "report_id", + report_format_id="report_format_id", + report_config_id="report_config_id", + ) + self.assertEqual( + bytes(request), + b'', + ) + def test_get_report_with_ignore_pagination(self): request = Reports.get_report("report_id", ignore_pagination=True) self.assertEqual( diff --git a/tests/protocols/gmpv226/entities/reports/test_get_report.py b/tests/protocols/gmpv226/entities/reports/test_get_report.py index 8817972a..77e402bf 100644 --- a/tests/protocols/gmpv226/entities/reports/test_get_report.py +++ b/tests/protocols/gmpv226/entities/reports/test_get_report.py @@ -36,6 +36,15 @@ def test_get_report_with_report_format_id(self): b'' ) + def test_get_report_with_report_format_id_and_config_id(self): + self.gmp.get_report( + report_id="r1", report_format_id="bar", report_config_id="c1" + ) + + self.connection.send.has_been_called_with( + b'' + ) + def test_get_report_with_report_format_type(self): self.gmp.get_report( report_id="r1", report_format_id=ReportFormatType.TXT