openvidu-server: hide secret properties on log

pull/761/head
pabloFuente 2022-11-11 13:37:45 +01:00
parent 286891c6fc
commit 8aad8948bf
4 changed files with 32 additions and 20 deletions

View File

@ -340,6 +340,9 @@ public class OpenViduServer implements JsonRpcConfigurer {
for (String property : configPropNames) {
String value = CONFIG_PROPS.get(property);
if (config.getSecretProperties().contains(property)) {
value = config.hideSecret(value, "*", 0);
}
msg += " * " + config.getPropertyName(property) + "=" + (value == null ? "" : value) + "\n";
}
msg += "\n\n";

View File

@ -115,6 +115,8 @@ public class OpenviduConfig {
private List<String> userConfigProps;
protected final Set<String> secretProps = new HashSet<>(Arrays.asList("OPENVIDU_SECRET"));
protected Map<String, ?> propertiesSource;
public static final String DEFAULT_RECORDING_IMAGE_REPO = "openvidu/openvidu-recording";
@ -487,6 +489,10 @@ public class OpenviduConfig {
public Map<String, String> getConfigProps() {
return configProps;
}
public Set<String> getSecretProperties() {
return secretProps;
}
public List<String> getUserProperties() {
return userConfigProps;
@ -1255,4 +1261,11 @@ public class OpenviduConfig {
return builder;
}
public String hideSecret(final String originalString, String charToReplace, int numberOfVisibleChars) {
String hiddenString = originalString.substring(originalString.length() - numberOfVisibleChars,
originalString.length());
hiddenString = charToReplace.repeat(originalString.length() - numberOfVisibleChars) + hiddenString;
return hiddenString;
}
}

View File

@ -152,11 +152,4 @@ public class ConfigRestController {
return new ResponseEntity<>(json.toString(), RestUtils.getResponseHeaders(), HttpStatus.OK);
}
protected String hideSecret(final String originalString, String charToReplace, int numberOfVisibleChars) {
String hiddenString = originalString.substring(originalString.length() - numberOfVisibleChars,
originalString.length());
hiddenString = charToReplace.repeat(originalString.length() - numberOfVisibleChars) + hiddenString;
return hiddenString;
}
}

View File

@ -742,10 +742,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
}
@Test
@DisplayName("Speech To Text disabled test")
void speechToTextDisabledTest() throws Exception {
@DisplayName("Service disabled STT test")
void serviceDisabledSttTest() throws Exception {
log.info("Speech To Text disabled test");
log.info("Service disabled STT test");
restartOpenViduServerIfNecessary(false, null, "disabled");
@ -776,10 +776,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
}
@Test
@DisplayName("Speech To Text simple transcription test")
void speechToTextSimpleTranscriptionTest() throws Exception {
@DisplayName("Simple transcription STT test")
void simpleTranscriptionSttTest() throws Exception {
log.info("Speech To Text simple transcription test");
log.info("Simple transcription STT test");
restartOpenViduServerIfNecessary(false, null, "vosk");
@ -852,10 +852,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
}
@Test
@DisplayName("Speech To Text close session test")
void speechToTextCloseSessionTest() throws Exception {
@DisplayName("Close session STT test")
void closeSessionSttTest() throws Exception {
log.info("Speech To Text close session");
log.info("Close session STT test");
restartOpenViduServerIfNecessary(false, null, "vosk");
@ -907,10 +907,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
}
@Test
@DisplayName("Speech To Text expected errors test")
void speechToTextExpectedErrorsTest() throws Exception {
@DisplayName("Expected errors STT test")
void expectedErrorsSttTest() throws Exception {
log.info("Speech To Text expected errors");
log.info("Expected errors STT test");
restartOpenViduServerIfNecessary(false, null, "vosk");
@ -1541,7 +1541,10 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
protected void restartOpenViduServerIfNecessary(Boolean wantedNetworkQuality, Integer wantedNetworkQualityInterval,
String wantedSpeechToText) {
try {
wantedSpeechToText = "azure";
try {
CustomHttpClient restClient = new CustomHttpClient(OPENVIDU_URL, "OPENVIDUAPP", OPENVIDU_SECRET);
JsonObject config = restClient.rest(HttpMethod.GET, "/openvidu/api/config", 200);