From 1b00ca4b2712fa4cbb38ebcfc0d4317f8ae9b877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 7 Oct 2019 15:35:10 +0200 Subject: [PATCH 1/3] Add ignore_pagination argument to get_report --- gvm/protocols/gmpv7/__init__.py | 8 +++++++- tests/protocols/gmpv7/test_get_report.py | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gvm/protocols/gmpv7/__init__.py b/gvm/protocols/gmpv7/__init__.py index 1d76c366a..656ecec64 100644 --- a/gvm/protocols/gmpv7/__init__.py +++ b/gvm/protocols/gmpv7/__init__.py @@ -3407,7 +3407,8 @@ def get_report( filter: Optional[str] = None, filter_id: Optional[str] = None, delta_report_id: Optional[str] = None, - report_format_id: Optional[str] = None + report_format_id: Optional[str] = None, + ignore_pagination: Optional[bool] = None ) -> Any: """Request a single report @@ -3417,6 +3418,8 @@ def get_report( filter_id: UUID of filter to use to filter results in the report delta_report_id: UUID of an existing report to compare report to. report_format_id: UUID of report format to use + ignore_pagination: Whether to ignore the filter terms "first" and + "rows". Returns: The response. See :py:meth:`send_command` for details. @@ -3435,6 +3438,9 @@ def get_report( if report_format_id: cmd.set_attribute("format_id", report_format_id) + if ignore_pagination is not None: + cmd.set_attribute("ignore_pagination", _to_bool(ignore_pagination)) + return self._send_xml_command(cmd) def get_report_formats( diff --git a/tests/protocols/gmpv7/test_get_report.py b/tests/protocols/gmpv7/test_get_report.py index bcaac8faa..43c3f748e 100644 --- a/tests/protocols/gmpv7/test_get_report.py +++ b/tests/protocols/gmpv7/test_get_report.py @@ -59,6 +59,19 @@ def test_get_report_with_delta_report_id(self): '' ) + def test_get_report_with_ignore_pagination(self): + self.gmp.get_report(report_id='r1', ignore_pagination=True) + + self.connection.send.has_been_called_with( + '' + ) + + self.gmp.get_report(report_id='r1', ignore_pagination=False) + + self.connection.send.has_been_called_with( + '' + ) + if __name__ == '__main__': unittest.main() From e165d3c4fe4d49053f42203cd67ebe8a45cb17f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 7 Oct 2019 15:38:34 +0200 Subject: [PATCH 2/3] Allow to query report details With GMP 7 and 8 details is 1 by default. With GMP 9 the default changed to be 0. --- gvm/protocols/gmpv7/__init__.py | 7 ++++++- tests/protocols/gmpv7/test_get_report.py | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gvm/protocols/gmpv7/__init__.py b/gvm/protocols/gmpv7/__init__.py index 656ecec64..243e65f5e 100644 --- a/gvm/protocols/gmpv7/__init__.py +++ b/gvm/protocols/gmpv7/__init__.py @@ -3408,7 +3408,8 @@ def get_report( filter_id: Optional[str] = None, delta_report_id: Optional[str] = None, report_format_id: Optional[str] = None, - ignore_pagination: Optional[bool] = None + ignore_pagination: Optional[bool] = None, + details: Optional[bool] = None ) -> Any: """Request a single report @@ -3420,6 +3421,7 @@ def get_report( report_format_id: UUID of report format to use ignore_pagination: Whether to ignore the filter terms "first" and "rows". + details: Request addititional report information details Returns: The response. See :py:meth:`send_command` for details. @@ -3441,6 +3443,9 @@ def get_report( if ignore_pagination is not None: cmd.set_attribute("ignore_pagination", _to_bool(ignore_pagination)) + if details is not None: + cmd.set_attribute("details", _to_bool(details)) + return self._send_xml_command(cmd) def get_report_formats( diff --git a/tests/protocols/gmpv7/test_get_report.py b/tests/protocols/gmpv7/test_get_report.py index 43c3f748e..0a6c48722 100644 --- a/tests/protocols/gmpv7/test_get_report.py +++ b/tests/protocols/gmpv7/test_get_report.py @@ -72,6 +72,19 @@ def test_get_report_with_ignore_pagination(self): '' ) + def test_get_report_with_details(self): + self.gmp.get_report(report_id='r1', details=True) + + self.connection.send.has_been_called_with( + '' + ) + + self.gmp.get_report(report_id='r1', details=False) + + self.connection.send.has_been_called_with( + '' + ) + if __name__ == '__main__': unittest.main() From 43a867082cc7793f3049025afd697fc8f689e87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 7 Oct 2019 15:42:02 +0200 Subject: [PATCH 3/3] Added changelog entry for ignore_pagination and details --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab6c5fe0c..0e763c7a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] ### Added +* Added ignore_pagination and details arguments for get_report [PR 163](https://github.com/greenbone/python-gvm/pull/163) * Introducing Gmpv9 [PR 157](https://github.com/greenbone/python-gvm/pull/157) * Added new `create_audit` method, to create a task with the `usage_type` `audit` [PR 157](https://github.com/greenbone/python-gvm/pull/157) * Added new `create_policy` method, to create a config with the `usage_type` `policy` [PR 157](https://github.com/greenbone/python-gvm/pull/157)