Gvm-tools update-task-target

Hello,

re:gvm-tools v21.6.1 / GOS 21.04.8

We are trying to update the targets associated with a particular task using the gvm-tool script update-task-target.gmp.py as shown at bottom of post. We are able to successfully create new targets and task using other gvm-tool scripts (so our ssh connection and user privs are ok).

ā€˜hosts_file.csvā€™ has a single line with ip address.
$task_id is from existing task we are trying to update

Script output is ā€œResponse Error 400. Error in host specificationā€

Output is being generated in the ā€œcopy_send_targetā€ function,
at the line: new_target_id = gmp.create_target(**keywords).xpath(ā€™@idā€™)[0]

Weā€™ve run into this type error before, but it was associated with CIDR notation. Here the csv file has a single ip. The associated script, update-task-target.gmp.py is fresh from Github, no changes. Where would be good choice to look for additional clues for troubleshooting?

/usr/local/bin/gvm-script --gmp-username $gmp_username --gmp-password $gmp_password ssh --hostname $gmp-server ./gvm-tools/scripts/update-task-target.gmp.py ./hosts_file.csv $task_id

Hi @devnull :slightly_smiling_face:

Going by what the error message is, this thread may have some help/things to try and please let us know. Thanks!

1 Like

Hello DeeAnn,

re: https://github.com/greenbone/gvm-tools/blob/master/scripts/update-task-target.gmp.py

Thank you for the article link. The input file we are using only has 1 ip in it for testing. We have tried using the ip by itself and the ip/32, but get the same error message.

Our confirmed solution(s):

  1. Input file needs to be line separated ips, not comma separated as the inline comments suggest.

  2. Line 73
    keywords = {ā€˜hostsā€™: hosts_string}
    change to
    keywords = {ā€˜hostsā€™: [hosts_string]}

1 Like

Thank you @devnull, Iā€™ll pass your findings on to the developers. :slightly_smiling_face:

1 Like

I will take a look at this.

2 Likes

I have refactored the script. You may checkout the latest release of gvm-tools.
You now need to use the script as follows:
$ gvm-script --gmp-username name --gmp-password pass ssh --hostname <gsm> scripts/update-task-target.gmp.py +hf hosts_file.csv +t 303fa0a6-aa9b-43c4-bac0-66ae0b2d1698

Let me know if anything doesnā€™t work as expected.

2 Likes