Skip to content

Commit a040ff6

Browse files
committed
Refactor ConditionalBypass
1 parent aa79341 commit a040ff6

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

java/ql/lib/semmle/code/java/security/ConditionalBypassQuery.qll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ private predicate endsWithStep(DataFlow::Node node1, DataFlow::Node node2) {
3737
}
3838

3939
/**
40+
* DEPRECATED: Use `ConditionalBypassFlow` instead.
41+
*
4042
* A taint tracking configuration for untrusted data flowing to sensitive conditions.
4143
*/
42-
class ConditionalBypassFlowConfig extends TaintTracking::Configuration {
44+
deprecated class ConditionalBypassFlowConfig extends TaintTracking::Configuration {
4345
ConditionalBypassFlowConfig() { this = "ConditionalBypassFlowConfig" }
4446

4547
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
@@ -50,3 +52,18 @@ class ConditionalBypassFlowConfig extends TaintTracking::Configuration {
5052
endsWithStep(node1, node2)
5153
}
5254
}
55+
56+
module ConditionalBypassFlowConfig implements DataFlow::ConfigSig {
57+
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
58+
59+
predicate isSink(DataFlow::Node sink) { conditionControlsMethod(_, sink.asExpr()) }
60+
61+
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
62+
endsWithStep(node1, node2)
63+
}
64+
}
65+
66+
/**
67+
* A taint tracking configuration for untrusted data flowing to sensitive conditions.
68+
*/
69+
module ConditionalBypassFlow = TaintTracking::Global<ConditionalBypassFlowConfig>;

java/ql/src/Security/CWE/CWE-807/ConditionalBypass.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
import java
1616
import semmle.code.java.dataflow.DataFlow
1717
import semmle.code.java.security.ConditionalBypassQuery
18-
import DataFlow::PathGraph
18+
import ConditionalBypassFlow::PathGraph
1919

2020
from
21-
DataFlow::PathNode source, DataFlow::PathNode sink, MethodAccess m, Expr e,
22-
ConditionalBypassFlowConfig conf
21+
ConditionalBypassFlow::PathNode source, ConditionalBypassFlow::PathNode sink, MethodAccess m,
22+
Expr e
2323
where
2424
conditionControlsMethod(m, e) and
2525
sink.getNode().asExpr() = e and
26-
conf.hasFlowPath(source, sink)
26+
ConditionalBypassFlow::flowPath(source, sink)
2727
select m, source, sink,
2828
"Sensitive method may not be executed depending on a $@, which flows from $@.", e,
2929
"this condition", source.getNode(), "user-controlled value"

java/ql/test/query-tests/security/CWE-807/semmle/tests/ConditionalBypassTest.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ConditionalBypassTest extends InlineExpectationsTest {
99

1010
override predicate hasActualResult(Location location, string element, string tag, string value) {
1111
tag = "hasConditionalBypassTest" and
12-
exists(DataFlow::Node sink, ConditionalBypassFlowConfig conf | conf.hasFlowTo(sink) |
12+
exists(DataFlow::Node sink | ConditionalBypassFlow::flowTo(sink) |
1313
sink.getLocation() = location and
1414
element = sink.toString() and
1515
value = ""

0 commit comments

Comments
 (0)