Gmp.get_tasks() shows only 10 Elements

gmp.get_tasks() shows only 10 Elements … Is there a way to get the task greater then 10?

from gvmtools.helper import Table
response_xml = gmp.get_tasks()
print(response_xml.xpath(‘task’))

[<Element task at 0x7f0cf3d9ddc0>, <Element task at 0x7f0cf3d9dd00>, <Element task at 0x7f0cf3d9d940>, <Element task at 0x7f0cf3d9dbc0>, <Element task at 0x7f0cf3d9d400>, <Element task at 0x7f0cf3d9da80>, <Element task at 0x7f0cf3d9d480>, <Element task at 0x7f0cf3d9db40>, <Element task at 0x7f0cf3d9dec0>, <Element task at 0x7f0cf3d9df40>]

You just need to set a filter:
gmp.get_tasks(filter="rows=42")

Btw. you can import the pretty_print function with
from gvm.xml import pretty_print
This function prints indented xml …

2 Likes

thank you very much … wher do I find this information? :slight_smile:

E.g. here

2 Likes

@y0urself This filter didn’t work in my case, can you help me? Greenbone api return only 10 elements.

Environment:

Greenbone Security Assistant 21.4.4
Greenbone Vulnerability Manager 21.4.5
OpenVAS 21.4.4
gvm-libs 21.4.4
Operating system:Kali

I need more details. Otherwise I can only guess, which is not very helpful in most cases.
What command have you explicitly called, so I can help you?

Edit: You probably need to use filter_string instead of filter. It just came into my mind, that we changed the API in this case to filter_string, see here.

1 Like

@y0urself
Firstly thank you for answer me.

I have 59 tasks and all the names match with the string “app”. I’m using tasks = gmp.get_tasks(filter_string=‘app’) and I receive just 10 elements

Here you can see, that you need to specify your filter a little bit more detailed.
As for your particular situation, you can probably go with

tasks = gmp.get_tasks(filter_string="name~app and rows=-1") # -1 in this case means all
1 Like

OMG!!!

Thank you very much… It was so simple and I was trying much more complex things.

2 Likes

The old “lets just change the API” trick

1 Like