greenbone / python-gvm

Greenbone Vulnerability Management Python Library
https://greenbone.github.io/python-gvm/
GNU General Public License v3.0
107 stars 60 forks source link

Bogus element: usage_type #182

Closed DenisNovac closed 4 years ago

DenisNovac commented 4 years ago

Hi everyone. I am having troubles with this call (all components such as config_id was received from api itself):

response = self._gmp.create_task(name=name, config_id=config_id, target_id=target_id,  scanner_id=scanner_id)

I am getting this error:

In openvasmd.log:

event task:MESSAGE:2019-12-02 09h33.39 UTC:1461: Status of task (a0ac8fa1-97d2-40ed-980e-7dcdf8bcabd3) has changed to New md omp: INFO:2019-12-02 09h33.39 UTC:1461: Failed to parse client XML: Error

And then my connection stops at the next step:

self._gmp.get_tasks()

gvm.errors.GvmError: Remote closed the connection

Expected behavior

Creation and reading of tasks works fine.

Current behavior

Getting 400 status code when trying to create task.

GVM versions

gsa: (gsad --version) Greenbone Security Assistant 7.0.3

gvm: (gvmd --version) gvmd: command not found

openvas-scanner: (openvassd --version) OpenVAS Scanner 5.1.3

Libs versions

python-gvm in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (1.1.0)
lxml in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (from python-gvm) (4.4.1)
paramiko in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (from python-gvm) (2.6.0)
defusedxml in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (from python-gvm) (0.6.0)
bcrypt>=3.1.3 in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (from paramiko->python-gvm) (3.1.7)
cryptography>=2.5 in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (from paramiko->python-gvm) (2.7)
pynacl>=1.0.1 in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (from paramiko->python-gvm) (1.3.0)
six>=1.4.1 in c:\users\dyablochkin\appdata\roaming\python\python37\site-packages (from bcrypt>=3.1.3->paramiko->python-gvm) (1.12.0)
cffi>=1.1 in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (from bcrypt>=3.1.3->paramiko->python-gvm) (1.12.3)
asn1crypto>=0.21.0 in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (from cryptography>=2.5->paramiko->python-gvm) (1.0.1)
pycparser in c:\users\dyablochkin\appdata\local\programs\python\python37\lib\site-packages (from cffi>=1.1->bcrypt>=3.1.3->paramiko->python-gvm) (2.19)

Environment

Operating system: Python-gvm on Windows 10 (from pip) and OpenVAS in Docker container on Debian 9.

Installation method / source: https://hub.docker.com/r/mikesplain/openvas

Logfiles

openvasmd.log gsad.log

Python sources

test.py.txt

bjoernricks commented 4 years ago

Hi, you are using the wrong GMP protocol version for your GVM setup.

GVM/OpenVAS 9 is GMP v7.

DenisNovac commented 4 years ago

You mean, OpenVAS in container is outdated? Or is it about TLSConnection in GMP object in python? I got really confused with all this versions...

bjoernricks commented 4 years ago

python-gvm supports different versions of GVM/OpenVAS and the used GMP. See https://python-gvm.readthedocs.io/en/latest/api/protocols.html

You are trying to use python-gvm with GMPv9 against GVM/OpenVAS9 which speaks GMPv7.

DenisNovac commented 4 years ago

Oh, now i understand. Changed code:

#from gvm.protocols.latest import Gmp
from gvm.protocols.gmpv7 import Gmp

And everything works fine now. Thank you!