Skip to content

Commit

Permalink
refactor: Improve security by replacing random.choice with secrets.ch…
Browse files Browse the repository at this point in the history
…oice
  • Loading branch information
lhhyung committed Dec 13, 2024
1 parent 6c0fbed commit 3f8a4a5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/spaceone/plugin/service/plugin_service.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import logging
import random
import secrets

from spaceone.core.service import *
from spaceone.core import config

from spaceone.core.service import *
from spaceone.plugin.error import *
from spaceone.plugin.manager.plugin_manager import *
from spaceone.plugin.manager.supervisor_manager import *
from spaceone.plugin.manager.repository_manager import RepositoryManager
from spaceone.plugin.manager.supervisor_manager import *

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -264,7 +263,7 @@ def _select_endpoint(self, plugin_ref, updated_version=None):
@staticmethod
def _select_one(choice_list, algorithm="random"):
if algorithm == "random":
return random.choice(choice_list)
return secrets.choice(choice_list)
_LOGGER.error(f"[_select_one] unimplemented algorithm: {algorithm}")

def _check_plugin(self, plugin_id: str, domain_id: str, version: str, token: str):
Expand Down

0 comments on commit 3f8a4a5

Please sign in to comment.