fix empty password

This commit is contained in:
obdev
2024-05-07 12:20:38 +00:00
committed by ob-robot
parent 3d804e3693
commit ea454e2ce9
6 changed files with 48 additions and 48 deletions

View File

@ -26,7 +26,7 @@ class UpgradeParams:
class PasswordMaskingFormatter(logging.Formatter): class PasswordMaskingFormatter(logging.Formatter):
def format(self, record): def format(self, record):
s = super(PasswordMaskingFormatter, self).format(record) s = super(PasswordMaskingFormatter, self).format(record)
return re.sub(r'password=\".*?\"', 'password=\"******\"', s) return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
def config_logging_module(log_filenamme): def config_logging_module(log_filenamme):
logging.basicConfig(level=logging.INFO,\ logging.basicConfig(level=logging.INFO,\
@ -156,7 +156,7 @@ def do_upgrade_by_argv(argv):
else: else:
raise MyError('invalid module: {0}'.format(cmd_module)) raise MyError('invalid module: {0}'.format(cmd_module))
logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\ logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
host, port, user, password, timeout, module_set, log_filename) host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
do_upgrade(host, port, user, password, timeout, module_set, upgrade_params) do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
except mysql.connector.Error, e: except mysql.connector.Error, e:
logging.exception('mysql connctor error') logging.exception('mysql connctor error')

View File

@ -25,7 +25,7 @@ class UpgradeParams:
class PasswordMaskingFormatter(logging.Formatter): class PasswordMaskingFormatter(logging.Formatter):
def format(self, record): def format(self, record):
s = super(PasswordMaskingFormatter, self).format(record) s = super(PasswordMaskingFormatter, self).format(record)
return re.sub(r'password=\".*?\"', 'password=\"******\"', s) return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
def config_logging_module(log_filenamme): def config_logging_module(log_filenamme):
logging.basicConfig(level=logging.INFO,\ logging.basicConfig(level=logging.INFO,\
@ -146,7 +146,7 @@ def do_upgrade_by_argv(argv):
else: else:
raise MyError('invalid module: {0}'.format(cmd_module)) raise MyError('invalid module: {0}'.format(cmd_module))
logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\ logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
host, port, user, password, timeout, module_set, log_filename) host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
do_upgrade(host, port, user, password, timeout, module_set, upgrade_params) do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
except mysql.connector.Error, e: except mysql.connector.Error, e:
logging.exception('mysql connctor error') logging.exception('mysql connctor error')

View File

@ -17,7 +17,7 @@ class UpgradeParams:
class PasswordMaskingFormatter(logging.Formatter): class PasswordMaskingFormatter(logging.Formatter):
def format(self, record): def format(self, record):
s = super(PasswordMaskingFormatter, self).format(record) s = super(PasswordMaskingFormatter, self).format(record)
return re.sub(r'password=\".*?\"', 'password=\"******\"', s) return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
#### --------------start : my_error.py -------------- #### --------------start : my_error.py --------------
class MyError(Exception): class MyError(Exception):
@ -804,7 +804,7 @@ if __name__ == '__main__':
password = get_opt_password() password = get_opt_password()
timeout = int(get_opt_timeout()) timeout = int(get_opt_timeout())
logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", log-file=\"%s\"',\ logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", log-file=\"%s\"',\
host, port, user, password, timeout, log_filename) host, port, user, password.replace('"', '\\"'), timeout, log_filename)
do_check(host, port, user, password, timeout, upgrade_params) do_check(host, port, user, password, timeout, upgrade_params)
except mysql.connector.Error, e: except mysql.connector.Error, e:
logging.exception('mysql connctor error') logging.exception('mysql connctor error')

View File

@ -16,7 +16,7 @@ class UpgradeParams:
class PasswordMaskingFormatter(logging.Formatter): class PasswordMaskingFormatter(logging.Formatter):
def format(self, record): def format(self, record):
s = super(PasswordMaskingFormatter, self).format(record) s = super(PasswordMaskingFormatter, self).format(record)
return re.sub(r'password=\".*?\"', 'password=\"******\"', s) return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
#### --------------start : my_error.py -------------- #### --------------start : my_error.py --------------
class MyError(Exception): class MyError(Exception):
@ -445,7 +445,7 @@ if __name__ == '__main__':
timeout = int(get_opt_timeout()) timeout = int(get_opt_timeout())
zone = get_opt_zone() zone = get_opt_zone()
logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", log-file=\"%s\", timeout=%s, zone=\"%s\"', \ logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", log-file=\"%s\", timeout=%s, zone=\"%s\"', \
host, port, user, password, log_filename, timeout, zone) host, port, user, password.replace('"', '\\"'), log_filename, timeout, zone)
do_check(host, port, user, password, upgrade_params, timeout, False, zone) # need_check_major_status = False do_check(host, port, user, password, upgrade_params, timeout, False, zone) # need_check_major_status = False
except mysql.connector.Error, e: except mysql.connector.Error, e:
logging.exception('mysql connctor error') logging.exception('mysql connctor error')

View File

@ -626,7 +626,7 @@
#class PasswordMaskingFormatter(logging.Formatter): #class PasswordMaskingFormatter(logging.Formatter):
# def format(self, record): # def format(self, record):
# s = super(PasswordMaskingFormatter, self).format(record) # s = super(PasswordMaskingFormatter, self).format(record)
# return re.sub(r'password=\".*?\"', 'password=\"******\"', s) # return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
# #
#def config_logging_module(log_filenamme): #def config_logging_module(log_filenamme):
# logging.basicConfig(level=logging.INFO,\ # logging.basicConfig(level=logging.INFO,\
@ -756,7 +756,7 @@
# else: # else:
# raise MyError('invalid module: {0}'.format(cmd_module)) # raise MyError('invalid module: {0}'.format(cmd_module))
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\ # logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
# host, port, user, password, timeout, module_set, log_filename) # host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params) # do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
# except mysql.connector.Error, e: # except mysql.connector.Error, e:
# logging.exception('mysql connctor error') # logging.exception('mysql connctor error')
@ -798,7 +798,7 @@
#class PasswordMaskingFormatter(logging.Formatter): #class PasswordMaskingFormatter(logging.Formatter):
# def format(self, record): # def format(self, record):
# s = super(PasswordMaskingFormatter, self).format(record) # s = super(PasswordMaskingFormatter, self).format(record)
# return re.sub(r'password=\".*?\"', 'password=\"******\"', s) # return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
# #
#def config_logging_module(log_filenamme): #def config_logging_module(log_filenamme):
# logging.basicConfig(level=logging.INFO,\ # logging.basicConfig(level=logging.INFO,\
@ -919,7 +919,7 @@
# else: # else:
# raise MyError('invalid module: {0}'.format(cmd_module)) # raise MyError('invalid module: {0}'.format(cmd_module))
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\ # logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
# host, port, user, password, timeout, module_set, log_filename) # host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params) # do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
# except mysql.connector.Error, e: # except mysql.connector.Error, e:
# logging.exception('mysql connctor error') # logging.exception('mysql connctor error')
@ -1677,7 +1677,7 @@
#class PasswordMaskingFormatter(logging.Formatter): #class PasswordMaskingFormatter(logging.Formatter):
# def format(self, record): # def format(self, record):
# s = super(PasswordMaskingFormatter, self).format(record) # s = super(PasswordMaskingFormatter, self).format(record)
# return re.sub(r'password=\".*?\"', 'password=\"******\"', s) # return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
# #
##### --------------start : my_error.py -------------- ##### --------------start : my_error.py --------------
#class MyError(Exception): #class MyError(Exception):
@ -2464,7 +2464,7 @@
# password = get_opt_password() # password = get_opt_password()
# timeout = int(get_opt_timeout()) # timeout = int(get_opt_timeout())
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", log-file=\"%s\"',\ # logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", log-file=\"%s\"',\
# host, port, user, password, timeout, log_filename) # host, port, user, password.replace('"', '\\"'), timeout, log_filename)
# do_check(host, port, user, password, timeout, upgrade_params) # do_check(host, port, user, password, timeout, upgrade_params)
# except mysql.connector.Error, e: # except mysql.connector.Error, e:
# logging.exception('mysql connctor error') # logging.exception('mysql connctor error')
@ -2492,7 +2492,7 @@
#class PasswordMaskingFormatter(logging.Formatter): #class PasswordMaskingFormatter(logging.Formatter):
# def format(self, record): # def format(self, record):
# s = super(PasswordMaskingFormatter, self).format(record) # s = super(PasswordMaskingFormatter, self).format(record)
# return re.sub(r'password=\".*?\"', 'password=\"******\"', s) # return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
# #
##### --------------start : my_error.py -------------- ##### --------------start : my_error.py --------------
#class MyError(Exception): #class MyError(Exception):
@ -2921,7 +2921,7 @@
# timeout = int(get_opt_timeout()) # timeout = int(get_opt_timeout())
# zone = get_opt_zone() # zone = get_opt_zone()
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", log-file=\"%s\", timeout=%s, zone=\"%s\"', \ # logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", log-file=\"%s\", timeout=%s, zone=\"%s\"', \
# host, port, user, password, log_filename, timeout, zone) # host, port, user, password.replace('"', '\\"'), log_filename, timeout, zone)
# do_check(host, port, user, password, upgrade_params, timeout, False, zone) # need_check_major_status = False # do_check(host, port, user, password, upgrade_params, timeout, False, zone) # need_check_major_status = False
# except mysql.connector.Error, e: # except mysql.connector.Error, e:
# logging.exception('mysql connctor error') # logging.exception('mysql connctor error')

View File

@ -626,7 +626,7 @@
#class PasswordMaskingFormatter(logging.Formatter): #class PasswordMaskingFormatter(logging.Formatter):
# def format(self, record): # def format(self, record):
# s = super(PasswordMaskingFormatter, self).format(record) # s = super(PasswordMaskingFormatter, self).format(record)
# return re.sub(r'password=\".*?\"', 'password=\"******\"', s) # return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
# #
#def config_logging_module(log_filenamme): #def config_logging_module(log_filenamme):
# logging.basicConfig(level=logging.INFO,\ # logging.basicConfig(level=logging.INFO,\
@ -756,7 +756,7 @@
# else: # else:
# raise MyError('invalid module: {0}'.format(cmd_module)) # raise MyError('invalid module: {0}'.format(cmd_module))
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\ # logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
# host, port, user, password, timeout, module_set, log_filename) # host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params) # do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
# except mysql.connector.Error, e: # except mysql.connector.Error, e:
# logging.exception('mysql connctor error') # logging.exception('mysql connctor error')
@ -798,7 +798,7 @@
#class PasswordMaskingFormatter(logging.Formatter): #class PasswordMaskingFormatter(logging.Formatter):
# def format(self, record): # def format(self, record):
# s = super(PasswordMaskingFormatter, self).format(record) # s = super(PasswordMaskingFormatter, self).format(record)
# return re.sub(r'password=\".*?\"', 'password=\"******\"', s) # return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
# #
#def config_logging_module(log_filenamme): #def config_logging_module(log_filenamme):
# logging.basicConfig(level=logging.INFO,\ # logging.basicConfig(level=logging.INFO,\
@ -919,7 +919,7 @@
# else: # else:
# raise MyError('invalid module: {0}'.format(cmd_module)) # raise MyError('invalid module: {0}'.format(cmd_module))
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\ # logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", module=\"%s\", log-file=\"%s\"',\
# host, port, user, password, timeout, module_set, log_filename) # host, port, user, password.replace('"', '\\"'), timeout, module_set, log_filename)
# do_upgrade(host, port, user, password, timeout, module_set, upgrade_params) # do_upgrade(host, port, user, password, timeout, module_set, upgrade_params)
# except mysql.connector.Error, e: # except mysql.connector.Error, e:
# logging.exception('mysql connctor error') # logging.exception('mysql connctor error')
@ -1677,7 +1677,7 @@
#class PasswordMaskingFormatter(logging.Formatter): #class PasswordMaskingFormatter(logging.Formatter):
# def format(self, record): # def format(self, record):
# s = super(PasswordMaskingFormatter, self).format(record) # s = super(PasswordMaskingFormatter, self).format(record)
# return re.sub(r'password=\".*?\"', 'password=\"******\"', s) # return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
# #
##### --------------start : my_error.py -------------- ##### --------------start : my_error.py --------------
#class MyError(Exception): #class MyError(Exception):
@ -2464,7 +2464,7 @@
# password = get_opt_password() # password = get_opt_password()
# timeout = int(get_opt_timeout()) # timeout = int(get_opt_timeout())
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", log-file=\"%s\"',\ # logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", timeout=\"%s\", log-file=\"%s\"',\
# host, port, user, password, timeout, log_filename) # host, port, user, password.replace('"', '\\"'), timeout, log_filename)
# do_check(host, port, user, password, timeout, upgrade_params) # do_check(host, port, user, password, timeout, upgrade_params)
# except mysql.connector.Error, e: # except mysql.connector.Error, e:
# logging.exception('mysql connctor error') # logging.exception('mysql connctor error')
@ -2492,7 +2492,7 @@
#class PasswordMaskingFormatter(logging.Formatter): #class PasswordMaskingFormatter(logging.Formatter):
# def format(self, record): # def format(self, record):
# s = super(PasswordMaskingFormatter, self).format(record) # s = super(PasswordMaskingFormatter, self).format(record)
# return re.sub(r'password=\".*?\"', 'password=\"******\"', s) # return re.sub(r'password="(?:[^"\\]|\\.)+"', 'password="******"', s)
# #
##### --------------start : my_error.py -------------- ##### --------------start : my_error.py --------------
#class MyError(Exception): #class MyError(Exception):
@ -2921,7 +2921,7 @@
# timeout = int(get_opt_timeout()) # timeout = int(get_opt_timeout())
# zone = get_opt_zone() # zone = get_opt_zone()
# logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", log-file=\"%s\", timeout=%s, zone=\"%s\"', \ # logging.info('parameters from cmd: host=\"%s\", port=%s, user=\"%s\", password=\"%s\", log-file=\"%s\", timeout=%s, zone=\"%s\"', \
# host, port, user, password, log_filename, timeout, zone) # host, port, user, password.replace('"', '\\"'), log_filename, timeout, zone)
# do_check(host, port, user, password, upgrade_params, timeout, False, zone) # need_check_major_status = False # do_check(host, port, user, password, upgrade_params, timeout, False, zone) # need_check_major_status = False
# except mysql.connector.Error, e: # except mysql.connector.Error, e:
# logging.exception('mysql connctor error') # logging.exception('mysql connctor error')