Skip to content

Commit

Permalink
fix: handle missing <tasks> in target
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed May 20, 2024
1 parent 0aca294 commit 1873dc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/gvm_sync_targets/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def gvm_sync_targets(
if resp.targets:
target = resp.targets[0]
click.echo(target)
if target.tasks:
target.tasks.tasks
else:
pass
else:
gmp.create_target("All Hosts", asset_hosts_filter="")

Expand Down
4 changes: 2 additions & 2 deletions src/gvm_sync_targets/models/targets_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Task(Resource, tag="task"):


class Tasks(Resource, tag="tasks"):
tasks: list[Task] = element()
tasks: list[Task] = element(default_factory=list)


class Target(Resource, tag="target"):
Expand All @@ -74,7 +74,7 @@ class Target(Resource, tag="target"):
reverse_lookup_unify: IntBoolean = element()
alive_tests: str = element()
allow_simultaneous_ips: IntBoolean = element()
tasks: Tasks = element()
tasks: Tasks | None = None


class GetTargetsResponse(Response, tag="get_targets_response"):
Expand Down

0 comments on commit 1873dc2

Please sign in to comment.