Skip to content

Commit ede822f

Browse files
committed
Minor refactoring to suppress CodeQL flags
1 parent d008766 commit ede822f

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/DefaultHttpClientManagedIdentity.java

+8-13
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,14 @@
2929
*/
3030
class DefaultHttpClientManagedIdentity extends DefaultHttpClient {
3131

32-
// CodeQL [SM03767] False positive: in addTrustedCertificateThumbprint() we create a TrustManager that only trusts a certificate with specified thumbprint.
33-
public static final HostnameVerifier ALL_HOSTS_ACCEPT_HOSTNAME_VERIFIER;
34-
35-
static {
36-
ALL_HOSTS_ACCEPT_HOSTNAME_VERIFIER = new HostnameVerifier() {
37-
@SuppressWarnings("BadHostnameVerifier")
38-
@Override
39-
public boolean verify(String hostname, SSLSession session) {
40-
return true;
41-
}
42-
};
43-
}
32+
// CodeQL [SM03767] False positive: in addTrustedCertificateThumbprint() we create a TrustManager that only trusts a certificate with a specific thumbprint.
33+
public static final HostnameVerifier ALL_HOSTS_ACCEPT_HOSTNAME_VERIFIER = new HostnameVerifier() {
34+
@SuppressWarnings("BadHostnameVerifier")
35+
@Override
36+
public boolean verify(String hostname, SSLSession session) {
37+
return true; // Allow all hostnames, however the TrustManager created later on will only trust a certificate with a specific thumbprint.
38+
}
39+
};
4440

4541
DefaultHttpClientManagedIdentity(Proxy proxy, SSLSocketFactory sslSocketFactory, Integer connectTimeout, Integer readTimeout) {
4642
super(proxy, sslSocketFactory, connectTimeout, readTimeout);
@@ -164,5 +160,4 @@ private static String extractCertificateThumbprint(Certificate certificate) {
164160
throw new MsalClientException("NoSuchAlgorithmException when extracting certificate thumbprint: ", e.getMessage());
165161
}
166162
}
167-
168163
}

msal4j-sdk/src/samples/msal-b2c-web-sample/src/main/java/com/microsoft/azure/msalwebsample/CookieHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void removeStateNonceCookies(HttpServletResponse httpResponse){
3232
Cookie stateCookie = new Cookie(MSAL_WEB_APP_STATE_COOKIE, "");
3333
stateCookie.setMaxAge(0);
3434

35-
// CodeQL [java/insecure-cookie]: Suppressing CodeQL warning since this is just a sample
35+
// CodeQL [SM00710]: CodeQL flagged this as the 'secure' flag was not set on this cookie, however this is just a sample to help with manual testing.
3636
httpResponse.addCookie(stateCookie);
3737

3838
Cookie nonceCookie = new Cookie(MSAL_WEB_APP_NONCE_COOKIE, "");

0 commit comments

Comments
 (0)