Filter in gmp.get_tasks() on gvm-tools




i use gvm-tools in batch mode for monitoring tool over gvm-pyshell.
I call gmp.get_tasks() and iterate over all values in xml tree.

It is possible to filter the gmp.get_tasks() call with “apply_overrides=1”?

many thanks


I haven’t tested the code but maybe




It works, but all Hosts with overrides are now not in respose…
I would like only that overides not in anser, analog GSA Management Website.
Any idea?

thx Karsten


No Idea for this use case?
We want this request for my monitoring tool, i need all host but not the overrides vulnerabilitys in anser.
With "filter=“apply_overrides=1” no hosts with overrides are in xml tree…


Sorry I really don’t understand your use case but if you can get the desired result in GSA just copy the filter from the url and add it to gmp.get_task(filter="…")


My usecase is following:
We want all tasks in gmp.get_task() anser include the task with overrides,
but the tasks with overirdes are not in xml anser.
For instace, task ‘test’ has 5 vulnerabilitys, but only 4 must be in anser, because 1 is defined as overly.
When i use the filter “apply_overrides=1”, no tasks with overrides are in anser.
The filter in GSA Management is “first=1 rows=-1 sort=name apply_overrides=1”, i try this but the result ist the same as “apply_overrides=1”.


Just for clarification, you can not override tasks. You are overriding scan results of tasks.

Therefore get_tasks should always return the same list of tasks independent of apply_overrides in the filter. The difference is when setting apply_overrides=1 in the filter of get_tasks the severity of the tasks are calculated by considering the overrides. If apply_overrides=0 the overrides aren’t considered for the severity of the tasks.


I visited the forum for this exact same question and apply_overrides changed the scoring perfectly for me. Via my gvm-pyshell script, the previous score of 4.0 without overrides is now 2.6. Thanks @bricks!


Im a litte bit confused…
When is use task_list = gmp.get_tasks() all 31 tasks are in task list.
When i use gmp.get_tasks(filter=“apply_overrides=1”) 10 tasks are in task list,
overrides are not in anser.
When i use gmp.get_tasks(filter=“apply_overrides=0”) 10 tasks are in task list,
overrides are in anser.
My use case is, that always all 31 tasks are in anser and calculated by considering the overrides.
It this posible?

thx Karsten


@Karsten could you show me the filters/term/text() of all these three responses? I suppose the differences are caused by some default filters getting applied too.


Here is my Code:

task_list = gmp.get_tasks()
task = dict()

for task in task_list.xpath(‘task’):
name = task.xpath(‘name/text()’)
name = str(name)
print(’<<<<’ + name[2:-2] + ‘>>>>’)
last_report_high = task.xpath(‘last_report/report/result_count/hole/text()’)
last_report_high = str(last_report_high)
last_report_medium = task.xpath(‘last_report/report/result_count/warning/text()’)
last_report_medium = str(last_report_medium)
last_report_low = task.xpath(‘last_report/report/result_count/info/text()’)
last_report_low = str(last_report_low)
print(last_report_high[2:-2] + ‘,’ + last_report_medium[2:-2] + ‘,’ + last_report_low[2:-2])

What must be change?


You have to check the full applied filter term for your different queries. To get the term you can do something like

term = task.xpath('filters/term/text()')

For some background. The current implementation always adds filter keywords like rows or sort automatically to you request. Therefore I suppose your three requests are getting different filter terms.


I paste this in for loop:
filter = task.xpath(‘filters/term/text()’)

Hmm, the response is:

equal as use filter=“apply_overrides=1” or not.


Sorry, should have been



with filter=“apply_overrides=1” 10 resultes:

[‘apply_overrides=1 first=1 rows=10 sort=name’]
[‘apply_overrides=1 first=1 rows=10 sort=name’]

witout filter=“apply_overrides=1” 31 resultes:

[‘first=1 rows=-1 sort=name’]
[‘first=1 rows=-1 sort=name’]

task_list = gmp.get_tasks(filter=“apply_overrides=1 rows=-1”) is the anser.

thx for your help!


Yeah that was my guess :slight_smile: