Skip to content

Commit 6f217d3

Browse files
committed
Java: Apply suggestions from review.
1 parent 4a00670 commit 6f217d3

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class InsecureTrustManagerConfiguration extends TaintTracking::Configuration {
8080
bindingset[result]
8181
private string getAFlagName() {
8282
result
83-
.regexpMatch("(?i).*(secure|disable|selfCert|selfSign|validat|verif|trust|ignore|nocertificatecheck).*")
83+
.regexpMatch("(?i).*(secure|disable|selfCert|selfSign|validat|verif|trust|ignore|nocertificatecheck).*") and
84+
result != "equalsIgnoreCase"
8485
}
8586

8687
/**
@@ -94,11 +95,6 @@ private class FlagType extends Type {
9495
}
9596
}
9697

97-
private predicate isEqualsIgnoreCaseMethodAccess(MethodAccess ma) {
98-
ma.getMethod().hasName("equalsIgnoreCase") and
99-
ma.getMethod().getDeclaringType() instanceof TypeString
100-
}
101-
10298
/** Holds if `source` should is considered a flag. */
10399
private predicate isFlag(DataFlow::Node source) {
104100
exists(VarAccess v | v.getVariable().getName() = getAFlagName() |
@@ -109,13 +105,13 @@ private predicate isFlag(DataFlow::Node source) {
109105
or
110106
exists(MethodAccess ma | ma.getMethod().getName() = getAFlagName() |
111107
source.asExpr() = ma and
112-
ma.getType() instanceof FlagType and
113-
not isEqualsIgnoreCaseMethodAccess(ma)
108+
ma.getType() instanceof FlagType
114109
)
115110
}
116111

117112
/**
118-
* Holds if there is flow from `node1` to `node2` either due to local flow or due to custom flow steps:
113+
* Holds if there is local flow from `node1` to `node2` either due to standard data-flow steps or the
114+
* following custom flow steps:
119115
* 1. `Boolean.parseBoolean(taintedValue)` taints the return value of `parseBoolean`.
120116
* 2. A call to an `EnvReadMethod` such as `System.getProperty` where a tainted value is used as an argument.
121117
* The return value of such a method is then tainted.

0 commit comments

Comments
 (0)