Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit c8297dd

Browse files
committed
MYSQL-7 : Password Values not redacted in the shell logs
1 parent 989335f commit c8297dd

File tree

9 files changed

+47
-75
lines changed

9 files changed

+47
-75
lines changed

src/dboperations/dboperations.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def stop_mysql(port,connection,baseDir,vdbConn,pwd):
3737
if(port_stat == Status.ACTIVE):
3838
logger.debug("DB is Running. Shutting down.")
3939
shutdown_cmd = "%s/bin/mysqladmin %s'%s' --protocol=TCP --port=%s shutdown" % (baseDir,vdbConn,pwd,port)
40-
logger.debug("Shutdown Command: {}".format(shutdown_cmd))
40+
# logger.debug("Shutdown Command: {}".format(shutdown_cmd))
4141
result = libs.run_bash(connection, shutdown_cmd,environment_vars,check=True)
4242
output = result.stdout.strip()
4343
error = result.stderr.strip()
@@ -46,7 +46,7 @@ def stop_mysql(port,connection,baseDir,vdbConn,pwd):
4646
logger.debug("There was an error trying to shutdown the database : "+error)
4747
raise MySQLShutdownException(error)
4848
else:
49-
logger.debug("Output: "+output)
49+
logger.debug("DB shutdown completed")
5050
time.sleep(25)
5151
if(Status.ACTIVE == get_port_status(port,connection)):
5252
logger.debug("KILL")
@@ -97,7 +97,6 @@ def get_port_status(port,connection):
9797
except Exception as err:
9898
logger.debug("Port Check Failed for second cmd: "+err.message)
9999
logger.debug("Port Status Response >")
100-
logger.debug(output)
101100

102101
if output== "":
103102
logger.debug("MySQL DB is NOT RUNNING at Port:"+myport)
@@ -130,7 +129,6 @@ def start_mysql(installPath,baseDir,mountPath,port,serverId,connection):
130129
if(port_stat == Status.INACTIVE):
131130
logger.debug("DB is not running. Starting the MySQL DB")
132131
start_cmd=get_start_cmd(installPath,baseDir,mountPath,port,serverId)
133-
logger.debug("Startup Command: {}".format(start_cmd))
134132
result = libs.run_bash(connection, start_cmd,environment_vars,check=True)
135133
output = result.stdout.strip()
136134
error = result.stderr.strip()
@@ -139,7 +137,7 @@ def start_mysql(installPath,baseDir,mountPath,port,serverId,connection):
139137
logger.debug("There was an error trying to start the DB : "+error)
140138
raise MySQLStartupException(error)
141139
else:
142-
logger.debug("Output: "+output)
140+
logger.debug("DB Started")
143141
time.sleep(25)
144142
if(Status.ACTIVE == get_port_status(port,connection)):
145143
logger.debug("DB Started Successfully")
@@ -168,12 +166,11 @@ def start_slave(connection,installPath,port,connString,username,pwd,hostIp):
168166
raise Exception("One of the required params for MySQL Connection is empty")
169167
else:
170168
start_slave_cmd=CommandFactory.start_replication(connection,installPath,port,connString,username,pwd,hostIp)
171-
logger.debug("Connection String with {}".format(start_slave_cmd))
172169
try:
173170
logger.debug("Starting Slave")
174171
result = libs.run_bash(connection, start_slave_cmd,environment_vars,check=True)
175172
output = result.stdout.strip()
176-
logger.debug("Start Slave Output: {}".format(output))
173+
logger.debug("Start Slave Completed")
177174
except Exception as err:
178175
logger.debug("Starting Slave Failed: "+err.message)
179176
raise err
@@ -187,17 +184,16 @@ def stop_slave(connection,installPath,port,connString,username,pwd,hostIp):
187184
raise Exception("One of the required params for MySQL Connection is empty")
188185
else:
189186
stop_slave_cmd=CommandFactory.stop_replication(connection,installPath,port,connString,username,pwd,hostIp)
190-
logger.debug("Connection String with {}".format(stop_slave_cmd))
191187
try:
192188
logger.debug("Stopping Replication")
193189
result = libs.run_bash(connection, stop_slave_cmd,environment_vars,check=True)
194190
_output=result.stdout.strip()
195191
_bashErrMsg=result.stderr.strip()
196192
_bashErrCode=result.exit_code
197193
if _bashErrCode!=0:
198-
logger.debug("Stopping Slave was not succesful")
194+
logger.debug("Stopping Slave was not successful")
199195
raise Exception(_bashErrMsg)
200-
logger.debug("Start Slave Response: {}".format(_output))
196+
logger.debug("Stop Replication successful")
201197
except Exception as err:
202198
logger.debug("Stop Replication Failed Due To: "+err.message)
203199
logger.debug("Ignoring and continuing")
@@ -213,7 +209,6 @@ def get_connection_cmd(installPath,port,connString,username,pwd,hostIp):
213209
raise ValueError("One of the required params for MySQL Connection is empty")
214210
else:
215211
connection_cmd=CommandFactory.connect_to_mysql(installPath,port,connString,username,pwd,hostIp)
216-
logger.debug("connaction_cmd >"+connection_cmd)
217212
return connection_cmd
218213

