Skip to content

Commit 2bc27a2

Browse files
committed
Add: Allow to use ignore_pagination for get_tasks
GMP has the ignore_pagination attribute for getting a list of tasks. Add the argument to python-gvm too. Closes #1138
1 parent 2349792 commit 2bc27a2

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

Diff for: gvm/protocols/gmp/_gmp224.py

+4
Original file line numberDiff line numberDiff line change
@@ -3805,6 +3805,7 @@ def get_tasks(
38053805
trash: Optional[bool] = None,
38063806
details: Optional[bool] = None,
38073807
schedules_only: Optional[bool] = None,
3808+
ignore_pagination: Optional[bool] = None,
38083809
) -> T:
38093810
"""Request a list of tasks
38103811
@@ -3815,6 +3816,8 @@ def get_tasks(
38153816
details: Whether to include full task details
38163817
schedules_only: Whether to only include id, name and schedule
38173818
details
3819+
ignore_pagination: Whether to ignore pagination settings (filter
3820+
terms "first" and "rows"). Default is False.
38183821
"""
38193822
return self._send_and_transform_command(
38203823
Tasks.get_tasks(
@@ -3823,6 +3826,7 @@ def get_tasks(
38233826
trash=trash,
38243827
details=details,
38253828
schedules_only=schedules_only,
3829+
ignore_pagination=ignore_pagination,
38263830
)
38273831
)
38283832

Diff for: gvm/protocols/gmp/requests/v224/_tasks.py

+6
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def get_tasks(
200200
trash: Optional[bool] = None,
201201
details: Optional[bool] = None,
202202
schedules_only: Optional[bool] = None,
203+
ignore_pagination: Optional[bool] = None,
203204
) -> Request:
204205
"""Request a list of tasks
205206
@@ -210,6 +211,8 @@ def get_tasks(
210211
details: Whether to include full task details
211212
schedules_only: Whether to only include id, name and schedule
212213
details
214+
ignore_pagination: Whether to ignore pagination settings (filter
215+
terms "first" and "rows"). Default is False.
213216
"""
214217
cmd = XmlCommand("get_tasks")
215218
cmd.set_attribute("usage_type", "scan")
@@ -225,6 +228,9 @@ def get_tasks(
225228
if schedules_only is not None:
226229
cmd.set_attribute("schedules_only", to_bool(schedules_only))
227230

231+
if ignore_pagination is not None:
232+
cmd.set_attribute("ignore_pagination", to_bool(ignore_pagination))
233+
228234
return cmd
229235

230236
@classmethod

Diff for: tests/protocols/gmp/requests/v224/test_tasks.py

+13
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,19 @@ def test_get_tasks_with_schedules_only(self):
453453
b'<get_tasks usage_type="scan" schedules_only="0"/>',
454454
)
455455

456+
def test_get_tasks_with_ignore_pagination(self):
457+
request = Tasks().get_tasks(ignore_pagination=True)
458+
self.assertEqual(
459+
bytes(request),
460+
b'<get_tasks usage_type="scan" ignore_pagination="1"/>',
461+
)
462+
463+
request = Tasks().get_tasks(ignore_pagination=False)
464+
self.assertEqual(
465+
bytes(request),
466+
b'<get_tasks usage_type="scan" ignore_pagination="0"/>',
467+
)
468+
456469
def test_get_task(self):
457470
request = Tasks().get_task("task_id")
458471
self.assertEqual(

Diff for: tests/protocols/gmpv224/entities/tasks/test_get_tasks.py

+13
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,16 @@ def test_get_tasks_with_schedules_only(self):
5353
self.connection.send.has_been_called_with(
5454
b'<get_tasks usage_type="scan" schedules_only="1"/>'
5555
)
56+
57+
def test_get_tasks_with_ignore_pagination(self):
58+
self.gmp.get_tasks(ignore_pagination=True)
59+
60+
self.connection.send.has_been_called_with(
61+
b'<get_tasks usage_type="scan" ignore_pagination="1"/>'
62+
)
63+
64+
self.gmp.get_tasks(ignore_pagination=False)
65+
66+
self.connection.send.has_been_called_with(
67+
b'<get_tasks usage_type="scan" ignore_pagination="0"/>'
68+
)

0 commit comments

Comments
 (0)