From 3a64cdbca18a45a1e7c7a49f1bf18036294ada71 Mon Sep 17 00:00:00 2001 From: Kunal Patel Date: Tue, 24 Nov 2026 15:16:19 -0500 Subject: [PATCH 1/3] fix(linotp): check the LinOTP server host name unless linotp_skip_hostname_verify is set --- src/prerna/util/linotp/LinOTPUtil.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/prerna/util/linotp/LinOTPUtil.java b/src/prerna/util/linotp/LinOTPUtil.java index bf9280d0ef..421c8c270f 100644 --- a/src/prerna/util/linotp/LinOTPUtil.java +++ b/src/prerna/util/linotp/LinOTPUtil.java @@ -82,6 +82,17 @@ public class LinOTPUtil { private static final Logger classLogger = LogManager.getLogger(LinOTPUtil.class); + private static final String SKIP_HOSTNAME_VERIFY_KEY = "linotp_skip_hostname_verify"; + + // host names are checked unless the admin opts out in social.properties + private static CloseableHttpClient newClient(SocialPropertiesUtil socialData) { + if (Boolean.parseBoolean(socialData.getProperty(SKIP_HOSTNAME_VERIFY_KEY, "false"))) { + classLogger.warn("{} is true so the LinOTP server's host name is not checked", SKIP_HOSTNAME_VERIFY_KEY); + return HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build(); + } + return HttpClients.createDefault(); + } + /** * * @param request @@ -184,8 +195,7 @@ public static LinOTPResponse login(HttpServletRequest request) throws ClientProt // first, request for challenge request using user pin // Create HTTP request via ssl port (https) and pass post parameters - try (CloseableHttpClient httpclient = HttpClients.custom() - .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()) { + try (CloseableHttpClient httpclient = newClient(socialData)) { HttpPost httpPost = new HttpPost(requestURL); List nvps = new ArrayList(); nvps.add(new BasicNameValuePair("user", username)); @@ -259,8 +269,7 @@ public static LinOTPResponse login(HttpServletRequest request) throws ClientProt } else { // subsequent challenge request with otp // Create HTTP request via ssl port (https) and pass post parameters - try (CloseableHttpClient httpclient = HttpClients.custom() - .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build()) { + try (CloseableHttpClient httpclient = newClient(socialData)) { HttpPost httpPost = new HttpPost(requestURL); HttpSession session = request.getSession(); username = (String) session.getAttribute(LINOTP_USERNAME); @@ -445,8 +454,7 @@ private static LinOTPResponse resetCounter(LinOTPResponse linotpResponse, String context.setCookieStore(cstore); // Create HTTP request via ssl port (https) and pass post parameters - try (CloseableHttpClient httpclient = HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) - .build()) { + try (CloseableHttpClient httpclient = newClient(socialData)) { HttpPost httpPost = new HttpPost(requestURL); List nvps = new ArrayList(); From 9157a8f1ad8f3cf936fdd7271f4bddd09d79545f Mon Sep 17 00:00:00 2001 From: Kunal Patel Date: Tue, 24 Nov 2026 16:12:24 -0500 Subject: [PATCH 2/3] fix(linotp): trim linotp_skip_hostname_verify before parsing --- src/prerna/util/linotp/LinOTPUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prerna/util/linotp/LinOTPUtil.java b/src/prerna/util/linotp/LinOTPUtil.java index 421c8c270f..1952bae1c1 100644 --- a/src/prerna/util/linotp/LinOTPUtil.java +++ b/src/prerna/util/linotp/LinOTPUtil.java @@ -86,7 +86,7 @@ public class LinOTPUtil { // host names are checked unless the admin opts out in social.properties private static CloseableHttpClient newClient(SocialPropertiesUtil socialData) { - if (Boolean.parseBoolean(socialData.getProperty(SKIP_HOSTNAME_VERIFY_KEY, "false"))) { + if (Boolean.parseBoolean(socialData.getProperty(SKIP_HOSTNAME_VERIFY_KEY, "false").trim())) { classLogger.warn("{} is true so the LinOTP server's host name is not checked", SKIP_HOSTNAME_VERIFY_KEY); return HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build(); } From 850b16e1a082f4d7d1ca7dc764fa9d54af3b6eaa Mon Sep 17 00:00:00 2001 From: Kunal Patel Date: Tue, 24 Nov 2026 16:20:03 -0500 Subject: [PATCH 3/3] chore(snyk): exclude test code from Snyk scans --- .snyk | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .snyk diff --git a/.snyk b/.snyk new file mode 100644 index 0000000000..93956804bf --- /dev/null +++ b/.snyk @@ -0,0 +1,8 @@ +# Snyk (https://snyk.io) policy file +version: v1.25.0 +# test code is not shipped; keep its fixtures out of Snyk Code results +exclude: + global: + - test/** + - py/**/tests/** + - py/testing/**