mirror of
https://github.com/Telecominfraproject/wlan-cloud-base.git
synced 2026-01-27 10:22:34 +00:00
addressed vulnerabilities reported by sonar
This commit is contained in:
@@ -118,12 +118,13 @@ public class RestTemplateConfigurationX509ClientCertAuth {
|
||||
|
||||
Principal principal = clientCertificate.getSubjectDN();
|
||||
subjectDn = principal.getName();
|
||||
|
||||
// Replace pattern-breaking characters
|
||||
subjectDn = subjectDn.replaceAll("[\n|\r|\t]", "_");
|
||||
|
||||
int startPos = subjectDn.indexOf("CN=") + "CN=".length();
|
||||
int endPos = subjectDn.indexOf(',', startPos);
|
||||
subjectDn = subjectDn.substring(startPos, endPos);
|
||||
|
||||
// Replace pattern-breaking characters
|
||||
subjectDn = subjectDn.replaceAll("[\n|\r|\t]", "_");
|
||||
|
||||
LOG.info("X509 client name {}", subjectDn);
|
||||
return sslCxt;
|
||||
|
||||
@@ -47,7 +47,6 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.codec.Hex;
|
||||
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
|
||||
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
import org.springframework.security.web.authentication.Http403ForbiddenEntryPoint;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.telecominfraproject.wlan.core.server.webconfig;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@@ -23,6 +25,8 @@ public class CommonControllerAdvice {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CommonControllerAdvice.class);
|
||||
|
||||
private static Pattern securityRepacementRegexPattern = Pattern.compile("[\n|\r|\t]");
|
||||
|
||||
/**
|
||||
* Custom exception handler, it will be applied to all methods (both sync
|
||||
* and async) on all controllers
|
||||
@@ -41,7 +45,7 @@ public class CommonControllerAdvice {
|
||||
// String, String)
|
||||
StringBuilder msg = new StringBuilder();
|
||||
// Replace pattern-breaking characters
|
||||
msg.append(request.getRequestURI().replaceAll("[\n|\r|\t]", "_"));
|
||||
msg.append(securityRepacementRegexPattern.matcher(request.getRequestURI()).replaceAll( "_"));
|
||||
|
||||
String queryString = request.getQueryString();
|
||||
if (queryString != null) {
|
||||
@@ -60,7 +64,8 @@ public class CommonControllerAdvice {
|
||||
}
|
||||
String user = request.getRemoteUser();
|
||||
if (user != null) {
|
||||
msg.append(";user=").append(user);
|
||||
// Replace pattern-breaking characters
|
||||
msg.append(";user=").append(securityRepacementRegexPattern.matcher(user).replaceAll( "_"));
|
||||
}
|
||||
|
||||
String requestDetails = msg.toString();
|
||||
|
||||
Reference in New Issue
Block a user