[DATALAB-2486] -- hide user/userName param in yaml files
diff --git a/services/datalab-webapp-common/src/main/java/com/epam/datalab/properties/ChangePropertiesConst.java b/services/datalab-webapp-common/src/main/java/com/epam/datalab/properties/ChangePropertiesConst.java
index 235ddc7..2cfc997 100644
--- a/services/datalab-webapp-common/src/main/java/com/epam/datalab/properties/ChangePropertiesConst.java
+++ b/services/datalab-webapp-common/src/main/java/com/epam/datalab/properties/ChangePropertiesConst.java
@@ -23,15 +23,15 @@
String GKE_SELF_SERVICE_PATH = "/root/self-service.yaml";
String GKE_SELF_SERVICE = "self-service.yaml";
String SELF_SERVICE = "self-service.yml";
- // String SELF_SERVICE_PROP_PATH = "services/self-service/self-service.yml";
+ // String SELF_SERVICE_PROP_PATH = "services/self-service/self-service.yml";
String SELF_SERVICE_PROP_PATH = "/opt/datalab/conf/self-service.yml";
String PROVISIONING_SERVICE = "provisioning.yml";
- // String PROVISIONING_SERVICE_PROP_PATH = "services/provisioning-service/provisioning.yml";
+ // String PROVISIONING_SERVICE_PROP_PATH = "services/provisioning-service/provisioning.yml";
String PROVISIONING_SERVICE_PROP_PATH = "/opt/datalab/conf/provisioning.yml";
String BILLING_SERVICE = "billing.yml";
- // String BILLING_SERVICE_PROP_PATH = "services/billing-gcp/billing.yml";
-// String BILLING_SERVICE_PROP_PATH = "services/billing-azure/billing.yml";
+ // String BILLING_SERVICE_PROP_PATH = "services/billing-gcp/billing.yml";
+ // String BILLING_SERVICE_PROP_PATH = "services/billing-azure/billing.yml";
// String BILLING_SERVICE_PROP_PATH = "services/billing-aws/billing.yml";
String BILLING_SERVICE_PROP_PATH = "/opt/datalab/conf/billing.yml";
String GKE_BILLING_PATH = "/root/billing.yaml";
@@ -44,6 +44,7 @@
String PROVISIONING_SERVICE_SUPERVISORCTL_RUN_NAME = " provserv ";
String BILLING_SERVICE_SUPERVISORCTL_RUN_NAME = " billing ";
String SECRET_REGEX = "((.*)[sS]ecret(.*)|password): (.*)";
+ String USER_REGEX = " *(user|username): (.*)";
String SECRET_REPLACEMENT_FORMAT = " ***********";
String SUPERVISORCTL_RESTART_SH_COMMAND = "sudo supervisorctl restart";
String CHANGE_CHMOD_SH_COMMAND_FORMAT = "sudo chmod %s %s";
diff --git a/services/datalab-webapp-common/src/main/java/com/epam/datalab/properties/ChangePropertiesService.java b/services/datalab-webapp-common/src/main/java/com/epam/datalab/properties/ChangePropertiesService.java
index bbedce0..e4944a5 100644
--- a/services/datalab-webapp-common/src/main/java/com/epam/datalab/properties/ChangePropertiesService.java
+++ b/services/datalab-webapp-common/src/main/java/com/epam/datalab/properties/ChangePropertiesService.java
@@ -92,17 +92,27 @@
private String hideSecretsAndRemoveLicence(String currentConf) {
- Matcher m = Pattern.compile(ChangePropertiesConst.SECRET_REGEX).matcher(currentConf);
+ Matcher passMatcher = Pattern.compile(ChangePropertiesConst.SECRET_REGEX).matcher(currentConf);
+ Matcher userMatcher = Pattern.compile(ChangePropertiesConst.USER_REGEX).matcher(currentConf);
List<String> secrets = new ArrayList<>();
+ List<String> users = new ArrayList<>();
String confWithReplacedSecretConf = removeLicence(currentConf);
- while (m.find()) {
- String secret = m.group().split(":")[ChangePropertiesConst.DEFAULT_VALUE_PLACE];
+ while (passMatcher.find()) {
+ String secret = passMatcher.group().split(":")[ChangePropertiesConst.DEFAULT_VALUE_PLACE];
if (!(secret.isEmpty() || secret.trim().isEmpty()))
secrets.add(secret);
}
+ while (userMatcher.find()) {
+ String user = userMatcher.group().split(":")[ChangePropertiesConst.DEFAULT_VALUE_PLACE];
+ if (!(user.isEmpty() || user.trim().isEmpty()))
+ users.add(user);
+ }
for (String secret : secrets) {
confWithReplacedSecretConf = confWithReplacedSecretConf.replace(secret, ChangePropertiesConst.SECRET_REPLACEMENT_FORMAT);
}
+ for (String user : users) {
+ confWithReplacedSecretConf = confWithReplacedSecretConf.replace(user, ChangePropertiesConst.SECRET_REPLACEMENT_FORMAT);
+ }
return confWithReplacedSecretConf;
}