Skip to content

Commit b973c30

Browse files
committed
style: clean up issues
1 parent 18ba5ba commit b973c30

File tree

3 files changed

+87
-29
lines changed

3 files changed

+87
-29
lines changed

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,11 @@ extend-safe-fixes = [
113113
"D200",
114114
]
115115
ignore = [
116-
"TRY003", # TODO(aspen): Switch to custom exceptions
117116
"ANN101", # Due to be deprecated in ruff
118117
"ANN102", # Due to be deprecated in ruff
119118
"COM812", # Conflicts with formatter
120119
"ISC001", # Conflicts with formatter
121120
"EXE002", # pre-commit does it better, works with SMB shares
122-
"FA100",
123121
"D",
124122
]
125123
select = ["ALL"]

src/gvm_sync_targets/cli/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
# SPDX-License-Identifier: MIT
44

55
import logging
6-
from typing import TextIO
6+
from typing import TYPE_CHECKING, TextIO
77

88
import click
99
from gvm.connections import DebugConnection, UnixSocketConnection
1010
from gvm.protocols.gmp import Gmp
1111

1212
from gvm_sync_targets import __version__
1313
from gvm_sync_targets.models import GetTargetsResponse, ModelTransform
14-
from gvm_sync_targets.models.targets_response import CreateTargetResponse
1514
from gvm_sync_targets.util import get_all_hosts, read_lines
1615

16+
if TYPE_CHECKING:
17+
from gvm_sync_targets.models.targets_response import CreateTargetResponse
18+
1719

