Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve security by replacing random.choice with secrets.choice #37

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading