Skip to content

Commit

Permalink
Optimize target scope page
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosnt committed Jan 4, 2025
1 parent 73d15ea commit 10a4580
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 120 deletions.
10 changes: 6 additions & 4 deletions src/frontend/components/target/port/authentication/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
(n) => !n || validate.name.test(n) || 'Invalid name value',
]"
validate-on="input"
prepend-icon="mdi-shield-account"
prepend-inner-icon="mdi-shield-account"
:disabled="type === 'None'"
/>
</v-col>
Expand All @@ -45,16 +45,15 @@
(s) => validate.secret.test(s) || 'Invalid secret value',
]"
validate-on="input"
prepend-icon="mdi-shield-key"
prepend-inner-icon="mdi-shield-key"
:disabled="type === 'None'"
@update:model-value="disabled = false"
/>
</v-col>
</v-row>

<UtilsSubmit
class="mt-4"
:disabled="disabled || type === 'None'"
:disabled="disabled && type !== 'None'"
text="Save"
/>
</v-container>
Expand All @@ -80,6 +79,9 @@ const secret = ref(null);
const type = ref("None");
function submit(): void {
if (type.value === "None") {
emit("completed");
}
if (valid.value) {
emit("loading", true);
props.api
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/components/target/port/dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
targetPort !== null ? $emit('completed') : null;
"
>
<v-stepper v-model="step" hide-actions>
<v-stepper v-model="step" hide-actions flat>
<v-stepper-header>
<v-stepper-item
title="Target Port"
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/components/target/port/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const path = ref(null);
function submit(): void {
if (valid.value) {
if (path.value && !path.value.startsWith("/")) {
path.value = "/".concat(path.value);
}
emit("loading", true);
props.api
.create({
Expand Down
201 changes: 86 additions & 115 deletions src/frontend/pages/projects/[project_id]/targets/[target_id]/scope.vue
Original file line number Diff line number Diff line change
@@ -1,121 +1,92 @@
<template>
<MenuProject>
<TargetTabs>
<v-container fluid>
<v-row justify="center" dense>
<v-col cols="10">
<Dataset
ref="dataset"
:api="api"
:default-parameters="{ ordering: 'port' }"
:add="TargetPortDialog"
icon="mdi-antenna"
empty-head="No Scopes"
empty-text="Define the set of ports and paths in scope and how to perform the authentication. Otherwise, the whole target will be scanned without authentication"
@load-data="(data) => (ports = data)"
>
<template #data>
<v-row justify="center" dense>
<v-col cols="10">
<v-table density="compact">
<thead>
<tr>
<th class="text-center font-weight-bold">Port</th>
<th class="text-center font-weight-bold">Path</th>
<th class="text-center font-weight-bold">
Authentication
</th>
<th class="text-center font-weight-bold">
Auth Name
</th>
<th class="text-center font-weight-bold">
Auth Secret
</th>
<th />
</tr>
</thead>
<tbody>
<tr v-for="port in ports" :key="port.id">
<td class="text-center">
<v-icon
class="mr-3"
:icon="portUtils.getIcon(port.port)"
/>{{ port.port }}
</td>
<td class="text-center">{{ port.path }}</td>
<td class="text-center">
{{
port.authentication
? port.authentication.type
: "None"
}}
</td>
<td class="text-center">
{{
port.authentication
? port.authentication.name
: ""
}}
</td>
<td class="text-center">
{{
port.authentication
? port.authentication.secret
: ""
}}
</td>
<td>
<!-- mdi-key-plus -->
<v-dialog v-if="!port.authentication" width="auto">
<template #activator="{ props: activatorProps }">
<BaseButton
icon="mdi-key-plus"
size="large"
color="green"
v-bind="activatorProps"
/>
</template>
<template #default="{ isActive }">
<TargetPortAuthenticationDialog
:api="authApi"
:target-port="port.id"
@close-dialog="isActive.value = false"
@completed="
isActive.value = false;
dataset.loadData(false);
"
/>
</template>
</v-dialog>
<UtilsDeleteButton
v-if="port.authentication"
:id="port.authentication.id"
:api="authApi"
:text="`Authentication '${port.authentication.name ? port.authentication.name : port.authentication.type}' will be removed`"
icon="mdi-key-remove"
action="Delete Authentication"
@completed="dataset.loadData(false)"
/>
<UtilsDeleteButton
:id="port.id"
:api="api"
:text="`Target port '${port.port}' will be removed`"
:variant="undefined"
icon="mdi-minus-network"
action="Delete Port"
@completed="dataset.loadData(false)"
/>
</td>
</tr>
</tbody>
</v-table>
</v-col>
</v-row>
</template>
</Dataset>
</v-col>
</v-row>
</v-container>
<Dataset
ref="dataset"
:api="api"
:default-parameters="{ ordering: 'port' }"
:add="TargetPortDialog"
icon="mdi-antenna"
empty-head="No Scope Defined"
empty-text="Define the ports and paths to be scanned and how to authenticate. Otherwise, the whole target address will be scanned"
@load-data="(data) => (ports = data)"
>
<template #data>
<v-table>
<thead>
<tr>
<th class="text-center font-weight-bold">Port</th>
<th class="text-center font-weight-bold">Path</th>
<th class="text-center font-weight-bold">Authentication</th>
<th class="text-center font-weight-bold">Auth Name</th>
<th class="text-center font-weight-bold">Auth Secret</th>
<th />
</tr>
</thead>
<tbody>
<tr v-for="port in ports" :key="port.id">
<td class="text-center">
<v-icon class="mr-3" :icon="portUtils.getIcon(port.port)" />{{
port.port
}}
</td>
<td class="text-center">{{ port.path }}</td>
<td class="text-center">
{{ port.authentication ? port.authentication.type : "None" }}
</td>
<td class="text-center">
{{ port.authentication ? port.authentication.name : "" }}
</td>
<td class="text-center">
{{ port.authentication ? port.authentication.secret : "" }}
</td>
<td>
<v-dialog v-if="!port.authentication" width="auto">
<template #activator="{ props: activatorProps }">
<BaseButton
icon="mdi-key-plus"
size="large"
color="green"
v-bind="activatorProps"
tooltip="Add Authentication"
/>
</template>
<template #default="{ isActive }">
<TargetPortAuthenticationDialog
:api="authApi"
:target-port="port.id"
@close-dialog="isActive.value = false"
@completed="
isActive.value = false;
dataset.loadData(false);
"
/>
</template>
</v-dialog>
<UtilsDeleteButton
v-if="port.authentication"
:id="port.authentication.id"
:api="authApi"
:text="`Authentication '${port.authentication.name ? port.authentication.name : port.authentication.type}' will be removed`"
icon="mdi-key-remove"
action="Delete Authentication"
@completed="dataset.loadData(false)"
/>
<UtilsDeleteButton
:id="port.id"
:api="api"
:text="`Target port '${port.port}' will be removed`"
:variant="undefined"
icon="mdi-minus-network"
action="Delete Port"
@completed="dataset.loadData(false)"
/>
</td>
</tr>
</tbody>
</v-table>
</template>
</Dataset>
</TargetTabs>
</MenuProject>
</template>
Expand Down

0 comments on commit 10a4580

Please sign in to comment.