зеркало из https://github.com/github/codeql.git
Refactor UnsafeCertTrustQuery
This commit is contained in:
Родитель
a040ff6997
Коммит
ac8dec740a
|
@ -6,9 +6,11 @@ import semmle.code.java.security.UnsafeCertTrust
|
||||||
import semmle.code.java.security.Encryption
|
import semmle.code.java.security.Encryption
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* DEPRECATED: Use `SslEndpointIdentificationFlow` instead.
|
||||||
|
*
|
||||||
* A taint flow configuration for SSL connections created without a proper certificate trust configuration.
|
* A taint flow configuration for SSL connections created without a proper certificate trust configuration.
|
||||||
*/
|
*/
|
||||||
class SslEndpointIdentificationFlowConfig extends TaintTracking::Configuration {
|
deprecated class SslEndpointIdentificationFlowConfig extends TaintTracking::Configuration {
|
||||||
SslEndpointIdentificationFlowConfig() { this = "SslEndpointIdentificationFlowConfig" }
|
SslEndpointIdentificationFlowConfig() { this = "SslEndpointIdentificationFlowConfig" }
|
||||||
|
|
||||||
override predicate isSource(DataFlow::Node source) { source instanceof SslConnectionInit }
|
override predicate isSource(DataFlow::Node source) { source instanceof SslConnectionInit }
|
||||||
|
@ -20,30 +22,38 @@ class SslEndpointIdentificationFlowConfig extends TaintTracking::Configuration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private module SslEndpointIdentificationFlowConfig implements DataFlow::ConfigSig {
|
||||||
|
predicate isSource(DataFlow::Node source) { source instanceof SslConnectionInit }
|
||||||
|
|
||||||
|
predicate isSink(DataFlow::Node sink) { sink instanceof SslConnectionCreation }
|
||||||
|
|
||||||
|
predicate isBarrier(DataFlow::Node sanitizer) { sanitizer instanceof SslUnsafeCertTrustSanitizer }
|
||||||
|
}
|
||||||
|
|
||||||
|
module SslEndpointIdentificationFlow = TaintTracking::Global<SslEndpointIdentificationFlowConfig>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An SSL object that was assigned a safe `SSLParameters` object and can be considered safe.
|
* An SSL object that was assigned a safe `SSLParameters` object and can be considered safe.
|
||||||
*/
|
*/
|
||||||
private class SslConnectionWithSafeSslParameters extends SslUnsafeCertTrustSanitizer {
|
private class SslConnectionWithSafeSslParameters extends SslUnsafeCertTrustSanitizer {
|
||||||
SslConnectionWithSafeSslParameters() {
|
SslConnectionWithSafeSslParameters() {
|
||||||
exists(SafeSslParametersFlowConfig config, DataFlow::Node safe, DataFlow::Node sanitizer |
|
exists(DataFlow::Node safe, DataFlow::Node sanitizer |
|
||||||
config.hasFlowTo(safe) and
|
SafeSslParametersFlow::flowTo(safe) and
|
||||||
sanitizer = DataFlow::exprNode(safe.asExpr().(Argument).getCall().getQualifier()) and
|
sanitizer = DataFlow::exprNode(safe.asExpr().(Argument).getCall().getQualifier()) and
|
||||||
DataFlow::localFlow(sanitizer, this)
|
DataFlow::localFlow(sanitizer, this)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SafeSslParametersFlowConfig extends DataFlow2::Configuration {
|
private module SafeSslParametersFlowConfig implements DataFlow::ConfigSig {
|
||||||
SafeSslParametersFlowConfig() { this = "SafeSslParametersFlowConfig" }
|
predicate isSource(DataFlow::Node source) {
|
||||||
|
|
||||||
override predicate isSource(DataFlow::Node source) {
|
|
||||||
exists(MethodAccess ma |
|
exists(MethodAccess ma |
|
||||||
ma instanceof SafeSetEndpointIdentificationAlgorithm and
|
ma instanceof SafeSetEndpointIdentificationAlgorithm and
|
||||||
DataFlow::getInstanceArgument(ma) = source.(DataFlow::PostUpdateNode).getPreUpdateNode()
|
DataFlow::getInstanceArgument(ma) = source.(DataFlow::PostUpdateNode).getPreUpdateNode()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override predicate isSink(DataFlow::Node sink) {
|
predicate isSink(DataFlow::Node sink) {
|
||||||
exists(MethodAccess ma, RefType t | t instanceof SslSocket or t instanceof SslEngine |
|
exists(MethodAccess ma, RefType t | t instanceof SslSocket or t instanceof SslEngine |
|
||||||
ma.getMethod().hasName("setSSLParameters") and
|
ma.getMethod().hasName("setSSLParameters") and
|
||||||
ma.getMethod().getDeclaringType().getAnAncestor() = t and
|
ma.getMethod().getDeclaringType().getAnAncestor() = t and
|
||||||
|
@ -52,6 +62,8 @@ private class SafeSslParametersFlowConfig extends DataFlow2::Configuration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private module SafeSslParametersFlow = DataFlow::Global<SafeSslParametersFlowConfig>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A call to `SSLParameters.setEndpointIdentificationAlgorithm` with a non-null and non-empty parameter.
|
* A call to `SSLParameters.setEndpointIdentificationAlgorithm` with a non-null and non-empty parameter.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,7 +18,5 @@ import semmle.code.java.security.UnsafeCertTrustQuery
|
||||||
from Expr unsafeTrust
|
from Expr unsafeTrust
|
||||||
where
|
where
|
||||||
unsafeTrust instanceof RabbitMQEnableHostnameVerificationNotSet or
|
unsafeTrust instanceof RabbitMQEnableHostnameVerificationNotSet or
|
||||||
exists(SslEndpointIdentificationFlowConfig config |
|
SslEndpointIdentificationFlow::flowTo(DataFlow::exprNode(unsafeTrust))
|
||||||
config.hasFlowTo(DataFlow::exprNode(unsafeTrust))
|
|
||||||
)
|
|
||||||
select unsafeTrust, "Unsafe configuration of trusted certificates."
|
select unsafeTrust, "Unsafe configuration of trusted certificates."
|
||||||
|
|
|
@ -12,9 +12,7 @@ class UnsafeCertTrustTest extends InlineExpectationsTest {
|
||||||
exists(Expr unsafeTrust |
|
exists(Expr unsafeTrust |
|
||||||
unsafeTrust instanceof RabbitMQEnableHostnameVerificationNotSet
|
unsafeTrust instanceof RabbitMQEnableHostnameVerificationNotSet
|
||||||
or
|
or
|
||||||
exists(SslEndpointIdentificationFlowConfig config |
|
SslEndpointIdentificationFlow::flowTo(DataFlow::exprNode(unsafeTrust))
|
||||||
config.hasFlowTo(DataFlow::exprNode(unsafeTrust))
|
|
||||||
)
|
|
||||||
|
|
|
|
||||||
unsafeTrust.getLocation() = location and
|
unsafeTrust.getLocation() = location and
|
||||||
element = unsafeTrust.toString() and
|
element = unsafeTrust.toString() and
|
||||||
|
|
Загрузка…
Ссылка в новой задаче