Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapet committed Feb 5, 2024
1 parent ed6136e commit 76cde80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 13 additions & 0 deletions rules/java/lang/ssl_hostname_verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ patterns:
regex: \A(javax\.net\.ssl\.)?SSLSession\z
- variable: "TRUE"
detection: ssl_hostname_verifier_true
- pattern: |
class $<_> implements $<HOSTNAME_VERIFIER>() {
$<!>$<...>$<_> verify(String $<_>, $<SSL_SESSION> $<_>) {
return $<TRUE>;
}
};
filters:
- variable: HOSTNAME_VERIFIER
regex: \A(javax\.net\.ssl\.)?HostnameVerifier\z
- variable: SSL_SESSION
regex: \A(javax\.net\.ssl\.)?SSLSession\z
- variable: "TRUE"
detection: ssl_hostname_verifier_true
auxiliary:
- id: ssl_hostname_verifier_allow_all_hostname_verifier
patterns:
Expand Down
5 changes: 2 additions & 3 deletions tests/java/lang/ssl_hostname_verifier/testdata/main.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public boolean verify(String s, SSLSession sslSession) {
e.printStackTrace();
}

public class MySSLSocketFactory extends SSLSocketFactory {
public class MySocketFactorySubClass extends SSLSocketFactory {
SSLContext sslContext = SSLContext.getInstance("TLS");
public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
super(truststore);
Expand All @@ -122,6 +122,5 @@ public X509Certificate[] getAcceptedIssuers() {
}

MySocketFactorySubClass socketFactory = new MySocketFactorySubClass(trustStore);
// TODO: not catching extended cases
// bearer:expected java_lang_ssl_hostname_verifier
// TODO bearer expected java_lang_ssl_hostname_verifier
socketFactory.setHostnameVerifier(MySocketFactorySubClass.ALLOW_ALL_HOSTNAME_VERIFIER);

0 comments on commit 76cde80

Please sign in to comment.