Skip to content

Commit 9e93aec

Browse files
committed
Add spurious test case
1 parent 19d1a78 commit 9e93aec

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

java/ql/test/query-tests/security/CWE-273/UnsafeCertTrustTest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,23 @@ public void testSSLSocketEndpointIdSafeWithConditionalSanitizer(boolean safe) th
122122
SSLSocket socket = (SSLSocket) socketFactory.createSocket();
123123
if (safe) {
124124
SSLParameters sslParameters = socket.getSSLParameters();
125-
onSetSSLParameters(sslParameters);
125+
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
126126
socket.setSSLParameters(sslParameters);
127127
}
128128
socket.getOutputStream(); // Safe
129129
}
130130

131+
public void testSSLSocketEndpointIdSafeWithSanitizerInCast(boolean safe) throws Exception {
132+
SSLContext sslContext = SSLContext.getInstance("TLS");
133+
SSLSocketFactory socketFactory = sslContext.getSocketFactory();
134+
Socket socket = socketFactory.createSocket();
135+
SSLSocket sslSocket = (SSLSocket) socket;
136+
SSLParameters sslParameters = sslSocket.getSSLParameters();
137+
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
138+
sslSocket.setSSLParameters(sslParameters);
139+
socket.getOutputStream(); // $ SPURIOUS: hasUnsafeCertTrust
140+
}
141+
131142
public void testSocketEndpointIdNotSet() throws Exception {
132143
SocketFactory socketFactory = SocketFactory.getDefault();
133144
Socket socket = socketFactory.createSocket("www.example.com", 80);

0 commit comments

Comments
 (0)