@@ -18,7 +18,7 @@ import semmle.code.java.security.Encryption
18
18
import DataFlow:: PathGraph
19
19
20
20
/**
21
- * Models an insecure `X509TrustManager`.
21
+ * An insecure `X509TrustManager`.
22
22
* An `X509TrustManager` is considered insecure if it never throws a `CertificateException`
23
23
* thereby accepting any certificate as valid.
24
24
*/
@@ -40,13 +40,16 @@ private class CertificateException extends RefType {
40
40
41
41
/**
42
42
* Holds if:
43
- * - `m` may `throw` a `CertificateException`
44
- * - `m` calls another method that may throw
43
+ * - `m` may `throw` a `CertificateException`, or
44
+ * - `m` calls another method that may throw, or
45
45
* - `m` calls a method declared to throw a `CertificateException`, but for which no source is available
46
46
*/
47
47
private predicate mayThrowCertificateException ( Method m ) {
48
- m .getBody ( ) .getAChild * ( ) .( ThrowStmt ) .getThrownExceptionType ( ) .getASupertype * ( ) instanceof
49
- CertificateException
48
+ exists ( ThrowStmt throwStmt |
49
+ throwStmt .getThrownExceptionType ( ) .getASupertype * ( ) instanceof CertificateException
50
+ |
51
+ throwStmt .getEnclosingCallable ( ) = m
52
+ )
50
53
or
51
54
exists ( Method otherMethod | m .polyCalls ( otherMethod ) |
52
55
mayThrowCertificateException ( otherMethod )
@@ -57,7 +60,7 @@ private predicate mayThrowCertificateException(Method m) {
57
60
}
58
61
59
62
/**
60
- * A configuration to model the flow of a `InsecureX509TrustManager` to an `SSLContext.init` call.
63
+ * A configuration to model the flow of an `InsecureX509TrustManager` to an `SSLContext.init` call.
61
64
*/
62
65
class InsecureTrustManagerConfiguration extends TaintTracking:: Configuration {
63
66
InsecureTrustManagerConfiguration ( ) { this = "InsecureTrustManagerConfiguration" }
0 commit comments