mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge pull request #3436 from artem-smotrakov/revocation-checking
Java: Added a query for disabled certificate revocation checking
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
edges
|
||||
| DisabledRevocationChecking.java:17:5:17:8 | this <.field> [post update] [flag] : Boolean | DisabledRevocationChecking.java:21:5:21:31 | this <.method> [post update] [flag] : Boolean |
|
||||
| DisabledRevocationChecking.java:17:12:17:16 | false : Boolean | DisabledRevocationChecking.java:17:5:17:8 | this <.field> [post update] [flag] : Boolean |
|
||||
| DisabledRevocationChecking.java:21:5:21:31 | this <.method> [post update] [flag] : Boolean | DisabledRevocationChecking.java:22:5:22:31 | this <.method> [flag] : Boolean |
|
||||
| DisabledRevocationChecking.java:22:5:22:31 | this <.method> [flag] : Boolean | DisabledRevocationChecking.java:25:15:25:22 | parameter this [flag] : Boolean |
|
||||
| DisabledRevocationChecking.java:25:15:25:22 | parameter this [flag] : Boolean | DisabledRevocationChecking.java:28:33:28:36 | this <.field> [flag] : Boolean |
|
||||
| DisabledRevocationChecking.java:28:33:28:36 | this <.field> [flag] : Boolean | DisabledRevocationChecking.java:28:33:28:36 | flag |
|
||||
nodes
|
||||
| DisabledRevocationChecking.java:17:5:17:8 | this <.field> [post update] [flag] : Boolean | semmle.label | this <.field> [post update] [flag] : Boolean |
|
||||
| DisabledRevocationChecking.java:17:12:17:16 | false : Boolean | semmle.label | false : Boolean |
|
||||
| DisabledRevocationChecking.java:21:5:21:31 | this <.method> [post update] [flag] : Boolean | semmle.label | this <.method> [post update] [flag] : Boolean |
|
||||
| DisabledRevocationChecking.java:22:5:22:31 | this <.method> [flag] : Boolean | semmle.label | this <.method> [flag] : Boolean |
|
||||
| DisabledRevocationChecking.java:25:15:25:22 | parameter this [flag] : Boolean | semmle.label | parameter this [flag] : Boolean |
|
||||
| DisabledRevocationChecking.java:28:33:28:36 | flag | semmle.label | flag |
|
||||
| DisabledRevocationChecking.java:28:33:28:36 | this <.field> [flag] : Boolean | semmle.label | this <.field> [flag] : Boolean |
|
||||
#select
|
||||
| DisabledRevocationChecking.java:17:12:17:16 | false | DisabledRevocationChecking.java:17:12:17:16 | false : Boolean | DisabledRevocationChecking.java:28:33:28:36 | flag | Revocation checking is disabled $@. | DisabledRevocationChecking.java:17:12:17:16 | false | here |
|
||||
@@ -0,0 +1,80 @@
|
||||
import java.security.KeyStore;
|
||||
import java.security.cert.CertPath;
|
||||
import java.security.cert.CertPathValidator;
|
||||
import java.security.cert.PKIXCertPathChecker;
|
||||
import java.security.cert.PKIXParameters;
|
||||
import java.security.cert.PKIXRevocationChecker;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DisabledRevocationChecking {
|
||||
|
||||
private boolean flag = true;
|
||||
|
||||
public void disableRevocationChecking() {
|
||||
flag = false;
|
||||
}
|
||||
|
||||
public void testDisabledRevocationChecking(KeyStore cacerts, CertPath certPath) throws Exception {
|
||||
disableRevocationChecking();
|
||||
validate(cacerts, certPath);
|
||||
}
|
||||
|
||||
public void validate(KeyStore cacerts, CertPath certPath) throws Exception {
|
||||
CertPathValidator validator = CertPathValidator.getInstance("PKIX");
|
||||
PKIXParameters params = new PKIXParameters(cacerts);
|
||||
params.setRevocationEnabled(flag);
|
||||
validator.validate(certPath, params);
|
||||
}
|
||||
|
||||
public void testSettingRevocationCheckerWithCollectionsSingletonList(KeyStore cacerts, CertPath certPath) throws Exception {
|
||||
CertPathValidator validator = CertPathValidator.getInstance("PKIX");
|
||||
PKIXParameters params = new PKIXParameters(cacerts);
|
||||
params.setRevocationEnabled(false);
|
||||
PKIXRevocationChecker checker = (PKIXRevocationChecker) validator.getRevocationChecker();
|
||||
params.setCertPathCheckers(Collections.singletonList(checker));
|
||||
validator.validate(certPath, params);
|
||||
}
|
||||
|
||||
public void testSettingRevocationCheckerWithArraysAsList(KeyStore cacerts, CertPath certPath) throws Exception {
|
||||
CertPathValidator validator = CertPathValidator.getInstance("PKIX");
|
||||
PKIXParameters params = new PKIXParameters(cacerts);
|
||||
params.setRevocationEnabled(false);
|
||||
PKIXRevocationChecker checker = (PKIXRevocationChecker) validator.getRevocationChecker();
|
||||
params.setCertPathCheckers(Arrays.asList(checker));
|
||||
validator.validate(certPath, params);
|
||||
}
|
||||
|
||||
public void testSettingRevocationCheckerWithAddingToArrayList(KeyStore cacerts, CertPath certPath) throws Exception {
|
||||
CertPathValidator validator = CertPathValidator.getInstance("PKIX");
|
||||
PKIXParameters params = new PKIXParameters(cacerts);
|
||||
params.setRevocationEnabled(false);
|
||||
PKIXRevocationChecker checker = (PKIXRevocationChecker) validator.getRevocationChecker();
|
||||
List<PKIXCertPathChecker> checkers = new ArrayList<>();
|
||||
checkers.add(checker);
|
||||
params.setCertPathCheckers(checkers);
|
||||
validator.validate(certPath, params);
|
||||
}
|
||||
|
||||
public void testSettingRevocationCheckerWithListOf(KeyStore cacerts, CertPath certPath) throws Exception {
|
||||
CertPathValidator validator = CertPathValidator.getInstance("PKIX");
|
||||
PKIXParameters params = new PKIXParameters(cacerts);
|
||||
params.setRevocationEnabled(false);
|
||||
PKIXRevocationChecker checker = (PKIXRevocationChecker) validator.getRevocationChecker();
|
||||
List<PKIXCertPathChecker> checkers = List.of(checker);
|
||||
params.setCertPathCheckers(checkers);
|
||||
validator.validate(certPath, params);
|
||||
}
|
||||
|
||||
public void testAddingRevocationChecker(KeyStore cacerts, CertPath certPath) throws Exception {
|
||||
CertPathValidator validator = CertPathValidator.getInstance("PKIX");
|
||||
PKIXParameters params = new PKIXParameters(cacerts);
|
||||
params.setRevocationEnabled(false);
|
||||
PKIXRevocationChecker checker = (PKIXRevocationChecker) validator.getRevocationChecker();
|
||||
params.addCertPathChecker(checker);
|
||||
validator.validate(certPath, params);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
experimental/Security/CWE/CWE-299/DisabledRevocationChecking.ql
|
||||
Reference in New Issue
Block a user