Not able create task using Openvas Api

717 views Asked by At

I was trying out the openvas API 0.1.0 to leverage python abilities with Openvas. But I'm not able to create a task where as i can start a task already created. I'm also generating the xml same as the one in documentation

request = XMLNode("create_task",
                              XMLNode("config", config),
                              XMLNode("target", target),
                              XMLNode("scanner", scanner),
                              XMLNode("name", name),
                              XMLNode("comment", comment),
                              )

Which is giving me

open_lib.Client Error: 400 CREATE_TASK requires a config a scanner, and a target

I tried by giving arguments in both string format and in uuid with no help.

Can anybody help me here?

Thanks

1

There are 1 answers

0
danielpops On

The config and target need to be xml attributes, and you should be providing the uuid. The following works well for me:

from lxml.etree import Element, SubElement
def create_task(self, name, target_id, config_name, comment=None):
    request = Element('create_task')
    SubElement(request, 'name').text = name
    SubElement(request, 'config', {'id': config_id_map[config_name]})
    SubElement(request, 'target', {'id': target_id})
    if comment:
        SubElement(request, 'comment').text = comment
    response = self._send_xml_request(request)
    task_id = response.get('id')
    return task_id