219214
def get_start_cmd(installPath,baseDir,mountPath,port,serverId):

src/plugin_runner.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ def stop_staging(staged_source, repository, source_config):
7575
pluginops.stop_staging(staged_source, repository, source_config)
7676

7777
@plugin.linked.pre_snapshot()
78-
def linked_pre_snapshot(staged_source, repository, source_config, snapshot_parameters):
78+
def linked_pre_snapshot(staged_source, repository, source_config, optional_snapshot_parameters):
7979
logger.debug("linked_pre_snapshot > Start ")
8080
# Start Staging if not already running.
81-
pluginops.linked_pre_snapshot(staged_source, repository, source_config, snapshot_parameters)
81+
pluginops.linked_pre_snapshot(staged_source, repository, source_config, optional_snapshot_parameters)
8282
logger.debug(" linked_pre_snapshot > End ")
8383

8484
@plugin.linked.post_snapshot()
85-
def linked_post_snapshot(staged_source,repository,source_config,snapshot_parameters):
85+
def linked_post_snapshot(staged_source,repository,source_config,optional_snapshot_parameters):
8686
logger.debug("linked_post_snapshot - Start ")
87-
snapshot = pluginops.linked_post_snapshot(staged_source,repository,source_config,snapshot_parameters)
87+
snapshot = pluginops.linked_post_snapshot(staged_source,repository,source_config,optional_snapshot_parameters)
8888
linked_status(staged_source, repository, source_config)
8989
logger.debug("linked_post_snapshot - End ")
9090
return snapshot
@@ -105,9 +105,6 @@ def configure(virtual_source, snapshot, repository):
105105
def reconfigure(virtual_source, repository, source_config, snapshot):
106106
logger.debug("virtual.reconfigure > Start")
107107
start(virtual_source, repository, source_config)
108-
logger.debug(source_config)
109-
logger.debug("Snapshot")
110-
logger.debug(snapshot)
111108
#srcConfig = configure(virtual_source,snapshot,repository)
112109
logger.debug("virtual.reconfigure > End")
113110
virtual_status(virtual_source, repository, source_config)
@@ -140,7 +137,6 @@ def virtual_post_snapshot(virtual_source, repository, source_config):
140137
snapshot.snap_backup_path=""
141138
snapshot.snap_time=utils.get_current_time()
142139
logger.debug("SnapShot Definition Created")
143-
logger.debug(snapshot)
144140
return snapshot
145141

146142
@plugin.virtual.start()

