Skip to content

Commit 51fdcf8

Browse files
intrigus-lgtmaschackmull
authored andcommitted
Apply suggestions from code review
Co-authored-by: Anders Schack-Mulligen <[email protected]>
1 parent 6f217d3 commit 51fdcf8

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

java/ql/src/Security/CWE/CWE-295/InsecureTrustManager.ql

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import semmle.code.java.security.Encryption
1818
import DataFlow::PathGraph
1919

2020
/**
21-
* Models an insecure `X509TrustManager`.
21+
* An insecure `X509TrustManager`.
2222
* An `X509TrustManager` is considered insecure if it never throws a `CertificateException`
2323
* thereby accepting any certificate as valid.
2424
*/
@@ -40,13 +40,16 @@ private class CertificateException extends RefType {
4040

4141
/**
4242
* 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
4545
* - `m` calls a method declared to throw a `CertificateException`, but for which no source is available
4646
*/
4747
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+
)
5053
or
5154
exists(Method otherMethod | m.polyCalls(otherMethod) |
5255
mayThrowCertificateException(otherMethod)
@@ -57,7 +60,7 @@ private predicate mayThrowCertificateException(Method m) {
5760
}
5861

5962
/**
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.
6164
*/
6265
class InsecureTrustManagerConfiguration extends TaintTracking::Configuration {
6366
InsecureTrustManagerConfiguration() { this = "InsecureTrustManagerConfiguration" }

0 commit comments

Comments
 (0)