new: [app] Added reset all feature

This commit is contained in:
Sami Mokaddem 2024-07-15 16:19:50 +02:00
parent cc8f955b02
commit 5e2951efd0
7 changed files with 68 additions and 48 deletions

View file

@ -89,15 +89,20 @@ def restore_exercices_progress():
db.USER_ID_TO_AUTHKEY_MAPPING[int(user_id_str)] = authkey db.USER_ID_TO_AUTHKEY_MAPPING[int(user_id_str)] = authkey
except: except:
logger.info('Could not restore exercise progress') logger.info('Could not restore exercise progress')
db.EXERCISES_STATUS = {} resetAll()
db.SELECTED_EXERCISES = []
db.USER_ID_TO_EMAIL_MAPPING = {}
db.USER_ID_TO_AUTHKEY_MAPPING = {}
if len(db.EXERCISES_STATUS) == 0: if len(db.EXERCISES_STATUS) == 0:
init_exercises_tasks() init_exercises_tasks()
def resetAll():
db.EXERCISES_STATUS = {}
db.SELECTED_EXERCISES = []
db.USER_ID_TO_EMAIL_MAPPING = {}
db.USER_ID_TO_AUTHKEY_MAPPING = {}
init_exercises_tasks()
def is_validate_exercises(exercises: list) -> bool: def is_validate_exercises(exercises: list) -> bool:
exercises_uuid = set() exercises_uuid = set()
tasks_uuid = set() tasks_uuid = set()
@ -222,6 +227,11 @@ def resetAllExerciseProgress():
backup_exercises_progress() backup_exercises_progress()
def resetAllCommand():
resetAll()
backup_exercises_progress()
def get_completed_tasks_for_user(user_id: int): def get_completed_tasks_for_user(user_id: int):
completion = get_completion_for_users().get(user_id, {}) completion = get_completion_for_users().get(user_id, {})
completed_tasks = {} completed_tasks = {}

View file

