You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1580,6 +1583,52 @@ public static boolean isGZIPCompressedDataSafe(byte[] compressedBytes, long maxC
1580
1583
} catch (Exceptione) {
1581
1584
isSafe = false;
1582
1585
}
1586
+
1583
1587
returnisSafe;
1584
1588
}
1589
+
1590
+
/**
1591
+
* Process a string, intended to be written in a log, to remove as much as possible information that can lead to an exposure to a log injection vulnerability.<br><br>
1592
+
* <b>Log injection</b> is also called <b>log forging</b>.<br><br>
1593
+
* The following information are removed:
1594
+
* <ul>
1595
+
* <li>Characters: Carriage Return (CR), Linefeed (LF) and Tabulation (TAB).</li>
1596
+
* <li>Leading and trailing spaces.</li>
1597
+
* <li>Any HTML tags.</li>
1598
+
* </ul><br><br>
1599
+
* A parameter is also used to limit the maximum length of the sanitized message.
1600
+
* To remove any HTML tags, the OWASP project <a href="https://owasp.org/www-project-java-html-sanitizer/">Java HTML Sanitizer</a> is leveraged.<br>
1601
+
* I delegated such removal to a dedicated library to prevent missing of edge cases as well as potential bypasses.
1602
+
*
1603
+
* @param message The original string message intended to be written in a log.
1604
+
* @param maxMessageLength The maximum number of characters after which the sanitized message must be truncated. If inferior to 1 then default to the value of 500.
0 commit comments