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?
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):
Input file needs to be line separated ips, not comma separated as the inline comments suggest.
Line 73
keywords = {āhostsā: hosts_string}
change to
keywords = {āhostsā: [hosts_string]}
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.