1820
@click.group(
1921
context_settings={
@@ -82,10 +84,11 @@ def gvm_sync_targets(
8284

8385
target = resp.targets[0]
8486
click.echo(target)
85-
if target.tasks:
86-
task_ids = [task.uuid for task in target.tasks.tasks]
87-
else:
88-
task_ids = []
87+
task_ids = (
88+
[task.uuid for task in target.tasks.tasks]
89+
if target.tasks
90+
else []
91+
)
8992

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

tests/gvm_sync_targets/models/targets_response_test.py

Lines changed: 78 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,63 @@
8585
<name></name>
8686
<trash>0</trash>
8787
</smb_credential>
88-
<esxi_credential id=""><name></name><trash>0</trash></esxi_credential>
89-
<snmp_credential id=""><name></name><trash>0</trash></snmp_credential>
90-
<ssh_elevate_credential id=""><name></name><trash>0</trash></ssh_elevate_credential>
88+
<esxi_credential id="">
89+
<name></name>
90+
<trash>0</trash>
91+
</esxi_credential>
92+
<snmp_credential id="">
93+
<name></name>
94+
<trash>0</trash>
95+
</snmp_credential>
96+
<ssh_elevate_credential id="">
97+
<name></name>
98+
<trash>0</trash>
99+
</ssh_elevate_credential>
91100
<reverse_lookup_only>0</reverse_lookup_only>
92101
<reverse_lookup_unify>0</reverse_lookup_unify>
93-
<alive_tests>Scan Config Default</alive_tests><allow_simultaneous_ips>1</allow_simultaneous_ips>
102+
<alive_tests>Scan Config Default</alive_tests>
103+
<allow_simultaneous_ips>1</allow_simultaneous_ips>
94104
</target>
95105
<target id="1a11fc20-b767-4407-82ee-e87fbddbc74a">
96106
<owner><name>admin</name></owner><name>Unnamed</name>
97107
<comment></comment><creation_time>2024-05-15T20:41:23Z</creation_time>
98108
<modification_time>2024-05-15T20:41:23Z</modification_time>
99109
<writable>1</writable><in_use>1</in_use>
100-
<permissions><permission><name>Everything</name></permission></permissions>
110+
<permissions>
111+
<permission><name>Everything</name></permission>
112+
</permissions>
101113
<hosts>1.2.3.4, 1::1</hosts>
102-
<exclude_hosts></exclude_hosts><max_hosts>41</max_hosts>
103-
<port_list id="33d0cd82-57c6-11e1-8ed1-406186ea4fc5"><name>All IANA assigned TCP</name><trash>0</trash></port_list>
104-
<ssh_credential id="416d4541-8cb4-4745-ba27-7d509cec9455"><name>SSH auth</name><port>22</port><trash>0</trash></ssh_credential>
105-
<smb_credential id=""><name></name><trash>0</trash></smb_credential><esxi_credential id=""><name></name><trash>0</trash></esxi_credential>
106-
<snmp_credential id=""><name></name><trash>0</trash></snmp_credential><ssh_elevate_credential id=""><name></name><trash>0</trash></ssh_elevate_credential>
107-
<reverse_lookup_only>0</reverse_lookup_only><reverse_lookup_unify>0</reverse_lookup_unify>
108-
<alive_tests>Scan Config Default</alive_tests><allow_simultaneous_ips>1</allow_simultaneous_ips>
114+
<exclude_hosts></exclude_hosts>
115+
<max_hosts>41</max_hosts>
116+
<port_list id="33d0cd82-57c6-11e1-8ed1-406186ea4fc5">
117+
<name>All IANA assigned TCP</name>
118+
<trash>0</trash>
119+
</port_list>
120+
<ssh_credential id="416d4541-8cb4-4745-ba27-7d509cec9455">
121+
<name>SSH auth</name>
122+
<port>22</port>
123+
<trash>0</trash>
124+
</ssh_credential>
125+
<smb_credential id="">
126+
<name></name>
127+
<trash>0</trash>
128+
</smb_credential>
129+
<esxi_credential id="">
130+
<name></name>
131+
<trash>0</trash>
132+
</esxi_credential>
133+
<snmp_credential id="">
134+
<name></name>
135+
<trash>0</trash>
136+
</snmp_credential>
137+
<ssh_elevate_credential id="">
138+
<name></name>
139+
<trash>0</trash>
140+
</ssh_elevate_credential>
141+
<reverse_lookup_only>0</reverse_lookup_only>
142+
<reverse_lookup_unify>0</reverse_lookup_unify>
143+
<alive_tests>Scan Config Default</alive_tests>
144+
<allow_simultaneous_ips>1</allow_simultaneous_ips>
109145
</target>
110146
<filters id="">
111147
<term>first=1 rows=10 sort=name</term>
@@ -227,25 +263,46 @@
227263
</smb_credential>
228264
<esxi_credential id=""><name></name><trash>0</trash></esxi_credential>
229265
<snmp_credential id=""><name></name><trash>0</trash></snmp_credential>
230-
<ssh_elevate_credential id=""><name></name><trash>0</trash></ssh_elevate_credential>
266+
<ssh_elevate_credential id="">
267+
<name></name><trash>0</trash>
268+
</ssh_elevate_credential>
231269
<reverse_lookup_only>0</reverse_lookup_only>
232270
<reverse_lookup_unify>0</reverse_lookup_unify>
233-
<alive_tests>Scan Config Default</alive_tests><allow_simultaneous_ips>1</allow_simultaneous_ips>
271+
<alive_tests>Scan Config Default</alive_tests>
272+
<allow_simultaneous_ips>1</allow_simultaneous_ips>
234273
</target>
235274
<target id="1a11fc20-b767-4407-82ee-e87fbddbc74a">
236275
<owner><name>admin</name></owner><name>Unnamed</name>
237276
<comment></comment><creation_time>2024-05-15T20:41:23Z</creation_time>
238277
<modification_time>2024-05-15T20:41:23Z</modification_time>
239278
<writable>1</writable><in_use>1</in_use>
240-
<permissions><permission><name>Everything</name></permission></permissions>
279+
<permissions>
280+
<permission><name>Everything</name></permission>
281+
</permissions>
241282
<hosts>1.2.3.4, 1::1</hosts>
242283
<exclude_hosts></exclude_hosts><max_hosts>41</max_hosts>
243-
<port_list id="33d0cd82-57c6-11e1-8ed1-406186ea4fc5"><name>All IANA assigned TCP</name><trash>0</trash></port_list>
244-
<ssh_credential id="416d4541-8cb4-4745-ba27-7d509cec9455"><name>SSH auth</name><port>22</port><trash>0</trash></ssh_credential>
245-
<smb_credential id=""><name></name><trash>0</trash></smb_credential><esxi_credential id=""><name></name><trash>0</trash></esxi_credential>
246-
<snmp_credential id=""><name></name><trash>0</trash></snmp_credential><ssh_elevate_credential id=""><name></name><trash>0</trash></ssh_elevate_credential>
247-
<reverse_lookup_only>0</reverse_lookup_only><reverse_lookup_unify>0</reverse_lookup_unify>
248-
<alive_tests>Scan Config Default</alive_tests><allow_simultaneous_ips>1</allow_simultaneous_ips>
284+
<port_list id="33d0cd82-57c6-11e1-8ed1-406186ea4fc5">
285+
<name>All IANA assigned TCP</name><trash>0</trash>
286+
</port_list>
287+
<ssh_credential id="416d4541-8cb4-4745-ba27-7d509cec9455">
288+
<name>SSH auth</name><port>22</port><trash>0</trash>
289+
</ssh_credential>
290+
<smb_credential id="">
291+
<name></name><trash>0</trash>
292+
</smb_credential>
293+
<esxi_credential id="">
294+
<name></name><trash>0</trash>
295+
</esxi_credential>
296+
<snmp_credential id="">
297+
<name></name><trash>0</trash>
298+
</snmp_credential>
299+
<ssh_elevate_credential id="">
300+
<name></name><trash>0</trash>
301+
</ssh_elevate_credential>
302+
<reverse_lookup_only>0</reverse_lookup_only>
303+
<reverse_lookup_unify>0</reverse_lookup_unify>
304+
<alive_tests>Scan Config Default</alive_tests>
305+
<allow_simultaneous_ips>1</allow_simultaneous_ips>
249306
</target>
250307
<filters id="">
251308
<term>first=1 rows=10 sort=name</term>

0 commit comments

Comments
 (0)