@@ -383,6 +383,28 @@ def infrastructure_state():
383383 app .logger .error ("Error getting infrastructure state: %s" % exs )
384384 return {"state" : "error" , "vm_states" : {}}
385385
386+ def hide_sensitive_data (template ):
387+ """Remove/Hide sensitive data (passwords, credentials)."""
388+ data = yaml .full_load (template )
389+
390+ for node in list (data ['topology_template' ]['node_templates' ].values ()):
391+ if node ["type" ] == "tosca.nodes.ec3.DNSRegistry" :
392+ try :
393+ node ["properties" ]["dns_service_credentials" ]["token" ] = "AK:SK"
394+ except KeyError :
395+ pass
396+
397+ if node ["type" ] == "tosca.nodes.ec3.ElasticCluster" :
398+ if "im_auth" in node ["properties" ]:
399+ node ["properties" ]["im_auth" ] = "protected"
400+ try :
401+ node ["interfaces" ]["Standard" ]["configure" ]["inputs" ]["CLIENT_ID" ] = "client_id"
402+ node ["interfaces" ]["Standard" ]["configure" ]["inputs" ]["CLIENT_SECRET" ] = "client_secret"
403+ except KeyError :
404+ pass
405+
406+ return yaml .dump (data , default_flow_style = False , sort_keys = False )
407+
386408 @app .route ('/template/<infid>' )
387409 @authorized_with_valid_token
388410 def template (infid = None ):
@@ -393,7 +415,7 @@ def template(infid=None):
393415 response = im .get_inf_property (infid , 'tosca' , auth_data )
394416 if not response .ok :
395417 raise Exception (response .text )
396- template = response .text
418+ template = hide_sensitive_data ( response .text )
397419 except Exception as ex :
398420 flash ("Error getting template: \n %s" % ex , "error" )
399421
@@ -644,7 +666,6 @@ def createdep():
644666
645667 with io .open (settings .toscaDir + request .args .get ('template' )) as stream :
646668 template = yaml .full_load (stream )
647- template = add_image_to_template (template , image )
648669
649670 template = add_image_to_template (template , image )
650671
0 commit comments