new: [app] Added reset all feature
This commit is contained in:
parent
cc8f955b02
commit
5e2951efd0
7 changed files with 68 additions and 48 deletions
18
exercise.py
18
exercise.py
|
@ -89,15 +89,20 @@ def restore_exercices_progress():
|
|||
db.USER_ID_TO_AUTHKEY_MAPPING[int(user_id_str)] = authkey
|
||||
except:
|
||||
logger.info('Could not restore exercise progress')
|
||||
db.EXERCISES_STATUS = {}
|
||||
db.SELECTED_EXERCISES = []
|
||||
db.USER_ID_TO_EMAIL_MAPPING = {}
|
||||
db.USER_ID_TO_AUTHKEY_MAPPING = {}
|
||||
resetAll()
|
||||
|
||||
if len(db.EXERCISES_STATUS) == 0:
|
||||
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:
|
||||
exercises_uuid = set()
|
||||
tasks_uuid = set()
|
||||
|
@ -222,6 +227,11 @@ def resetAllExerciseProgress():
|
|||
backup_exercises_progress()
|
||||
|
||||
|
||||
def resetAllCommand():
|
||||
resetAll()
|
||||
backup_exercises_progress()
|
||||
|
||||
|
||||
def get_completed_tasks_for_user(user_id: int):
|
||||
completion = get_completion_for_users().get(user_id, {})
|
||||
completed_tasks = {}
|
||||
|
|
|
@ -54,8 +54,7 @@
|
|||
"followed_by": [
|
||||
"3e61a340-0314-4622-91cc-042f3ff8543a"
|
||||
],
|
||||
"trigger": [
|
||||
]
|
||||
"trigger": []
|
||||
},
|
||||
"timing": {
|
||||
"triggered_at": null
|
||||
|
@ -66,7 +65,7 @@
|
|||
"inject_uuid": "3e61a340-0314-4622-91cc-042f3ff8543a",
|
||||
"reporting_callback": [],
|
||||
"requirements": {
|
||||
"inject_uuid": "8f636640-e4f0-4ffb-abff-4e85597aa1bd"
|
||||
"inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
|
||||
},
|
||||
"sequence": {
|
||||
"completion_trigger": [
|
||||
|
@ -76,8 +75,7 @@
|
|||
"followed_by": [
|
||||
"8a2d58c8-2b3a-4ba2-bb77-15bcfa704828"
|
||||
],
|
||||
"trigger": [
|
||||
]
|
||||
"trigger": []
|
||||
},
|
||||
"timing": {
|
||||
"triggered_at": null
|
||||
|
@ -88,7 +86,7 @@
|
|||
"inject_uuid": "8a2d58c8-2b3a-4ba2-bb77-15bcfa704828",
|
||||
"reporting_callback": [],
|
||||
"requirements": {
|
||||
"inject_uuid": "3e61a340-0314-4622-91cc-042f3ff8543a"
|
||||
"inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
|
||||
},
|
||||
"sequence": {
|
||||
"completion_trigger": [
|
||||
|
@ -98,8 +96,7 @@
|
|||
"followed_by": [
|
||||
"9df13cc8-b61b-4c9f-a1a8-66def8b64439"
|
||||
],
|
||||
"trigger": [
|
||||
]
|
||||
"trigger": []
|
||||
},
|
||||
"timing": {
|
||||
"triggered_at": null
|
||||
|
@ -110,7 +107,7 @@
|
|||
"inject_uuid": "9df13cc8-b61b-4c9f-a1a8-66def8b64439",
|
||||
"reporting_callback": [],
|
||||
"requirements": {
|
||||
"inject_uuid": "8a2d58c8-2b3a-4ba2-bb77-15bcfa704828"
|
||||
"inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
|
||||
},
|
||||
"sequence": {
|
||||
"completion_trigger": [
|
||||
|
@ -120,8 +117,7 @@
|
|||
"followed_by": [
|
||||
"c5c03af1-7ef3-44e7-819a-6c4fd402148a"
|
||||
],
|
||||
"trigger": [
|
||||
]
|
||||
"trigger": []
|
||||
},
|
||||
"timing": {
|
||||
"triggered_at": null
|
||||
|
@ -132,7 +128,7 @@
|
|||
"inject_uuid": "c5c03af1-7ef3-44e7-819a-6c4fd402148a",
|
||||
"reporting_callback": [],
|
||||
"requirements": {
|
||||
"inject_uuid": "9df13cc8-b61b-4c9f-a1a8-66def8b64439"
|
||||
"inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
|
||||
},
|
||||
"sequence": {
|
||||
"completion_trigger": [
|
||||
|
@ -142,8 +138,7 @@
|
|||
"followed_by": [
|
||||
"11f6f0c2-8813-42ee-a312-136649d3f077"
|
||||
],
|
||||
"trigger": [
|
||||
]
|
||||
"trigger": []
|
||||
},
|
||||
"timing": {
|
||||
"triggered_at": null
|
||||
|
@ -154,7 +149,7 @@
|
|||
"inject_uuid": "11f6f0c2-8813-42ee-a312-136649d3f077",
|
||||
"reporting_callback": [],
|
||||
"requirements": {
|
||||
"inject_uuid": "c5c03af1-7ef3-44e7-819a-6c4fd402148a"
|
||||
"inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
|
||||
},
|
||||
"sequence": {
|
||||
"completion_trigger": [
|
||||
|
@ -164,8 +159,7 @@
|
|||
"followed_by": [
|
||||
"e3ef4e5f-454a-48c8-a5d7-b3d1d25ecc9f"
|
||||
],
|
||||
"trigger": [
|
||||
]
|
||||
"trigger": []
|
||||
},
|
||||
"timing": {
|
||||
"triggered_at": null
|
||||
|
@ -176,23 +170,21 @@
|
|||
"inject_uuid": "e3ef4e5f-454a-48c8-a5d7-b3d1d25ecc9f",
|
||||
"reporting_callback": [],
|
||||
"requirements": {
|
||||
"inject_uuid": "11f6f0c2-8813-42ee-a312-136649d3f077"
|
||||
"inject_uuid": "8e8dbda2-0f5e-4101-83ff-63c1ddda2cae"
|
||||
},
|
||||
"sequence": {
|
||||
"completion_trigger": [
|
||||
"time_expiration",
|
||||
"completion"
|
||||
],
|
||||
"trigger": [
|
||||
]
|
||||
"trigger": []
|
||||
},
|
||||
"timing": {
|
||||
"triggered_at": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"inject_payloads": [
|
||||
],
|
||||
"inject_payloads": [],
|
||||
"injects": [
|
||||
{
|
||||
"action": "event-creation",
|
||||
|
@ -210,8 +202,7 @@
|
|||
],
|
||||
"result": "MISP Event created",
|
||||
"evaluation_strategy": "data_filtering",
|
||||
"evaluation_context": {
|
||||
},
|
||||
"evaluation_context": {},
|
||||
"score_range": [
|
||||
0,
|
||||
20
|
||||
|
@ -248,8 +239,7 @@
|
|||
],
|
||||
"result": "Infection Email added",
|
||||
"evaluation_strategy": "data_filtering",
|
||||
"evaluation_context": {
|
||||
},
|
||||
"evaluation_context": {},
|
||||
"score_range": [
|
||||
0,
|
||||
20
|
||||
|
@ -285,8 +275,7 @@
|
|||
],
|
||||
"result": "Malicious payload added",
|
||||
"evaluation_strategy": "data_filtering",
|
||||
"evaluation_context": {
|
||||
},
|
||||
"evaluation_context": {},
|
||||
"score_range": [
|
||||
0,
|
||||
20
|
||||
|
@ -322,8 +311,7 @@
|
|||
],
|
||||
"result": "C2 IP added",
|
||||
"evaluation_strategy": "data_filtering",
|
||||
"evaluation_context": {
|
||||
},
|
||||
"evaluation_context": {},
|
||||
"score_range": [
|
||||
0,
|
||||
20
|
||||
|
@ -352,15 +340,14 @@
|
|||
"extract_type": "all",
|
||||
"comparison": "contains-regex",
|
||||
"values": [
|
||||
"HKCU.+SOFTWARE.+CryptoLocker.*"
|
||||
"HKCU.+SOFTWARE.+CryptoLocker.*"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"result": "Registry key added",
|
||||
"evaluation_strategy": "data_filtering",
|
||||
"evaluation_context": {
|
||||
},
|
||||
"evaluation_context": {},
|
||||
"score_range": [
|
||||
0,
|
||||
20
|
||||
|
@ -389,15 +376,14 @@
|
|||
"extract_type": "all",
|
||||
"comparison": "contains-regex",
|
||||
"values": [
|
||||
"-----BEGIN PUBLIC KEY-----.*"
|
||||
"-----BEGIN PUBLIC KEY-----.*"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"result": "Public key added",
|
||||
"evaluation_strategy": "data_filtering",
|
||||
"evaluation_context": {
|
||||
},
|
||||
"evaluation_context": {},
|
||||
"score_range": [
|
||||
0,
|
||||
20
|
||||
|
@ -433,8 +419,7 @@
|
|||
],
|
||||
"result": "Context added",
|
||||
"evaluation_strategy": "data_filtering",
|
||||
"evaluation_context": {
|
||||
},
|
||||
"evaluation_context": {},
|
||||
"score_range": [
|
||||
0,
|
||||
20
|
||||
|
@ -469,8 +454,7 @@
|
|||
],
|
||||
"result": "Event published",
|
||||
"evaluation_strategy": "data_filtering",
|
||||
"evaluation_context": {
|
||||
},
|
||||
"evaluation_context": {},
|
||||
"score_range": [
|
||||
0,
|
||||
20
|
||||
|
@ -482,4 +466,4 @@
|
|||
"uuid": "e3ef4e5f-454a-48c8-a5d7-b3d1d25ecc9f"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -118,6 +118,10 @@ async def mark_task_incomplete(sid, payload):
|
|||
async def reset_all_exercise_progress(sid):
|
||||
return exercise_model.resetAllExerciseProgress()
|
||||
|
||||
@sio.event
|
||||
async def reset_all(sid):
|
||||
return exercise_model.resetAllCommand()
|
||||
|
||||
@sio.event
|
||||
async def reset_notifications(sid):
|
||||
return notification_model.reset_notifications()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
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 { 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>
|
||||
Reset All Exercises
|
||||
</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
|
||||
@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"
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
},
|
||||
yaxis: {
|
||||
min: 0,
|
||||
max: 30,
|
||||
max: 20,
|
||||
labels: {
|
||||
show: false,
|
||||
}
|
||||
|
|
|
@ -88,7 +88,12 @@
|
|||
<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>
|
||||
<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
|
||||
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]}%`"
|
||||
|
|
|
@ -76,6 +76,10 @@ export function resetAllExerciseProgress() {
|
|||
sendResetAllExerciseProgress()
|
||||
}
|
||||
|
||||
export function resetAll() {
|
||||
sendResetAll()
|
||||
}
|
||||
|
||||
export function resetLiveLogs() {
|
||||
sendResetLiveLogs()
|
||||
}
|
||||
|
@ -166,6 +170,12 @@ function sendResetAllExerciseProgress() {
|
|||
})
|
||||
}
|
||||
|
||||
function sendResetAll() {
|
||||
socket.emit("reset_all", () => {
|
||||
getProgress()
|
||||
})
|
||||
}
|
||||
|
||||
function sendResetLiveLogs() {
|
||||
socket.emit("reset_notifications", () => {
|
||||
getNotifications()
|
||||
|
|
Loading…
Reference in a new issue