fix : securite regex et message erreur et endpoint

This commit is contained in:
2026-03-12 09:20:07 +01:00
parent 126d6b505a
commit 9393abc8df
10 changed files with 2552 additions and 24 deletions

View File

@@ -79,6 +79,7 @@
<script setup lang="ts">
import { computed, onMounted, ref } from "vue"
import { Icon as IconifyIcon } from "@iconify/vue"
import { useApiAuthHeader } from "~/composables/useApiAuth"
type BackupScript = {
key: string
@@ -118,6 +119,7 @@ const scripts = ref<BackupScript[]>([])
const output = ref<string>("")
const message = ref<string>("")
const isError = ref(false)
const apiAuthHeader = useApiAuthHeader()
const statusClass = computed(() => (isError.value ? "status-error" : "status-success"))
@@ -134,12 +136,14 @@ const loadScripts = async () => {
downloadFolders: []
})
try {
const data = await $fetch<BackupScriptListResponse>("/api/backup-script")
const data = await $fetch<BackupScriptListResponse>("/api/backup-script", {
headers: apiAuthHeader
})
scripts.value = data.scripts
} catch (error) {
} catch {
scripts.value = []
isError.value = true
message.value = `Erreur chargement scripts: ${error instanceof Error ? error.message : String(error)}`
message.value = "Erreur lors de l'opération"
emit("result", {
key: null,
label: "",
@@ -162,7 +166,8 @@ const runScript = async (key: string) => {
try {
const data = await $fetch<BackupScriptRunResponse>("/api/backup-script", {
method: "POST",
body: { key }
body: { key },
headers: apiAuthHeader
})
message.value = `${data.label} execute avec succes`
output.value = data.output || "Aucune sortie retournee."
@@ -173,8 +178,20 @@ const runScript = async (key: string) => {
isError: false,
downloadFolders: data.downloadFolders || []
})
} catch (error: any) {
} catch (error: unknown) {
isError.value = true
const statusMessage =
typeof error === "object" &&
error !== null &&
"data" in error &&
typeof error.data === "object" &&
error.data !== null &&
"statusMessage" in error.data &&
typeof error.data.statusMessage === "string"
? error.data.statusMessage
: null
message.value = statusMessage || "Erreur lors de l'opération"
message.value = error?.data?.statusMessage || "Erreur execution script"
output.value = ""
emit("result", {

View File

@@ -4,8 +4,8 @@
<h2 class="card-title">Speedtest</h2>
<button
class="reload-btn"
@click="runTests"
:disabled="isTesting"
@click="runTests"
>
<IconifyIcon
icon="mdi:reload"

View File

@@ -20,8 +20,8 @@
</template>
<div
v-else
v-for="row in rows"
v-else
:key="`${row.label}-${row.url}`"
class="status-row"
:class="row.status === 200 ? 'row-ok' : 'row-error'"