Automate target and task create using openstack cli

Hi,

in the last weeks / months we were playing around with the new python-gvm library. This is simply awesome and we decided to share a little snippet with the community.

In case anybody else having an OpenStack cluster or OpenStack project and wants to scan the floating ips using gvm our script can be a good starting point to speed up the target and task generation process inside your running gvm installation.

The script can be found here: https://github.com/carlstegmann/snippets/blob/master/gvm_targets_and_tasks_from_openstack_cluster.py
Requirements for the script: https://github.com/carlstegmann/snippets/blob/master/gvm_targets_and_tasks_from_openstack_cluster_requirements.txt

Our test environment uses:

GVM versions

gsa: Greenbone Security Assistant 8.0.0~git
gvm: Greenbone Vulnerability Manager 8.0.0
openvas-scanner: OpenVAS Scanner 6.0.0
gvm-libs: gvm-libs-10.0.0

Environment

Operating system: Ubuntu 18.04
Kernel: 4.15.0-55-generic
Installation method / source: source

Kind regards,
Carl

3 Likes

Thanks for this feedback!

Just had a quick look at your cluster script and recognized you are already using the new typings. Therefore I would like to leave some hints here. You should not mix different versions of the gmp classes.

E.g. you are using

from gvm.protocols.gmpv7.types import AliveTest

and

from gvm.protocols.latest import Gmp

For this AliveTest type class it may work but can break in future. It wont work e.g. for FilterType already. So always ensure to import the types from the same module.

from gvm.protocols.gmpv7 import Gmp, AliveTests

I am going to update the gvm.protocols.latest module to export the suitable typings too. This is currently missing.

2 Likes