@@ -267,28 +267,34 @@ public static boolean getCaptchaStatus() {
267267 }
268268
269269 public static String maskOutSensitiveInfo (String strInput ) {
270- if (ConfigManager .IsDebugEnabled ())
271- return strInput ;
272-
273270 if (strInput == null || strInput .isBlank ())
274271 return strInput ;
275272
276273 String maskedInput = strInput ;
277274
278- String [] sensitiveKeys = {
279- "password" , "secret" , "token" , "key" , "private" , "client_secret" , "authclientsecret"
280- };
281-
282- for (String key : sensitiveKeys ) {
283- String regex = "(?i)(\" [^\" ]*" + key + "[^\" ]*\" \\ s*:\\ s*\" )(.*?)(\" )" ;
284- maskedInput = maskedInput .replaceAll (regex , "$1***** MASKED *****$3" );
275+ // In debug mode skip key/token masking so full payloads remain visible,
276+ // but always mask large binary payloads to keep the report size manageable.
277+ if (!ConfigManager .IsDebugEnabled ()) {
278+ String [] sensitiveKeys = {
279+ "password" , "secret" , "token" , "key" , "private" , "client_secret" , "authclientsecret"
280+ };
281+ for (String key : sensitiveKeys ) {
282+ String regex = "(?i)(\" [^\" ]*" + key + "[^\" ]*\" \\ s*:\\ s*\" )(.*?)(\" )" ;
283+ maskedInput = maskedInput .replaceAll (regex , "$1***** MASKED *****$3" );
284+ }
285+ Pattern INDIVIDUAL_BIOMETRICS_PATTERN = Pattern .compile (
286+ "\" category\" \\ s*:\\ s*\" individualBiometrics\" \\ s*,\\ s*\" value\" \\ s*:\\ s*\" (.*?)\" " );
287+ Matcher biometricsMatcher = INDIVIDUAL_BIOMETRICS_PATTERN .matcher (maskedInput );
288+ maskedInput = biometricsMatcher .replaceAll (
289+ "\" category\" : \" individualBiometrics\" , \" value\" : \" ***** MASKED *****\" " );
285290 }
286291
287- Pattern INDIVIDUAL_BIOMETRICS_PATTERN = Pattern .compile (
288- "\" category\" \\ s*:\\ s*\" individualBiometrics\" \\ s*,\\ s*\" value\" \\ s*:\\ s*\" (.*?)\" " );
289- Matcher biometricsMatcher = INDIVIDUAL_BIOMETRICS_PATTERN .matcher (maskedInput );
290- maskedInput = biometricsMatcher .replaceAll (
291- "\" category\" : \" individualBiometrics\" , \" value\" : \" ***** MASKED *****\" " );
292+ // Always mask large base64/binary payloads regardless of debug mode --
293+ // cbeff biometrics, document files, encrypted identity data.
294+ maskedInput = maskedInput .replaceAll ("\" value\" \\ s*:\\ s*\" ([^\" ]{200,})\" " ,
295+ "\" value\" : \" ***** MASKED *****\" " );
296+ maskedInput = maskedInput .replaceAll ("\" data\" \\ s*:\\ s*\" ([^\" ]{200,})\" " ,
297+ "\" data\" : \" ***** MASKED *****\" " );
292298
293299 return maskedInput ;
294300 }
@@ -335,7 +341,7 @@ public static void reportResponse(String responseHeader, String url, Response re
335341 + GlobalConstants .REPORT_RESPONSE_SUFFIX );
336342 } else {
337343 Reporter .log (GlobalConstants .REPORT_RESPONSE_PREFIX + GlobalConstants .REPORT_RESPONSE_BODY + formattedHeader
338- + ReportUtil .getTextAreaJsonMsgHtml (response .asString ()) + GlobalConstants .REPORT_RESPONSE_SUFFIX );
344+ + ReportUtil .getTextAreaJsonMsgHtml (maskOutSensitiveInfo ( response .asString () )) + GlobalConstants .REPORT_RESPONSE_SUFFIX );
339345 }
340346 }
341347 public static void reportResponseHeader (String responseHeader , String url ) {
@@ -352,12 +358,13 @@ public static void reportResponse(String responseHeader, String url, String resp
352358 public static void reportResponse (String responseHeader , String url , String response , boolean formatResponse ) {
353359 String formattedHeader = ReportUtil .getTextAreaForHeaders (responseHeader );
354360
361+ String maskedResponse = maskOutSensitiveInfo (response );
355362 if (formatResponse )
356363 Reporter .log (GlobalConstants .REPORT_RESPONSE_PREFIX + GlobalConstants .REPORT_RESPONSE_BODY + formattedHeader
357- + ReportUtil .getTextAreaJsonMsgHtml (response ) + GlobalConstants .REPORT_RESPONSE_SUFFIX );
364+ + ReportUtil .getTextAreaJsonMsgHtml (maskedResponse ) + GlobalConstants .REPORT_RESPONSE_SUFFIX );
358365 else
359366 Reporter .log (GlobalConstants .REPORT_RESPONSE_PREFIX + GlobalConstants .REPORT_RESPONSE_BODY + responseHeader
360- + response + GlobalConstants .REPORT_RESPONSE_SUFFIX );
367+ + maskedResponse + GlobalConstants .REPORT_RESPONSE_SUFFIX );
361368 }
362369
363370 // Hashes a string using SHA-256
0 commit comments