Skip to content

Commit d6ffea7

Browse files
nidhi-frSoteria Kommathoty
andauthored
Updated the code not to print the passwords in debug logs. (#321)
Co-authored-by: Soteria Kommathoty <soteria.kommathoty.ext@ericsson.com>
1 parent 575fca2 commit d6ffea7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/com/ericsson/ei/frontend/EIRequestsController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,20 @@ public ResponseEntity<String> postRequests(Model model, HttpServletRequest incom
112112
}
113113
String requestBody = "";
114114

115+
115116
try {
116117
// Replaces \r with nothing in case system is run on windows \r may disturb
117118
// tests. \r does not affect EI functionality.
118119
requestBody = incomingRequest.getReader()
119120
.lines()
120121
.collect(Collectors.joining(System.lineSeparator()))
121122
.replaceAll("(\\r)", "");
123+
122124
} catch (IOException e) {
123125
LOG.error("Forward Request Errors: " + e);
124126
}
125127

126-
LOG.debug("Input request JSON content to be forwarded:\n" + requestBody);
128+
LOG.debug("Input request JSON content to be forwarded:\n" + requestBody.replaceAll("\"password\":\"[^\"]*\"", "\"password\":\"\""));
127129

128130
HttpEntity inputReqJsonEntity = new ByteArrayEntity(requestBody.getBytes());
129131

@@ -167,7 +169,7 @@ public ResponseEntity<String> putRequests(Model model, HttpServletRequest incomi
167169
LOG.error("Forward Request Errors: " + e);
168170
}
169171

170-
LOG.debug("Input request JSON content to be forwarded:\n" + requestBody);
172+
LOG.debug("Input request JSON content to be forwarded:\n" + requestBody.replaceAll("\"password\":\"[^\"]*\"", "\"password\":\"\""));
171173

172174
HttpEntity inputReqJsonEntity = new ByteArrayEntity(requestBody.getBytes());
173175

0 commit comments

Comments
 (0)