src/pluginops/pluginops.py

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ def start_staging(staged_source, repository, source_config):
124124
result = libs.run_bash(staged_source.staged_connection, start_staging_script,environment_vars,check=True)
125125
output = result.stdout.strip()
126126
error = result.stderr.strip()
127-
logger.debug("output:"+output)
128-
logger.debug("error:"+error)
129127
exit_code = result.exit_code
130128
if exit_code !=0:
131129
logger.debug("There was an error> "+error)
@@ -151,8 +149,6 @@ def start_staging(staged_source, repository, source_config):
151149
result = libs.run_bash(staged_source.staged_connection, start_staging_script,environment_vars,check=True)
152150
output = result.stdout.strip()
153151
error = result.stderr.strip()
154-
logger.debug("output:"+output)
155-
logger.debug("error:"+error)
156152
exit_code = result.exit_code
157153
if exit_code !=0:
158154
logger.debug("Error is : "+error)
@@ -188,7 +184,7 @@ def stop_staging(staged_source, repository, source_config):
188184
logger.debug("Error is : "+error)
189185
raise LinkingException("Exception while stopping staging:"+error)
190186
else:
191-
logger.debug("Stop Staging - Successful: "+output)
187+
logger.debug("Stop Staging - Successful")
192188
elif staged_source.parameters.d_source_type == "Manual Backup Ingestion":
193189
logger.debug("plugin_operations.stop_staging > Manual Backup Ingestion")
194190
library_script=pkgutil.get_data('resources','library.sh')
@@ -210,7 +206,7 @@ def stop_staging(staged_source, repository, source_config):
210206
logger.debug("Error is : "+error)
211207
raise LinkingException("Exception while stopping staging:"+error)
212208
else:
213-
logger.debug("Stop Staging - Successful: "+output)
209+
logger.debug("Stop Staging - Successful")
214210
else :
215211
logger.debug("dSourceType is Simple Tablespace Backup. ")
216212
library_script=pkgutil.get_data('resources','library.sh')
@@ -232,7 +228,7 @@ def stop_staging(staged_source, repository, source_config):
232228
logger.debug("Error is : "+error)
233229
raise LinkingException("Exception while stopping staging:"+error)
234230
else:
235-
logger.debug("Stop Staging - Successful: "+output)
231+
logger.debug("Stop Staging - Successful: ")
236232
#TODO: Integration
237233

