Skip to content

Commit

Permalink
feat: update target
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed May 20, 2024
1 parent ad81566 commit 18ba5ba
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/gvm_sync_targets/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from gvm_sync_targets import __version__
from gvm_sync_targets.models import GetTargetsResponse, ModelTransform
from gvm_sync_targets.models.targets_response import CreateTargetResponse
from gvm_sync_targets.util import get_all_hosts, read_lines


Expand Down Expand Up @@ -75,12 +76,22 @@ def gvm_sync_targets(
)

if resp.targets:
new_target: CreateTargetResponse = gmp.create_target(
"All Hosts - temp", asset_hosts_filter=""
)

target = resp.targets[0]
click.echo(target)
if target.tasks:
target.tasks.tasks
task_ids = [task.uuid for task in target.tasks.tasks]
else:
pass
task_ids = []

for task_id in task_ids:
gmp.modify_task(task_id, target_id=new_target.uuid)

gmp.delete_target(target.uuid)
gmp.modify_target(new_target.uuid, name="All Hosts")
else:
gmp.create_target("All Hosts", asset_hosts_filter="")

Expand Down

0 comments on commit 18ba5ba

Please sign in to comment.