Gmp object has no attribute create_asset


#1
Traceback

Traceback (most recent call last):
File “/home/xxx/.local/bin/gvm-script”, line 11, in
sys.exit(main())
File “/home/xxx/.local/lib/python3.6/site-packages/gvmtools/script.py”, line 108, in main
run_script(args.scriptname, global_vars)
File “/home/xxx/.local/lib/python3.6/site-packages/gvmtools/helper.py”, line 86, in run_script
exec(file, global_vars) # pylint: disable=exec-used
File “”, line 91, in
AttributeError: ‘Gmp’ object has no attribute ‘create_asset’

Same issue with removed transform=transform

Code

15: path = ‘/var/run/openvasmd.sock’
16: connection = UnixSocketConnection(path=path)
17: transform = EtreeTransform()
18: gmp = Gmp(connection, transform=transform)

82: with gmp:
84: gmp.authenticate(‘xxx’, ‘xxx’)
91: req = gmp.create_asset()

Got same with res = gmp.create_asset(asset_type='host', name=row_ip, comment=row_fqdn)

Packages

Newest from master branch. GMP v7.0

Any thoughts?


Gmp get credentials
#2

Same thing happens in gvm-pyshell fyi:

$ gvm-pyshell --config ~/.config/gvm-tools.conf socket --socketpath /var/run/openvasmd.sock
GVM Interactive Console 2.0.0b1 API 1.0.0b2.dev1. Type "help" to get information about functionality.
>>> print(gmp.get_version().xpath('version/text()')[0])
7.0
>>> gmp.create_asset()
Traceback (most recent call last):
  File "/usr/lib/python3.6/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
AttributeError: 'Gmp' object has no attribute 'create_asset'
>>>

#3

EDIT:
I think code of my script is screwing something up. I reinstalled gvm-tools and python-gvm and gmp.create_asset() worked fine in gvm-pyshell but stopped working after executing the script. Gonna debu some

EDIT2:
That was false. I think I managed to recreate my issue.
First I install latest release of python-gvm by pip3 install --force-reinstall python-gvm , by now in gvm-pyshell gmp.create_asset() works and gmp.get_credentials() doesn’t (because it doesnt have fix from master).
Then I install newest version by cloning python-gvm repo, go inside repo folder and usine pip3 install ., now in gvm-pyshell I can use gmp.get_credentials() because it has fix, but can’t use gmp.create_asset() (look traceback from top)


#4

I managed to temporarily fix the issue by downloading latest release from repo (not from master branch) and manually applying commit to fix get_credentials() by altering this one line. Question is why it this main issue happened and how to permanently fix it…


#5

Hi,

I’ve you have issues with the API please double check the documentation at https://python-gvm.readthedocs.io/ especially the docs for the Gmp object

https://python-gvm.readthedocs.io/en/latest/api/protocols.html

From the docs you can see, that there is no create_asset method on the Gmp object anymore. To create a host asset please use create_host instead.

The python-gvm API does NOT reflect the GMP protocol 1:1. It circumvents some rough edges of the protocol and makes it more obvious which parameters are expected.