Python-GVM OSP Wrapper ImportError: No module named osp.connections

Hi,

i’ve a problem with an OSP-Wrapper Skript. I’ve tried that example here for OSP.: https://python-gvm.readthedocs.io/en/latest/
I have python3.4 and installed the gvm-tools 1.41 and python-gvm 1.0.0b2 modules. Unfortunately the modules aren’t been recognized. I’m getting this error:
ImportError: No module named osp.connections

Greetings
A.Zaki

Hi, you should use supported recent versions. gvm-tools 1.4.1 is heavily outdated and from a pre python-gvm area. No current script will work with this version. python-gvm 1.0.0b2 is beta version before the initial first release. So you shouldn’t use that version too.

2 Likes

Hi bricks, okay, thanks. I did the installation manually with pip.

python3 -m pip install --user python-gvm

pip install --user gvm-tools

Not sure why pip installs the old versions. Shouldn’t pip install directly the newer version ?

Greetings
A.Zaki

Yes it should but you are using an unsupported and outdated version of Python too. Python 3.4 is not developed by the Python community anymore. The minimum version should be 3.6. See https://endoflife.date/python

1 Like

ok, thanks. I’ve upgraded python and pip to 3.6 and 20.2.4. I was able to install the newer packets of python-gvm and gvm-tools (version 20.xx). Now i have the same problem: I’m trying to execute a sample script from https://python-gvm.readthedocs.io/en/latest/
It shows me an error at line:

from osp.connections import UnixSocketConnection
ModuleNotFoundError: No module named osp.connections

Thanks for helping.
Greetings
A.Zaki

Oh I am sorry. You have run into a copy and paste mistake in the docs. It must be gvm.connections and gvm.protocols.latest. I’ve fixed the docs which should be up-to-date in some minutes.

1 Like

ok, so osp is in the gvm class ? There is no osp class ?

Do i have to import the module libraries ? like import gvm or python-gvm ?

You tried to use some code from https://python-gvm.readthedocs.io/en/latest/usage.html#using-osp
This code used a wrong module from osp.connections import UnixSocketConnection instead of from gvm.connections import UnixSocketConnection. python-gvm provides the gvm python package.

1 Like

ok, but now it says: ModuleNotFoundError: The module named ‘gvm.connections’; ‘gvm is not a package’

Not sure what you are doing. This is a very basic Python thing that has nothing to do with python-gvm itself. Please try to test importing gvm by opening a Python3 shell and running import gvm. If that fails your setup is incorrect.

1 Like

yes, it fails, but when i type “import sys” there is no problem

ok, now it works. That was strange, i found out that python3.6 took another scriptfile for interpreting. Now it gets the right one. Also there was a gvm.pyc file which had to be deleted because of the ImportError: bad magic number in ‘gvm’: b’\x03\xf3\r\n’
Now i’m getting an socket error: gvm.errors.GvmError: Socket /tmp/ospd-wrapper.sock does not exist

I’ve also changed the socket-path: path=’/var/run/ospd-wrapper.sock’
But it’s the same error message which i get.
I use the UnixSocketConnection Method

I think there is more information missing like where does the socket connect to ( ipadresse, port) or is the UnixSocketConnection Method only for local systems ?
The script is not on the openvas sensor or the gsm. It has to open a connection to that systems. Thanks for helping.

If you are attempting to use /var/run/ospd-wrapper.sock, it must exist on your local system. If the error is telling you it doesn’t exist, then I can only assume that file does not exist at the path you specified.

If you want to connect to a remote host, you cannot use unix sockets.

2 Likes

Ok, thanks for the infos. I have another problem: I have used the “check_gmp.py” skript on my monitoring system for the GSM-Master to recall the scan-infos and tasks from the hosts. Now after the Upgrade to Version 20.0.0.8 it doesn’t work anymore. I assume that’s because the GSM-Master now uses the OSP-Protocol.
Is there any alternative to get this working again ?
Thanks for helping
Greetings
A.Zaki

New / unrelated question = new topic pls (should be a golden rule for every online community / forums, not only this one).

You could create a new topic in https://community.greenbone.net/c/gmp/11 (check_gmp.py is using GMP as the name is saying, not OSP).

If doing so make sure to provide more info on “it doesn’t work anymore” as this is clearly lacking details.

1 Like