Use InlineExpectationsTest

This commit is contained in:
Tony Torralba
2021-06-22 10:08:26 +02:00
parent 02d0fa9188
commit e43fff2d30
7 changed files with 78 additions and 29 deletions

View File

@@ -34,8 +34,9 @@ class SslConnectionCreation extends DataFlow::Node {
// calls to SocketFactory.createSocket with parameters immediately create the connection
exists(MethodAccess ma, Method m |
ma.getMethod() = m and
m instanceof CreateSocket and
m.getNumberOfParameters() > 0
m instanceof CreateSocketMethod and
m.getNumberOfParameters() > 0 and
isSslSocket(ma)
|
this.asExpr() = ma
)
@@ -55,6 +56,20 @@ class SslConnectionWithSafeSslParameters extends DataFlow::Node {
}
}
/**
* Holds if the return value of `createSocket` is cast to `SSLSocket`
* or the qualifier of `createSocket` is an instance of `SSLSocketFactory`.
*/
private predicate isSslSocket(MethodAccess createSocket) {
exists(Variable ssl, CastExpr ce |
ce.getExpr() = createSocket and
ce.getControlFlowNode().getASuccessor().(VariableAssign).getDestVar() = ssl and
ssl.getType() instanceof SSLSocket
)
or
createSocket.getQualifier().getType().(RefType).getASupertype*() instanceof SSLSocketFactory
}
private class SafeSslParametersFlowConfig extends DataFlow2::Configuration {
SafeSslParametersFlowConfig() { this = "SafeSslParametersFlowConfig" }
@@ -85,7 +100,7 @@ private class SafeSetEndpointIdentificationAlgorithm extends MethodAccess {
/**
* A call to the method `useSslProtocol` on an instance of `com.rabbitmq.client.ConnectionFactory`
* that doesn't have `enableHostnameVerification` set.
* that doesn't set `enableHostnameVerification`.
*/
class RabbitMQEnableHostnameVerificationNotSet extends MethodAccess {
RabbitMQEnableHostnameVerificationNotSet() {