GVM user_tags missing in response XML

Hello,

I’m writing a script to manage dynamic inventory and I need to use tags so hosts can be added to appropriate targets. When I export hosts from the web UI and open the XML the user_tags field is correct:

<get_assets_response status="200" status_text="OK">
    <asset id="5d61622a-2bbb-47f3-ada6-3eef453f3e9b">
        <owner>
            <name>admin</name>
        </owner>
        <name>XXX.XXX.XXX.XXX</name>
        <comment>Project: XXX host: XXX</comment>
        <creation_time>2023-02-21T16:01:46Z</creation_time>
        <modification_time>2023-02-21T16:01:46Z</modification_time>
        <writable>1</writable>
        <in_use>0</in_use>
        <permissions>
            <permission>
                <name>Everything</name>
            </permission>
        </permissions>
        <user_tags>
            <count>1</count>
            <tag id="943381c0-f37d-4065-a542-a12996dab166">
                <name>host:gke</name>
                <value></value>
                <comment></comment>
            </tag>
        </user_tags>

However when I query for hosts by using response = gmp.get_hosts(filter_string=f'first={first_element_index} rows=1000') and look at the output XML I can see that the <tag> is missing, there is only count value:

<get_assets_response status="200" status_text="OK">
  <asset id="5d61622a-2bbb-47f3-ada6-3eef453f3e9b">
    <owner>
      <name>admin</name>
    </owner>
    <name>XXX.XXX.XXX.XXX</name>
    <comment>Project: XXX host: XXX</comment>
    <creation_time>2023-02-21T16:01:46Z</creation_time>
    <modification_time>2023-02-21T16:01:46Z</modification_time>
    <writable>1</writable>
    <in_use>0</in_use>
    <permissions>
      <permission>
        <name>Everything</name>
      </permission>
    </permissions>
    <user_tags>
      <count>1</count>
    </user_tags>

Is this some kind of a bug? Or am I missing an anrgument that needs to be passed to get_hosts()? The documentation mentions only filter_id and filter_string.

Hi,

the python API misses the possibility to query the asset details. I’ve created a PR to fix that https://github.com/greenbone/python-gvm/pull/981

4 Likes

Hi @bricks !
Thanks for creating the PR, will test it out as soon as it’s merged. :slight_smile:

2 Likes

I’ve create a new release today https://github.com/greenbone/python-gvm/releases/tag/v23.4.0

3 Likes