Loading exercise/lib/exercise_manager.py +1 −1 Original line number Diff line number Diff line Loading @@ -225,7 +225,7 @@ def create_exercise( create_drive_permissions(teams, definition.files.filter(is_drive=True)) if exercise.technical: create_opensearch_exercise(teams) create_opensearch_exercise(teams, exercise.id) return exercise Loading running_exercise/lib/opensearch_client.py +8 −7 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ from opensearchpy import OpenSearch from django.conf import settings from exercise.models import OpenSearchAccess from user.lib.passphrase_generator import PassphraseGenerator def get_opensearch_client(): host = settings.OPENSEARCH_HOST Loading @@ -16,7 +18,7 @@ def get_opensearch_client(): ) def create_opensearch_exercise(teams): def create_opensearch_exercise(teams, exercise_id): """ For each team: ` Loading @@ -36,10 +38,11 @@ def create_opensearch_exercise(teams): for team in teams: team_id = team.id index_name = f"team-{team_id}--index" username = f"team-{team_id}" # TODO: Generate a strong password for each user (configure opensearch password policy) password = f"v&ery6#7st*ong78288732-pass889329word-aVUfg9{team_id}" username = f"exercise-{exercise_id}--team-{team_id}" index_name = f"{username}--index" role_name = f"{username}--role" # TODO: ensure that the password will be strong enough to pass the OpenSearch verification password = PassphraseGenerator.generate_passphrase() opensearch_access_list.append( OpenSearchAccess( Loading @@ -50,8 +53,6 @@ def create_opensearch_exercise(teams): ) ) role_name = f"team-{team_id}--role" try: client.indices.create(index=index_name) Loading Loading
exercise/lib/exercise_manager.py +1 −1 Original line number Diff line number Diff line Loading @@ -225,7 +225,7 @@ def create_exercise( create_drive_permissions(teams, definition.files.filter(is_drive=True)) if exercise.technical: create_opensearch_exercise(teams) create_opensearch_exercise(teams, exercise.id) return exercise Loading
running_exercise/lib/opensearch_client.py +8 −7 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ from opensearchpy import OpenSearch from django.conf import settings from exercise.models import OpenSearchAccess from user.lib.passphrase_generator import PassphraseGenerator def get_opensearch_client(): host = settings.OPENSEARCH_HOST Loading @@ -16,7 +18,7 @@ def get_opensearch_client(): ) def create_opensearch_exercise(teams): def create_opensearch_exercise(teams, exercise_id): """ For each team: ` Loading @@ -36,10 +38,11 @@ def create_opensearch_exercise(teams): for team in teams: team_id = team.id index_name = f"team-{team_id}--index" username = f"team-{team_id}" # TODO: Generate a strong password for each user (configure opensearch password policy) password = f"v&ery6#7st*ong78288732-pass889329word-aVUfg9{team_id}" username = f"exercise-{exercise_id}--team-{team_id}" index_name = f"{username}--index" role_name = f"{username}--role" # TODO: ensure that the password will be strong enough to pass the OpenSearch verification password = PassphraseGenerator.generate_passphrase() opensearch_access_list.append( OpenSearchAccess( Loading @@ -50,8 +53,6 @@ def create_opensearch_exercise(teams): ) ) role_name = f"team-{team_id}--role" try: client.indices.create(index=index_name) Loading