Skip to content

Commit 2d13906

Browse files
author
Benjamin Muskalla
committed
Simplify jaxrs setup
1 parent 24d4368 commit 2d13906

File tree

2 files changed

+8
-38
lines changed

2 files changed

+8
-38
lines changed

java/ql/test/TestUtilities/InlineFlowTest.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,28 @@ class DefaultValueFlowConf extends DataFlow::Configuration {
77
DefaultValueFlowConf() { this = "qltest:defaultValueFlowConf" }
88

99
override predicate isSource(DataFlow::Node n) {
10-
n.asExpr().(MethodAccess).getMethod().hasName("source")
10+
n.asExpr().(MethodAccess).getMethod().getName() = ["source", "taint"]
1111
}
1212

1313
override predicate isSink(DataFlow::Node n) {
1414
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
1515
}
16+
17+
override int fieldFlowBranchLimit() { result = 1000 }
1618
}
1719

1820
class DefaultTaintFlowConf extends TaintTracking::Configuration {
1921
DefaultTaintFlowConf() { this = "qltest:defaultTaintFlowConf" }
2022

2123
override predicate isSource(DataFlow::Node n) {
22-
n.asExpr().(MethodAccess).getMethod().hasName("source")
24+
n.asExpr().(MethodAccess).getMethod().getName() = ["source", "taint"]
2325
}
2426

2527
override predicate isSink(DataFlow::Node n) {
26-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
28+
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
2729
}
30+
31+
override int fieldFlowBranchLimit() { result = 1000 }
2832
}
2933

3034
class InlineFlowTest extends InlineExpectationsTest {
Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,4 @@
11
import java
2-
import semmle.code.java.dataflow.TaintTracking
32
import TestUtilities.InlineFlowTest
43

5-
class TaintFlowConf extends TaintTracking::Configuration {
6-
TaintFlowConf() { this = "qltest:frameworks:jax-rs-taint" }
7-
8-
override predicate isSource(DataFlow::Node n) {
9-
n.asExpr().(MethodAccess).getMethod().hasName("taint")
10-
}
11-
12-
override predicate isSink(DataFlow::Node n) {
13-
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
14-
}
15-
16-
override int fieldFlowBranchLimit() { result = 1000 }
17-
}
18-
19-
class ValueFlowConf extends DataFlow::Configuration {
20-
ValueFlowConf() { this = "qltest:frameworks:jax-rs-value" }
21-
22-
override predicate isSource(DataFlow::Node n) {
23-
n.asExpr().(MethodAccess).getMethod().hasName("taint")
24-
}
25-
26-
override predicate isSink(DataFlow::Node n) {
27-
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
28-
}
29-
30-
// TODO: move to default?
31-
override int fieldFlowBranchLimit() { result = 1000 }
32-
}
33-
34-
class HasFlowTest extends InlineFlowTest {
35-
override DataFlow::Configuration getValueFlowConfig() { result = any(ValueFlowConf config) }
36-
37-
override DataFlow::Configuration getTaintFlowConfig() { result = any(TaintFlowConf config) }
38-
}
4+
class HasFlowTest extends InlineFlowTest { }

0 commit comments

Comments
 (0)