GVM 10 - Failed to parse client XML: Error

GVM versions

gsa: 8.0.1
gvm: 8.0.1
openvas-scanner: 6.0.1
gvm-libs: 10.0.1

Environment

Operating system: Ubuntu 19.04
Kernel: Linux variant-1 5.0.0-37-generic #40-Ubuntu SMP Thu Nov 14 00:14:01 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Installation method / source: I built from source by downloading the relevant releases on github, then building each necessary component from source.

Problem: I am interacting with my Openvas instance using Python. My script is as follows. I used the template from gvm-tools for my version and python-gvm. All I am doing is providing a taskname and a valid target_id and attempting to create a new task.

from gvm.connections import UnixSocketConnection
from gvm.protocols.latest import Gmp
from gvm.transforms import EtreeTransform
import logging
import psycopg2
import simplejson
import subprocess
import time

# path to unix socket
path = '/usr/local/var/run/gvmd.sock'
connection = UnixSocketConnection(path=path)
transform = EtreeTransform()

# logfile
logging.basicConfig(filename = "task_creation.log", level = logging.INFO)

# setup connection
gmp = Gmp(connection=connection, transform=transform)

# authentication credentials
ov_usern = $
ov_passw = $
ov_scanner_id = '08b69003-5fc2-4037-a479-93b440211c73'
ov_config_id = '698f691e-7489-11df-9d8c-002264764cea'

taskname = 'Task One'

with gmp:
    gmp.authenticate(ov_usern, ov_passw)
    target_id = '78bc45d9-b5d6-4088-aafe-770689ce4a9d'
    print(target_id)
    task_id = gmp.create_task(taskname, ov_config_id, target_id, ov_scanner_id)
    print(task_id)
    print(type(task_id))

However, when trying to do this, I get a failure on the gvmd side, as follows:

I attempted to create the task multiple times.
gvmd.log - source of the problem

event task:MESSAGE:2019-12-16 03h51.30 UTC:7359: Status of task  (bfa9240e-56fa-48af-a579-446d08ea5931) has changed to New
md    gmp:   INFO:2019-12-16 03h51.30 UTC:7359:    Failed to parse client XML: Error
event task:MESSAGE:2019-12-16 03h53.06 UTC:7638: Status of task  (336d19d3-4ffd-4ce2-a7ed-ece60339778e) has changed to New
md    gmp:   INFO:2019-12-16 03h53.06 UTC:7638:    Failed to parse client XML: Error
event task:MESSAGE:2019-12-16 03h56.07 UTC:8141: Status of task  (af0ebfef-fc8d-49a5-b074-64dce4bef696) has changed to New
md    gmp:   INFO:2019-12-16 03h56.07 UTC:8141:    Failed to parse client XML: Error
event task:MESSAGE:2019-12-16 04h11.40 UTC:10778: Status of task  (46915c7a-1ee2-4d81-923c-f972e816488f) has changed to New
md    gmp:   INFO:2019-12-16 04h11.40 UTC:10778:    Failed to parse client XML: Error
event task:MESSAGE:2019-12-16 04h20.19 UTC:12297: Status of task  (9dac0c70-a40c-46a2-a76c-fa0d65aeb780) has changed to New
md    gmp:   INFO:2019-12-16 04h20.19 UTC:12297:    Failed to parse client XML: Error
event task:MESSAGE:2019-12-16 04h22.48 UTC:12807: Status of task  (a6783278-2da1-43c9-9f21-d522024f829a) has changed to New
md    gmp:   INFO:2019-12-16 04h22.48 UTC:12807:    Failed to parse client XML: Error


gsad.log - there is nothing relevant here

gsad main:WARNING:2019-12-16 04h13.00 UTC:1275: MHD: Error: received handshake message out of context
gsad main:WARNING:2019-12-16 04h14.03 UTC:1275: MHD: Error: received handshake message out of context
gsad main:WARNING:2019-12-16 04h14.16 UTC:1275: MHD: Failed to send data in request for `/static/js/main.85fd8104.chunk.js'.
gsad main:WARNING:2019-12-16 04h14.16 UTC:1275: MHD: Failed to send data in request for `/static/js/2.33b2c378.chunk.js'.
gsad main:WARNING:2019-12-16 04h14.28 UTC:1275: MHD: Failed to send data in request for `/static/js/2.33b2c378.chunk.js'.
gsad main:WARNING:2019-12-16 04h14.28 UTC:1275: MHD: Failed to send data in request for `/static/js/main.85fd8104.chunk.js'.
gsad main:WARNING:2019-12-16 04h14.44 UTC:1275: MHD: Error: received handshake message out of context
gsad main:WARNING:2019-12-16 04h14.44 UTC:1275: MHD: Error: received handshake message out of context
gsad main:WARNING:2019-12-16 04h14.44 UTC:1275: MHD: Error: received handshake message out of context
gsad main:WARNING:2019-12-16 04h15.02 utc:1276: MHD: Application reported internal error, closing connection.
gsad main:WARNING:2019-12-16 04h17.31 UTC:1275: MHD: Failed to send data in request for `/static/js/2.33b2c378.chunk.js'.
gsad main:WARNING:2019-12-16 04h17.33 UTC:1275: MHD: Error: received handshake message out of context
gsad main:WARNING:2019-12-16 04h17.43 UTC:1275: MHD: Error: received handshake message out of context
gsad main:WARNING:2019-12-16 04h17.43 UTC:1275: MHD: Failed to send data in request for `/static/js/2.33b2c378.chunk.js'.
gsad main:WARNING:2019-12-16 04h17.43 UTC:1275: MHD: Failed to send data in request for `/static/js/main.85fd8104.chunk.js'.

The Python debug log is empty. However, there is clearly output as such:

78bc45d9-b5d6-4088-aafe-770689ce4a9d
<Element create_task_response at 0x7ff45d333888>
<class 'lxml.etree._Element'>

Dev docs for gvm-tools: https://readthedocs.org/projects/gvm-tools/downloads/pdf/latest/
This is a near word-for-word transcription of page 18.

Dev docs for create_task function: https://python-gvm.readthedocs.io/en/latest/api/gmpv9.html
CTRL+F for “create_task”.

The scanner id is valid. The config id is valid. The target id is valid. Everything has been built according to the dev docs. What is going on?

I thought I should add that I have been able to successfully connect to Openvas and create targets using Python with no issues. This error only comes up specifically when trying to create tasks.

Did you check the response status and message from gmp.create_task?

If you use the EtreeCheckCommandTransform you will get an error message from the response too.

I did not.

I just tried to use the EtreeCheckCommandTransform and received the following:

('Error in response. Bogus element: usage_type', <Element create_task_response at 0x7f5f8c5b7a88>)

You are using the wrong GMP version. Your gmvd doesn’t support GMPv9

1 Like

I see. However, how can this be when I compiled gvmd-8.0.1 from source? Is it the manner I’m calling it in Python? Why would this work for targets but not for tasks?

You gvmd version 8 speaks GMP version 8. GMP version 9 is gvmd 9. See About the Greenbone Source Edition (GSE) category for an overview of the different versions of our software.

The protocol gets adjusted slightly with every version. Therefore some parts of the API may still work with a never version but some e.g. get_tasks don’t.

2 Likes

I see, thank you. From this, I managed to resolve the issue by importing the correct version of GMP, “gvm.protocols.gmpv8” instead of “gvm.protocols.latest”. Everything works now. I appreciate your help.

2 Likes

A post was split to a new topic: Unable to reach the web interface