File tree Expand file tree Collapse file tree 2 files changed +4
-12
lines changed
azure-cli-core/azure/cli/core
azure-cli/azure/cli/command_modules/lab Expand file tree Collapse file tree 2 files changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -16,19 +16,15 @@ def is_valid_ssh_rsa_public_key(openssh_pubkey):
1616 # http://stackoverflow.com/questions/2494450/ssh-rsa-public-key-validation-using-a-regular-expression # pylint: disable=line-too-long
1717 # A "good enough" check is to see if the key starts with the correct header.
1818 import struct
19- try :
20- from base64 import decodebytes as base64_decode
21- except ImportError :
22- # deprecated and redirected to decodebytes in Python 3
23- from base64 import decodestring as base64_decode
19+ import base64
2420
2521 parts = openssh_pubkey .split ()
2622 if len (parts ) < 2 :
2723 return False
2824 key_type = parts [0 ]
2925 key_string = parts [1 ]
3026
31- data = base64_decode ( key_string . encode ()) # pylint:disable=deprecated-method
27+ data = base64 . b64decode ( key_string )
3228 int_len = 4
3329 str_len = struct .unpack ('>I' , data [:int_len ])[0 ] # this should return 7
3430 return data [int_len :int_len + str_len ] == key_type .encode ()
Original file line number Diff line number Diff line change @@ -499,18 +499,14 @@ def _is_valid_ssh_rsa_public_key(openssh_pubkey):
499499 # http://stackoverflow.com/questions/2494450/ssh-rsa-public-key-validation-using-a-regular-expression
500500 # A "good enough" check is to see if the key starts with the correct header.
501501 import struct
502- try :
503- from base64 import decodebytes as base64_decode
504- except ImportError :
505- # deprecated and redirected to decodebytes in Python 3
506- from base64 import decodestring as base64_decode
502+ import base64
507503 parts = openssh_pubkey .split ()
508504 if len (parts ) < 2 :
509505 return False
510506 key_type = parts [0 ]
511507 key_string = parts [1 ]
512508
513- data = base64_decode ( key_string . encode ()) # pylint:disable=deprecated-method
509+ data = base64 . b64decode ( key_string )
514510 int_len = 4
515511 str_len = struct .unpack ('>I' , data [:int_len ])[0 ] # this should return 7
516512 return data [int_len :int_len + str_len ] == key_type .encode ()
You can’t perform that action at this time.
0 commit comments