Skip to content

Commit f52e438

Browse files
intrigus-lgtmsmowton
authored andcommitted
Java: Apply suggestions from code review
Co-authored-by: Chris Smowton <[email protected]>
1 parent 592fd1e commit f52e438

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void checkClientTrusted(X509Certificate[] chain, String authType) throws
2525
File certificateFile = new File("path/to/self-signed-certificate");
2626
// Create a `KeyStore` with default type
2727
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
28-
// This causes `keyStore` to be empty
28+
// `keyStore` is initially empty
2929
keyStore.load(null, null);
3030
X509Certificate generatedCertificate;
3131
try (InputStream cert = new FileInputStream(certificateFile)) {
@@ -36,7 +36,7 @@ public void checkClientTrusted(X509Certificate[] chain, String authType) throws
3636
keyStore.setCertificateEntry(certificateFile.getName(), generatedCertificate);
3737
// Get default `TrustManagerFactory`
3838
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
39-
// Use it with our modified key store that trusts our self-signed certificate
39+
// Use it with our key store that trusts our self-signed certificate
4040
tmf.init(keyStore);
4141
TrustManager[] trustManagers = tmf.getTrustManagers();
4242
context.init(null, trustManagers, null); // GOOD, we are not using a custom `TrustManager` but instead have

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @name Everything trusting `TrustManager`
2+
* @name `TrustManager` that accepts all certificates
33
* @description Trusting all certificates allows an attacker to perform a machine-in-the-middle attack.
44
* @kind path-problem
55
* @problem.severity error

0 commit comments

Comments
 (0)