mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Handle a specific pass-by-reference flow issue
This commit is contained in:
@@ -97,7 +97,7 @@ private class SafeSslParametersFlowConfig extends DataFlow2::Configuration {
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(MethodAccess ma |
|
||||
ma instanceof SafeSetEndpointIdentificationAlgorithm and
|
||||
ma.getQualifier() = source.asExpr()
|
||||
DataFlow::getInstanceArgument(ma) = source.(DataFlow::PostUpdateNode).getPreUpdateNode()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,20 @@ public class UnsafeCertTrustTest {
|
||||
socket.getOutputStream(); // Safe
|
||||
}
|
||||
|
||||
public void testSSLSocketEndpointIdSafeWithModificationByReference() throws Exception {
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
SSLSocketFactory socketFactory = sslContext.getSocketFactory();
|
||||
SSLSocket socket = (SSLSocket) socketFactory.createSocket();
|
||||
SSLParameters sslParameters = socket.getSSLParameters();
|
||||
onSetSSLParameters(sslParameters);
|
||||
socket.setSSLParameters(sslParameters);
|
||||
socket.getOutputStream(); // Safe
|
||||
}
|
||||
|
||||
private void onSetSSLParameters(SSLParameters sslParameters) {
|
||||
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
|
||||
}
|
||||
|
||||
public void testSocketEndpointIdNotSet() throws Exception {
|
||||
SocketFactory socketFactory = SocketFactory.getDefault();
|
||||
Socket socket = socketFactory.createSocket("www.example.com", 80);
|
||||
|
||||
Reference in New Issue
Block a user