238234
##################################################
@@ -321,18 +317,17 @@ def linked_pre_snapshot(staged_source, repository, source_config, snapshot_param
321317
logger.error(err)
322318
raise err
323319
else:
324-
logger.debug("Pre-Snapshot/Restore successful "+output)
320+
logger.debug("Pre-Snapshot/Restore successful ")
325321
logger.debug("Restoring Backup to Stage")
326322
restore_script = pkgutil.get_data('resources', 'restore_stage.sh')
327323
result = libs.run_bash(staged_source.staged_connection, restore_script,environment_vars,check=False)
328-
logger.debug(result)
329324
output = result.stdout.strip()
330325
std_err=result.stderr.strip()
331326
exit_code = result.exit_code
332327
logger.debug(std_err)
333328
logger.debug(exit_code)
334329
if exit_code == 0:
335-
logger.debug("Creation of Staging DB(Pre-Snapshot) successful."+output)
330+
logger.debug("Creation of Staging DB(Pre-Snapshot) successful.")
336331
else:
337332
logger.debug("There was an error while creating the staging DB.Check error.log for details.")
338333
err = utils.process_exit_codes(exit_code,"DBLINK",std_err)
@@ -369,7 +364,7 @@ def linked_pre_snapshot(staged_source, repository, source_config, snapshot_param
369364
logger.error(err)
370365
raise err
371366
else:
372-
logger.debug("Pre-Snapshot/Restore_DB successful "+output)
367+
logger.debug("Pre-Snapshot/Restore_DB successful ")
373368
else:
374369
# Simple Tablespace Option is hidden from the plugin.
375370
# This section will not get triggered until the option gets added back in schema.json
@@ -407,7 +402,7 @@ def linked_pre_snapshot(staged_source, repository, source_config, snapshot_param
407402
logger.debug("There was an error while resync : "+error)
408403
raise LinkingException("Exception in pre-snapshot/restore_db:"+error)
409404
else:
410-
logger.debug("Pre-Snapshot/Restore_DB successful "+output)
405+
logger.debug("Pre-Snapshot/Restore_DB successful")
411406

412407
# Simple Tablespace Option is hidden from the plugin.
413408
# This section will not get triggered until the option gets added back in schema.json
@@ -471,7 +466,6 @@ def linked_post_snapshot(
471466
logger.debug("plugin_opertions.linked_post_snapshot - Start ")
472467
dSourceType = staged_source.parameters.d_source_type
473468
start_staging(staged_source,repository,source_config)
474-
logger.debug(snapshot_parameters)
475469
mount_path=staged_source.parameters.mount_path
476470
snapshot = SnapshotDefinition(validate=False)
477471
snapshot.snapshot_id= str(utils.get_snapshot_id())
@@ -482,7 +476,6 @@ def linked_post_snapshot(
482476
snapshot.snap_pass=staged_source.parameters.staging_pass
483477
snapshot.snap_backup_path=staged_source.parameters.backup_path
484478
snapshot.snap_time=utils.get_current_time()
485-
logger.debug(snapshot)
486479
logger.debug("linked_post_snapshot - End ")
487480
return snapshot
488481

@@ -510,7 +503,7 @@ def linked_status(staged_source, repository, source_config):
510503
logger.debug("Exception while checking Staging DB Status : "+error)
511504
#ignore status?
512505
else:
513-
logger.debug("Staging Status Check: "+output)
506+
logger.debug("Staging Status Check successful")
514507
if output == "ACTIVE":
515508
return Status.ACTIVE
516509
else:
@@ -532,11 +525,9 @@ def configure(virtual_source, snapshot, repository):
532525
)
533526
logger.debug("Mount Path:"+mount_path)
534527
logger.debug("Snapshot Settings:")
535-
logger.debug(snapshot)
536528
logger.debug("Snapshot_id"+snapshot.snapshot_id)
537529
logger.debug("Config Settings: ")
538530
config_settings_prov = virtual_source.parameters.config_settings_prov
539-
logger.debug(config_settings_prov)
540531
config_params=""
541532
###################################################################
542533
# TODO: Operation fails if there are config settings. Must revisit.
@@ -576,19 +567,18 @@ def configure(virtual_source, snapshot, repository):
576567
}
577568
configure_script = pkgutil.get_data('resources', 'provision.sh')
578569
result = libs.run_bash(virtual_source.connection, configure_script,environment_vars,check=False)
579-
logger.debug(result)
580570
output = result.stdout.strip()
581571
std_err=result.stderr.strip()
582572
exit_code = result.exit_code
583573
if exit_code == 0:
584-
logger.debug("Pre-Snapshot/Restore_DB successful "+output)
574+
logger.debug("Pre-Snapshot/Restore_DB successful")
585575
else:
586576
err = utils.process_exit_codes(exit_code,"PROVISION",std_err)
587577
logger.debug("There was an error while provisioning.Check error.log for details.")
588578
logger.error(err)
589579
raise err
590580
return SourceConfigDefinition(
591-
db_name=output,
581+
db_name=virtual_source.parameters.t_database_name,
592582
base_dir=virtual_source.parameters.base_dir,
593583
port=virtual_source.parameters.port,
594584
data_dir=mount_path
@@ -610,7 +600,6 @@ def stop_mysql(port,connection,baseDir,user,pwd,host):
610600
if(port_stat == Status.ACTIVE):
611601
logger.debug("DB is Running. Shutting down.")
612602
shutdown_cmd = "%s/bin/mysqladmin %s'%s' --protocol=TCP --port=%s shutdown" % (baseDir,vdbConn,pwd,port)
613-
logger.debug("Shutdown Command: {}".format(shutdown_cmd))
614603
result = libs.run_bash(connection, shutdown_cmd,environment_vars,check=True)
615604
output = result.stdout.strip()
616605
error = result.stderr.strip()
@@ -619,7 +608,7 @@ def stop_mysql(port,connection,baseDir,user,pwd,host):
619608
logger.debug("There was an error trying to shutdown the database : "+error)
620609
#raise MySQLShutdownException(error)
621610
else:
622-
logger.debug("Output: "+output)
611+
logger.debug("Shutdown of database successful")
623612
time.sleep(20)
624613
if(Status.ACTIVE == get_port_status(port,connection)):
625614
logger.debug("MySQL has not shutdown after 20 seconds. Killing process.")
@@ -676,8 +665,7 @@ def get_port_status(port,connection):
676665
output = result.stdout.strip()
677666
except Exception as err:
678667
logger.debug("Port Check Failed for second cmd: "+err.message)
679-
logger.debug("Port Status Response >")
680-
logger.debug(output)
668+
logger.debug("Get port status successful")
681669

682670
if output== "":
683671
logger.debug("MySQL DB is NOT RUNNING at Port:"+myport)
@@ -714,7 +702,6 @@ def start_mysql(installPath,baseDir,mountPath,port,serverId,connection):
714702
if(port_stat == Status.INACTIVE):
715703
logger.debug("DB is not running. Starting the MySQL DB")
716704
start_cmd=get_start_cmd(installPath,baseDir,mountPath,port,serverId)
717-
logger.debug("Startup Command: {}".format(start_cmd))
718705
result = libs.run_bash(connection, start_cmd,environment_vars,check=True)
719706
output = result.stdout.strip()
720707
error = result.stderr.strip()
@@ -726,8 +713,6 @@ def start_mysql(installPath,baseDir,mountPath,port,serverId,connection):
726713
constants.ERR_START_ACTION,
727714
"ExitCode:{} \n {}".format(exit_code,error)
728715
)
729-
else:
730-
logger.debug("Output: "+output)
731716
time.sleep(30)
732717
if(Status.ACTIVE == get_port_status(port,connection)):
733718
logger.debug("DB Started Successfully")
@@ -750,12 +735,11 @@ def start_slave(connection,installPath,port,connString,username,pwd,hostIp):
750735
raise Exception("One of the required params for MySQL Connection is empty")
751736
else:
752737
start_slave_cmd=CommandFactory.start_replication(connection,installPath,port,connString,username,pwd,hostIp)
753-
logger.debug("Connection String with {}".format(start_slave_cmd))
754738
try:
755739
logger.debug("Starting Slave")
756740
result = libs.run_bash(connection, start_slave_cmd,environment_vars,check=True)
757741
output = result.stdout.strip()
758-
logger.debug("Start Slave Output: {}".format(output))
742+
logger.debug("Start Slave successful")
759743
except Exception as err:
760744
logger.debug("Starting Slave Failed: "+err.message)
761745
raise err
@@ -773,17 +757,16 @@ def stop_slave(connection,installPath,port,connString,username,pwd,hostIp):
773757
raise Exception("One of the required params for MySQL Connection is empty")
774758
else:
775759
stop_slave_cmd=CommandFactory.stop_replication(connection,installPath,port,connString,username,pwd,hostIp)
776-
logger.debug("Connection String with {}".format(stop_slave_cmd))
777760
try:
778761
logger.debug("Stopping Replication")
779762
result = libs.run_bash(connection, stop_slave_cmd,environment_vars,check=True)
780763
_output=result.stdout.strip()
781764
_bashErrMsg=result.stderr.strip()
782765
_bashErrCode=result.exit_code
783766
if _bashErrCode!=0:
784-
logger.debug("Stopping Slave was not succesful")
767+
logger.debug("Stopping Slave was not successful")
785768
raise Exception(_bashErrMsg)
786-
logger.debug("Start Slave Response: {}".format(_output))
769+
logger.debug("Stopping Slave successful")
787770
except Exception as err:
788771
logger.debug("Stop Replication Failed Due To: "+err.message)
789772
logger.debug("Ignoring and continuing")
@@ -802,7 +785,6 @@ def get_connection_cmd(installPath,port,connString,username,pwd,hostIp):
802785
raise ValueError("One of the required params for MySQL Connection is empty")
803786
else:
804787
connection_cmd=CommandFactory.connect_to_mysql(installPath,port,connString,username,pwd,hostIp)
805-
logger.debug("connaction_cmd >"+connection_cmd)
806788
return connection_cmd
807789

808790
##################################################
@@ -850,16 +832,13 @@ def repository_discovery(source_connection):
850832
logger.debug("Error is : "+error)
851833
raise RepositoryDiscoveryError("Exception while discovering:"+error)
852834
else:
853-
logger.debug("Output: "+output)
854835
#process repository json
855836
repos_js=json.loads(output)
856837
# print the keys and values
857838
for repo_js in repos_js:
858-
#logger.debug("Adding repository:"+repo_js+" to list")
859839
path = repo_js['installPath']
860840
version = repo_js['version']
861841
prettyName = repo_js['prettyName'].split("/bin")[1]
862842
repository = RepositoryDefinition(name=prettyName, install_path=path, version=version)
863843
repositories.append(repository)
864-
logger.debug("output:"+output)
865844
return repositories

0 commit comments

Comments
 (0)