fix: [backend:app] Make sure to cast uesr_id into integer and updated config.sample
This commit is contained in:
parent
d637f2a0ee
commit
cffb761c4d
3 changed files with 18 additions and 5 deletions
|
@ -14,6 +14,14 @@ live_logs_accepted_scope = {
|
|||
'tags': '*',
|
||||
}
|
||||
|
||||
user_activity_accepted_scope = {
|
||||
'events': ['view', 'add', 'edit', 'delete', 'restSearch',],
|
||||
'attributes': ['add', 'edit', 'delete', 'restSearch',],
|
||||
'objects': ['add', 'edit', 'delete',],
|
||||
'eventReports': ['view', 'add', 'edit', 'delete',],
|
||||
'tags': '*',
|
||||
}
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('misp-exercise-dashboard')
|
||||
format = '[%(levelname)s] %(asctime)s - %(message)s'
|
||||
|
|
|
@ -77,8 +77,12 @@ def restore_exercices_progress():
|
|||
data = json.load(f)
|
||||
db.EXERCISES_STATUS = data['EXERCISES_STATUS']
|
||||
db.SELECTED_EXERCISES = data['SELECTED_EXERCISES']
|
||||
db.USER_ID_TO_EMAIL_MAPPING = data['USER_ID_TO_EMAIL_MAPPING']
|
||||
db.USER_ID_TO_AUTHKEY_MAPPING = data['USER_ID_TO_AUTHKEY_MAPPING']
|
||||
db.USER_ID_TO_EMAIL_MAPPING = {}
|
||||
for user_id_str, email in data['USER_ID_TO_EMAIL_MAPPING']:
|
||||
db.USER_ID_TO_EMAIL_MAPPING[int(user_id_str)] = email
|
||||
db.USER_ID_TO_AUTHKEY_MAPPING = {}
|
||||
for user_id_str, authkey in data['USER_ID_TO_AUTHKEY_MAPPING']:
|
||||
db.USER_ID_TO_AUTHKEY_MAPPING[int(user_id_str)] = authkey
|
||||
except:
|
||||
logger.info('Could not restore exercise progress')
|
||||
|
||||
|
@ -323,6 +327,7 @@ def get_progress():
|
|||
progress = {}
|
||||
for user_id in completion_for_users.keys():
|
||||
if user_id not in db.USER_ID_TO_EMAIL_MAPPING:
|
||||
print('unknown user id', user_id)
|
||||
continue
|
||||
progress[user_id] = {
|
||||
'email': db.USER_ID_TO_EMAIL_MAPPING[user_id],
|
||||
|
|
|
@ -209,9 +209,9 @@ def is_accepted_user_activity(notification) -> bool:
|
|||
return False
|
||||
|
||||
scope, action = get_scope_action_from_url(notification['url'])
|
||||
if scope in config.uesr_activity_accepted_scope:
|
||||
if config.uesr_activity_accepted_scope == '*':
|
||||
if scope in config.user_activity_accepted_scope:
|
||||
if config.user_activity_accepted_scope == '*':
|
||||
return True
|
||||
elif action in config.uesr_activity_accepted_scope[scope]:
|
||||
elif action in config.user_activity_accepted_scope[scope]:
|
||||
return True
|
||||
return False
|
Loading…
Reference in a new issue