@ -54,8 +54,7 @@
"followed_by": [ "followed_by": [
"3e61a340-0314-4622-91cc-042f3ff8543a" "3e61a340-0314-4622-91cc-042f3ff8543a"
], ],
"trigger": [ "trigger": []
]
}, },
"timing": { "timing": {
"triggered_at": null "triggered_at": null
@ -66,7 +65,7 @@
"inject_uuid": "3e61a340-0314-4622-91cc-042f3ff8543a", "inject_uuid": "3e61a340-0314-4622-91cc-042f3ff8543a",
"reporting_callback": [], "reporting_callback": [],
"requirements": { "requirements": {
"inject_uuid": "8f636640-e4f0-4ffb-abff-4e85597aa1bd" "inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
}, },
"sequence": { "sequence": {
"completion_trigger": [ "completion_trigger": [
@ -76,8 +75,7 @@
"followed_by": [ "followed_by": [
"8a2d58c8-2b3a-4ba2-bb77-15bcfa704828" "8a2d58c8-2b3a-4ba2-bb77-15bcfa704828"
], ],
"trigger": [ "trigger": []
]
}, },
"timing": { "timing": {
"triggered_at": null "triggered_at": null
@ -88,7 +86,7 @@
"inject_uuid": "8a2d58c8-2b3a-4ba2-bb77-15bcfa704828", "inject_uuid": "8a2d58c8-2b3a-4ba2-bb77-15bcfa704828",
"reporting_callback": [], "reporting_callback": [],
"requirements": { "requirements": {
"inject_uuid": "3e61a340-0314-4622-91cc-042f3ff8543a" "inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
}, },
"sequence": { "sequence": {
"completion_trigger": [ "completion_trigger": [
@ -98,8 +96,7 @@
"followed_by": [ "followed_by": [
"9df13cc8-b61b-4c9f-a1a8-66def8b64439" "9df13cc8-b61b-4c9f-a1a8-66def8b64439"
], ],
"trigger": [ "trigger": []
]
}, },
"timing": { "timing": {
"triggered_at": null "triggered_at": null
@ -110,7 +107,7 @@
"inject_uuid": "9df13cc8-b61b-4c9f-a1a8-66def8b64439", "inject_uuid": "9df13cc8-b61b-4c9f-a1a8-66def8b64439",
"reporting_callback": [], "reporting_callback": [],
"requirements": { "requirements": {
"inject_uuid": "8a2d58c8-2b3a-4ba2-bb77-15bcfa704828" "inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
}, },
"sequence": { "sequence": {
"completion_trigger": [ "completion_trigger": [
@ -120,8 +117,7 @@
"followed_by": [ "followed_by": [
"c5c03af1-7ef3-44e7-819a-6c4fd402148a" "c5c03af1-7ef3-44e7-819a-6c4fd402148a"
], ],
"trigger": [ "trigger": []
]
}, },
"timing": { "timing": {
"triggered_at": null "triggered_at": null
@ -132,7 +128,7 @@
"inject_uuid": "c5c03af1-7ef3-44e7-819a-6c4fd402148a", "inject_uuid": "c5c03af1-7ef3-44e7-819a-6c4fd402148a",
"reporting_callback": [], "reporting_callback": [],
"requirements": { "requirements": {
"inject_uuid": "9df13cc8-b61b-4c9f-a1a8-66def8b64439" "inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
}, },
"sequence": { "sequence": {
"completion_trigger": [ "completion_trigger": [
@ -142,8 +138,7 @@
"followed_by": [ "followed_by": [
"11f6f0c2-8813-42ee-a312-136649d3f077" "11f6f0c2-8813-42ee-a312-136649d3f077"
], ],
"trigger": [ "trigger": []
]
}, },
"timing": { "timing": {
"triggered_at": null "triggered_at": null
@ -154,7 +149,7 @@
"inject_uuid": "11f6f0c2-8813-42ee-a312-136649d3f077", "inject_uuid": "11f6f0c2-8813-42ee-a312-136649d3f077",
"reporting_callback": [], "reporting_callback": [],
"requirements": { "requirements": {
"inject_uuid": "c5c03af1-7ef3-44e7-819a-6c4fd402148a" "inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
}, },
"sequence": { "sequence": {
"completion_trigger": [ "completion_trigger": [
@ -164,8 +159,7 @@
"followed_by": [ "followed_by": [
"e3ef4e5f-454a-48c8-a5d7-b3d1d25ecc9f" "e3ef4e5f-454a-48c8-a5d7-b3d1d25ecc9f"
], ],
"trigger": [ "trigger": []
]
}, },
"timing": { "timing": {
"triggered_at": null "triggered_at": null
@ -176,23 +170,21 @@
"inject_uuid": "e3ef4e5f-454a-48c8-a5d7-b3d1d25ecc9f", "inject_uuid": "e3ef4e5f-454a-48c8-a5d7-b3d1d25ecc9f",
"reporting_callback": [], "reporting_callback": [],
"requirements": { "requirements": {
"inject_uuid": "11f6f0c2-8813-42ee-a312-136649d3f077" "inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
}, },
"sequence": { "sequence": {
"completion_trigger": [ "completion_trigger": [
"time_expiration", "time_expiration",
"completion" "completion"
], ],
"trigger": [ "trigger": []
]
}, },
"timing": { "timing": {
"triggered_at": null "triggered_at": null
} }
} }
], ],
"inject_payloads": [ "inject_payloads": [],
],
"injects": [ "injects": [
{ {
"action": "event-creation", "action": "event-creation",
@ -210,8 +202,7 @@
], ],
"result": "MISP Event created", "result": "MISP Event created",
"evaluation_strategy": "data_filtering", "evaluation_strategy": "data_filtering",
"evaluation_context": { "evaluation_context": {},
},
"score_range": [ "score_range": [
0, 0,
20 20
@ -248,8 +239,7 @@
], ],
"result": "Infection Email added", "result": "Infection Email added",
"evaluation_strategy": "data_filtering", "evaluation_strategy": "data_filtering",
"evaluation_context": { "evaluation_context": {},
},
"score_range": [ "score_range": [
0, 0,
20 20
@ -285,8 +275,7 @@
], ],
"result": "Malicious payload added", "result": "Malicious payload added",
"evaluation_strategy": "data_filtering", "evaluation_strategy": "data_filtering",
"evaluation_context": { "evaluation_context": {},
},
"score_range": [ "score_range": [
0, 0,
20 20
@ -322,8 +311,7 @@
], ],
"result": "C2 IP added", "result": "C2 IP added",
"evaluation_strategy": "data_filtering", "evaluation_strategy": "data_filtering",
"evaluation_context": { "evaluation_context": {},
},
"score_range": [ "score_range": [
0, 0,
20 20
@ -352,15 +340,14 @@
"extract_type": "all", "extract_type": "all",
"comparison": "contains-regex", "comparison": "contains-regex",
"values": [ "values": [
"HKCU.+SOFTWARE.+CryptoLocker.*" "HKCU.+SOFTWARE.+CryptoLocker.*"
] ]
} }
} }
], ],
"result": "Registry key added", "result": "Registry key added",
"evaluation_strategy": "data_filtering", "evaluation_strategy": "data_filtering",
"evaluation_context": { "evaluation_context": {},
},
"score_range": [ "score_range": [
0, 0,
20 20
@ -389,15 +376,14 @@
"extract_type": "all", "extract_type": "all",
"comparison": "contains-regex", "comparison": "contains-regex",
"values": [ "values": [
"-----BEGIN PUBLIC KEY-----.*" "-----BEGIN PUBLIC KEY-----.*"
] ]
} }
} }
], ],
"result": "Public key added", "result": "Public key added",
"evaluation_strategy": "data_filtering", "evaluation_strategy": "data_filtering",
"evaluation_context": { "evaluation_context": {},
},
"score_range": [ "score_range": [
0, 0,
20 20
@ -433,8 +419,7 @@
], ],
"result": "Context added", "result": "Context added",
"evaluation_strategy": "data_filtering", "evaluation_strategy": "data_filtering",
"evaluation_context": { "evaluation_context": {},
},
"score_range": [ "score_range": [
0, 0,
20 20
@ -469,8 +454,7 @@
], ],
"result": "Event published", "result": "Event published",
"evaluation_strategy": "data_filtering", "evaluation_strategy": "data_filtering",
"evaluation_context": { "evaluation_context": {},
},
"score_range": [ "score_range": [
0, 0,
20 20
@ -482,4 +466,4 @@
"uuid": "e3ef4e5f-454a-48c8-a5d7-b3d1d25ecc9f" "uuid": "e3ef4e5f-454a-48c8-a5d7-b3d1d25ecc9f"
} }
] ]
} }

View file

@ -118,6 +118,10 @@ async def mark_task_incomplete(sid, payload):
async def reset_all_exercise_progress(sid): async def reset_all_exercise_progress(sid):
return exercise_model.resetAllExerciseProgress() return exercise_model.resetAllExerciseProgress()
@sio.event
async def reset_all(sid):
return exercise_model.resetAllCommand()
@sio.event @sio.event
async def reset_notifications(sid): async def reset_notifications(sid):
return notification_model.reset_notifications() return notification_model.reset_notifications()

View file

@ -1,6 +1,6 @@
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
import { exercises, selected_exercises, diagnostic, fullReload, resetAllExerciseProgress, resetLiveLogs, changeExerciseSelection, debouncedGetDiangostic, remediateSetting } from "@/socket"; import { exercises, selected_exercises, diagnostic, fullReload, resetAllExerciseProgress, resetAll, resetLiveLogs, changeExerciseSelection, debouncedGetDiangostic, remediateSetting } from "@/socket";
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { faScrewdriverWrench, faTrash, faSuitcaseMedical, faGraduationCap, faBan, faRotate, faHammer, faCheck } from '@fortawesome/free-solid-svg-icons' import { faScrewdriverWrench, faTrash, faSuitcaseMedical, faGraduationCap, faBan, faRotate, faHammer, faCheck } from '@fortawesome/free-solid-svg-icons'
@ -65,6 +65,13 @@
<FontAwesomeIcon :icon="faTrash" size="lg" fixed-width></FontAwesomeIcon> <FontAwesomeIcon :icon="faTrash" size="lg" fixed-width></FontAwesomeIcon>
Reset All Exercises Reset All Exercises
</button> </button>
<button
@click="resetAll()"
class="h-10 min-h-10 px-2 py-1 font-semibold bg-red-600 text-slate-200 hover:bg-red-700 btn btn-sm gap-1"
>
<FontAwesomeIcon :icon="faTrash" size="lg" fixed-width></FontAwesomeIcon>
Reset All
</button>
<button <button
@click="resetLiveLogs()" @click="resetLiveLogs()"
class="h-10 min-h-10 px-2 py-1 font-semibold bg-amber-600 text-slate-200 hover:bg-amber-700 btn btn-sm gap-1" class="h-10 min-h-10 px-2 py-1 font-semibold bg-amber-600 text-slate-200 hover:bg-amber-700 btn btn-sm gap-1"

View file

@ -48,7 +48,7 @@
}, },
yaxis: { yaxis: {
min: 0, min: 0,
max: 30, max: 20,
labels: { labels: {
show: false, show: false,
} }

View file

@ -88,7 +88,12 @@
<div class="flex flex-col"> <div class="flex flex-col">
<span class="text-center font-normal text-sm dark:text-blue-200 text-slate-500 text-nowrap">Task {{ task_index + 1 }}</span> <span class="text-center font-normal text-sm dark:text-blue-200 text-slate-500 text-nowrap">Task {{ task_index + 1 }}</span>
<i class="text-center">{{ task.name }}</i> <i class="text-center">{{ task.name }}</i>
<div class="flex w-full h-1 bg-gray-200 rounded-full overflow-hidden dark:bg-neutral-600" role="progressbar" :aria-valuenow="taskCompletionPercentages[task.uuid]" :aria-valuemin="0" aria-valuemax="100"> <div
role="progressbar"
class="flex w-full h-1 bg-gray-200 rounded-full overflow-hidden dark:bg-neutral-600"
:aria-valuenow="taskCompletionPercentages[task.uuid]" :aria-valuemin="0" aria-valuemax="100"
:title="`${taskCompletionPercentages[task.uuid].toFixed(0)}%`"
>
<div <div
class="flex flex-col justify-center rounded-full overflow-hidden bg-blue-600 text-xs text-white text-center whitespace-nowrap transition duration-500 dark:bg-blue-500 transition-width transition-slowest ease" class="flex flex-col justify-center rounded-full overflow-hidden bg-blue-600 text-xs text-white text-center whitespace-nowrap transition duration-500 dark:bg-blue-500 transition-width transition-slowest ease"
:style="`width: ${taskCompletionPercentages[task.uuid]}%`" :style="`width: ${taskCompletionPercentages[task.uuid]}%`"

View file

@ -76,6 +76,10 @@ export function resetAllExerciseProgress() {
sendResetAllExerciseProgress() sendResetAllExerciseProgress()
} }
export function resetAll() {
sendResetAll()
}
export function resetLiveLogs() { export function resetLiveLogs() {
sendResetLiveLogs() sendResetLiveLogs()
} }
@ -166,6 +170,12 @@ function sendResetAllExerciseProgress() {
}) })
} }
function sendResetAll() {
socket.emit("reset_all", () => {
getProgress()
})
}
function sendResetLiveLogs() { function sendResetLiveLogs() {
socket.emit("reset_notifications", () => { socket.emit("reset_notifications", () => {
getNotifications() getNotifications()