Skip to content

Commit d5326ab

Browse files
committed
update: target with directly input
1 parent efca7b3 commit d5326ab

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

src/commands/tasks/scanTask.ts

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,46 @@ export const scanCommand: callback = async (args: any) => {
1616
if (!target) {
1717
if (!selectTargets || selectTargets.length === 0) {
1818
vscode.window.showErrorMessage("No hosts found to scan.");
19-
return;
20-
}
21-
let selected: Host | undefined = undefined;
22-
if (selectTargets.length !== 1) {
23-
let list: string[] = [];
24-
selectTargets.forEach((host) => {
25-
list.push(`${host.hostname} (${host.ip})`);
19+
target = await vscode.window.showInputBox({
20+
placeHolder: "Enter a target (ip/domain/...etc) to scan",
2621
});
27-
target = await vscode.window.showQuickPick(list, {
28-
placeHolder: "Select a host to scan",
29-
});
30-
if (!target) {
22+
} else {
23+
let selected: Host | undefined = undefined;
24+
if (selectTargets.length !== 1) {
25+
let list: string[] = [];
26+
selectTargets.forEach((host) => {
27+
list.push(`${host.hostname} (${host.ip})`);
28+
});
29+
target = await vscode.window.showQuickPick(list, {
30+
placeHolder: "Select a host to scan",
31+
});
32+
if (!target) {
33+
vscode.window.showErrorMessage(
34+
"No target selected. Operation cancelled."
35+
);
36+
return;
37+
}
38+
selected = selectTargets.find(
39+
(host) => `${host.hostname} (${host.ip})` === target
40+
);
41+
} else {
42+
selected = selectTargets[0];
43+
}
44+
45+
if (!selected) {
3146
vscode.window.showErrorMessage(
32-
"No target selected. Operation cancelled."
47+
"Selected target not found in host list."
3348
);
3449
return;
3550
}
36-
selected = selectTargets.find(
37-
(host) => `${host.hostname} (${host.ip})` === target
51+
let options: string[] = Array.from(
52+
new Set([selected.hostname, selected.ip, ...selected.alias])
3853
);
39-
} else {
40-
selected = selectTargets[0];
41-
}
42-
43-
if (!selected) {
44-
vscode.window.showErrorMessage("Selected target not found in host list.");
45-
return;
46-
}
47-
let options: string[] = Array.from(new Set([selected.hostname, selected.ip, ...selected.alias]));
4854

49-
target = await vscode.window.showQuickPick(options, {
50-
placeHolder: "Select an option to scan",
51-
});
55+
target = await vscode.window.showQuickPick(options, {
56+
placeHolder: "Select an option to scan",
57+
});
58+
}
5259
}
5360
if (!target) {
5461
vscode.window.showErrorMessage("No target selected. Operation cancelled.");

0 commit comments

Comments
 (0)