From aa4d36cc57dda9808297cd743fa968d648a16e61 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Mar 2022 06:11:58 +0530 Subject: [PATCH] Use secrets to generate the random password --- kittens/ssh/main.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index d34485362..28585a9d4 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -5,10 +5,11 @@ import atexit import fnmatch import io import json -import stat import os import re +import secrets import shlex +import stat import sys import tarfile import tempfile @@ -24,7 +25,6 @@ from typing import ( from kitty.constants import cache_dir, shell_integration_dir, terminfo_dir from kitty.fast_data_types import get_options -from kitty.short_uuid import uuid4 from kitty.utils import SSHConnectionData from .completion import complete, ssh_options @@ -33,7 +33,6 @@ from .copy import CopyInstruction from .options.types import Options as SSHOptions from .options.utils import DELETE_ENV_VAR - # See https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html quote_pat = re.compile('([\\`"\n])') @@ -220,7 +219,7 @@ def bootstrap_script( exec_cmd = prepare_exec_cmd(remote_args, script_type == 'py') if remote_args else '' with open(os.path.join(shell_integration_dir, 'ssh', f'bootstrap.{script_type}')) as f: ans = f.read() - pw = uuid4() + pw = secrets.token_hex() ddir = os.path.join(cache_dir(), 'ssh') os.makedirs(ddir, exist_ok=True) with tempfile.NamedTemporaryFile(prefix='ssh-kitten-pw-', suffix='.json', dir=ddir, delete=False) as tf: