Skip to content

Commit 2d9b4b3

Browse files
author
Benjamin Muskalla
committed
Convert spring to InlineFlowTest
1 parent da3b7a2 commit 2d9b4b3

File tree

8 files changed

+16
-401
lines changed

8 files changed

+16
-401
lines changed
Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,4 @@
11
import java
2-
import semmle.code.java.dataflow.ExternalFlow
3-
import semmle.code.java.dataflow.TaintTracking
4-
import TestUtilities.InlineExpectationsTest
2+
import TestUtilities.InlineFlowTest
53

6-
class ValueFlowConf extends DataFlow::Configuration {
7-
ValueFlowConf() { this = "qltest:valueFlowConf" }
8-
9-
override predicate isSource(DataFlow::Node n) {
10-
n.asExpr().(MethodAccess).getMethod().hasName("source")
11-
}
12-
13-
override predicate isSink(DataFlow::Node n) {
14-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
15-
}
16-
}
17-
18-
class TaintFlowConf extends TaintTracking::Configuration {
19-
TaintFlowConf() { this = "qltest:taintFlowConf" }
20-
21-
override predicate isSource(DataFlow::Node n) {
22-
n.asExpr().(MethodAccess).getMethod().hasName("source")
23-
}
24-
25-
override predicate isSink(DataFlow::Node n) {
26-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
27-
}
28-
}
29-
30-
class HasFlowTest extends InlineExpectationsTest {
31-
HasFlowTest() { this = "HasFlowTest" }
32-
33-
override string getARelevantTag() { result = ["hasValueFlow", "hasTaintFlow"] }
34-
35-
override predicate hasActualResult(Location location, string element, string tag, string value) {
36-
tag = "hasValueFlow" and
37-
exists(DataFlow::Node src, DataFlow::Node sink, ValueFlowConf conf | conf.hasFlow(src, sink) |
38-
sink.getLocation() = location and
39-
element = sink.toString() and
40-
value = ""
41-
)
42-
or
43-
tag = "hasTaintFlow" and
44-
exists(DataFlow::Node src, DataFlow::Node sink, TaintFlowConf conf |
45-
conf.hasFlow(src, sink) and not any(ValueFlowConf c).hasFlow(src, sink)
46-
|
47-
sink.getLocation() = location and
48-
element = sink.toString() and
49-
value = ""
50-
)
51-
}
52-
}
4+
class HasFlowTest extends InlineFlowTest { }
Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,4 @@
11
import java
2-
import semmle.code.java.dataflow.DataFlow
3-
import semmle.code.java.dataflow.TaintTracking
4-
import TestUtilities.InlineExpectationsTest
2+
import TestUtilities.InlineFlowTest
53

6-
class ValueFlowConf extends DataFlow::Configuration {
7-
ValueFlowConf() { this = "qltest:valueFlowConf" }
8-
9-
override predicate isSource(DataFlow::Node n) {
10-
n.asExpr().(MethodAccess).getMethod().hasName("source")
11-
}
12-
13-
override predicate isSink(DataFlow::Node n) {
14-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
15-
}
16-
}
17-
18-
class TaintFlowConf extends TaintTracking::Configuration {
19-
TaintFlowConf() { this = "qltest:taintFlowConf" }
20-
21-
override predicate isSource(DataFlow::Node n) {
22-
n.asExpr().(MethodAccess).getMethod().hasName("source")
23-
}
24-
25-
override predicate isSink(DataFlow::Node n) {
26-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
27-
}
28-
}
29-
30-
class HasFlowTest extends InlineExpectationsTest {
31-
HasFlowTest() { this = "HasFlowTest" }
32-
33-
override string getARelevantTag() { result = ["hasValueFlow", "hasTaintFlow"] }
34-
35-
override predicate hasActualResult(Location location, string element, string tag, string value) {
36-
tag = "hasValueFlow" and
37-
exists(DataFlow::Node src, DataFlow::Node sink, ValueFlowConf conf | conf.hasFlow(src, sink) |
38-
sink.getLocation() = location and
39-
element = sink.toString() and
40-
value = ""
41-
)
42-
or
43-
tag = "hasTaintFlow" and
44-
exists(DataFlow::Node src, DataFlow::Node sink, TaintFlowConf conf |
45-
conf.hasFlow(src, sink) and not any(ValueFlowConf c).hasFlow(src, sink)
46-
|
47-
sink.getLocation() = location and
48-
element = sink.toString() and
49-
value = ""
50-
)
51-
}
52-
}
4+
class HasFlowTest extends InlineFlowTest { }
Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,4 @@
11
import java
2-
import semmle.code.java.frameworks.spring.Spring
3-
import semmle.code.java.dataflow.TaintTracking
4-
import TestUtilities.InlineExpectationsTest
2+
import TestUtilities.InlineFlowTest
53

6-
class TaintFlowConf extends TaintTracking::Configuration {
7-
TaintFlowConf() { this = "qltest:frameworks:spring-taint-flow" }
8-
9-
override predicate isSource(DataFlow::Node n) {
10-
exists(string name | name.matches("taint%") |
11-
n.asExpr().(MethodAccess).getMethod().hasName(name)
12-
)
13-
}
14-
15-
override predicate isSink(DataFlow::Node n) {
16-
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
17-
}
18-
}
19-
20-
class ValueFlowConf extends DataFlow::Configuration {
21-
ValueFlowConf() { this = "qltest:frameworks:spring-value-flow" }
22-
23-
override predicate isSource(DataFlow::Node n) {
24-
n.asExpr().(MethodAccess).getMethod().hasName("taint")
25-
}
26-
27-
override predicate isSink(DataFlow::Node n) {
28-
exists(MethodAccess ma | ma.getMethod().hasName("sink") | n.asExpr() = ma.getAnArgument())
29-
}
30-
}
31-
32-
class HasFlowTest extends InlineExpectationsTest {
33-
HasFlowTest() { this = "HasFlowTest" }
34-
35-
override string getARelevantTag() { result = ["hasTaintFlow", "hasValueFlow"] }
36-
37-
override predicate hasActualResult(Location location, string element, string tag, string value) {
38-
tag = "hasTaintFlow" and
39-
exists(DataFlow::Node src, DataFlow::Node sink, TaintFlowConf conf | conf.hasFlow(src, sink) |
40-
not any(ValueFlowConf vconf).hasFlow(src, sink) and
41-
sink.getLocation() = location and
42-
element = sink.toString() and
43-
value = ""
44-
)
45-
or
46-
tag = "hasValueFlow" and
47-
exists(DataFlow::Node src, DataFlow::Node sink, ValueFlowConf conf | conf.hasFlow(src, sink) |
48-
sink.getLocation() = location and
49-
element = sink.toString() and
50-
value = ""
51-
)
52-
}
53-
}
4+
class HasFlowTest extends InlineFlowTest { }
Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,4 @@
11
import java
2-
import semmle.code.java.dataflow.DataFlow
3-
import semmle.code.java.dataflow.TaintTracking
4-
import TestUtilities.InlineExpectationsTest
2+
import TestUtilities.InlineFlowTest
53

6-
class ValueFlowConf extends DataFlow::Configuration {
7-
ValueFlowConf() { this = "qltest:valueFlowConf" }
8-
9-
override predicate isSource(DataFlow::Node n) {
10-
n.asExpr().(MethodAccess).getMethod().hasName("source")
11-
}
12-
13-
override predicate isSink(DataFlow::Node n) {
14-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
15-
}
16-
}
17-
18-
class TaintFlowConf extends TaintTracking::Configuration {
19-
TaintFlowConf() { this = "qltest:taintFlowConf" }
20-
21-
override predicate isSource(DataFlow::Node n) {
22-
n.asExpr().(MethodAccess).getMethod().hasName("source")
23-
}
24-
25-
override predicate isSink(DataFlow::Node n) {
26-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
27-
}
28-
}
29-
30-
class HasFlowTest extends InlineExpectationsTest {
31-
HasFlowTest() { this = "HasFlowTest" }
32-
33-
override string getARelevantTag() { result = ["hasValueFlow", "hasTaintFlow"] }
34-
35-
override predicate hasActualResult(Location location, string element, string tag, string value) {
36-
tag = "hasValueFlow" and
37-
exists(DataFlow::Node src, DataFlow::Node sink, ValueFlowConf conf | conf.hasFlow(src, sink) |
38-
sink.getLocation() = location and
39-
element = sink.toString() and
40-
value = ""
41-
)
42-
or
43-
tag = "hasTaintFlow" and
44-
exists(DataFlow::Node src, DataFlow::Node sink, TaintFlowConf conf |
45-
conf.hasFlow(src, sink) and not any(ValueFlowConf c).hasFlow(src, sink)
46-
|
47-
sink.getLocation() = location and
48-
element = sink.toString() and
49-
value = ""
50-
)
51-
}
52-
}
4+
class HasFlowTest extends InlineFlowTest { }
Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,4 @@
11
import java
2-
import semmle.code.java.dataflow.DataFlow
3-
import semmle.code.java.dataflow.TaintTracking
4-
import TestUtilities.InlineExpectationsTest
2+
import TestUtilities.InlineFlowTest
53

6-
class ValueFlowConf extends DataFlow::Configuration {
7-
ValueFlowConf() { this = "qltest:valueFlowConf" }
8-
9-
override predicate isSource(DataFlow::Node n) {
10-
n.asExpr().(MethodAccess).getMethod().hasName("source")
11-
}
12-
13-
override predicate isSink(DataFlow::Node n) {
14-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
15-
}
16-
}
17-
18-
class TaintFlowConf extends TaintTracking::Configuration {
19-
TaintFlowConf() { this = "qltest:taintFlowConf" }
20-
21-
override predicate isSource(DataFlow::Node n) {
22-
n.asExpr().(MethodAccess).getMethod().hasName("source")
23-
}
24-
25-
override predicate isSink(DataFlow::Node n) {
26-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
27-
}
28-
}
29-
30-
class HasFlowTest extends InlineExpectationsTest {
31-
HasFlowTest() { this = "HasFlowTest" }
32-
33-
override string getARelevantTag() { result = ["hasValueFlow", "hasTaintFlow"] }
34-
35-
override predicate hasActualResult(Location location, string element, string tag, string value) {
36-
tag = "hasValueFlow" and
37-
exists(DataFlow::Node src, DataFlow::Node sink, ValueFlowConf conf | conf.hasFlow(src, sink) |
38-
sink.getLocation() = location and
39-
element = sink.toString() and
40-
value = ""
41-
)
42-
or
43-
tag = "hasTaintFlow" and
44-
exists(DataFlow::Node src, DataFlow::Node sink, TaintFlowConf conf |
45-
conf.hasFlow(src, sink) and not any(ValueFlowConf c).hasFlow(src, sink)
46-
|
47-
sink.getLocation() = location and
48-
element = sink.toString() and
49-
value = ""
50-
)
51-
}
52-
}
4+
class HasFlowTest extends InlineFlowTest { }
Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,4 @@
11
import java
2-
import semmle.code.java.dataflow.DataFlow
3-
import semmle.code.java.dataflow.TaintTracking
4-
import TestUtilities.InlineExpectationsTest
2+
import TestUtilities.InlineFlowTest
53

6-
class ValueFlowConf extends DataFlow::Configuration {
7-
ValueFlowConf() { this = "qltest:valueFlowConf" }
8-
9-
override predicate isSource(DataFlow::Node n) {
10-
n.asExpr().(MethodAccess).getMethod().hasName("source")
11-
}
12-
13-
override predicate isSink(DataFlow::Node n) {
14-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
15-
}
16-
}
17-
18-
class TaintFlowConf extends TaintTracking::Configuration {
19-
TaintFlowConf() { this = "qltest:taintFlowConf" }
20-
21-
override predicate isSource(DataFlow::Node n) {
22-
n.asExpr().(MethodAccess).getMethod().hasName("source")
23-
}
24-
25-
override predicate isSink(DataFlow::Node n) {
26-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
27-
}
28-
}
29-
30-
class HasFlowTest extends InlineExpectationsTest {
31-
HasFlowTest() { this = "HasFlowTest" }
32-
33-
override string getARelevantTag() { result = ["hasValueFlow", "hasTaintFlow"] }
34-
35-
override predicate hasActualResult(Location location, string element, string tag, string value) {
36-
tag = "hasValueFlow" and
37-
exists(DataFlow::Node src, DataFlow::Node sink, ValueFlowConf conf | conf.hasFlow(src, sink) |
38-
sink.getLocation() = location and
39-
element = sink.toString() and
40-
value = ""
41-
)
42-
or
43-
tag = "hasTaintFlow" and
44-
exists(DataFlow::Node src, DataFlow::Node sink, TaintFlowConf conf |
45-
conf.hasFlow(src, sink) and not any(ValueFlowConf c).hasFlow(src, sink)
46-
|
47-
sink.getLocation() = location and
48-
element = sink.toString() and
49-
value = ""
50-
)
51-
}
52-
}
4+
class HasFlowTest extends InlineFlowTest { }
Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,4 @@
11
import java
2-
import semmle.code.java.dataflow.DataFlow
3-
import semmle.code.java.dataflow.TaintTracking
4-
import TestUtilities.InlineExpectationsTest
2+
import TestUtilities.InlineFlowTest
53

6-
class ValueFlowConf extends DataFlow::Configuration {
7-
ValueFlowConf() { this = "qltest:valueFlowConf" }
8-
9-
override predicate isSource(DataFlow::Node n) {
10-
n.asExpr().(MethodAccess).getMethod().hasName("source")
11-
}
12-
13-
override predicate isSink(DataFlow::Node n) {
14-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
15-
}
16-
}
17-
18-
class TaintFlowConf extends TaintTracking::Configuration {
19-
TaintFlowConf() { this = "qltest:taintFlowConf" }
20-
21-
override predicate isSource(DataFlow::Node n) {
22-
n.asExpr().(MethodAccess).getMethod().hasName("source")
23-
}
24-
25-
override predicate isSink(DataFlow::Node n) {
26-
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
27-
}
28-
}
29-
30-
class HasFlowTest extends InlineExpectationsTest {
31-
HasFlowTest() { this = "HasFlowTest" }
32-
33-
override string getARelevantTag() { result = ["hasValueFlow", "hasTaintFlow"] }
34-
35-
override predicate hasActualResult(Location location, string element, string tag, string value) {
36-
tag = "hasValueFlow" and
37-
exists(DataFlow::Node src, DataFlow::Node sink, ValueFlowConf conf | conf.hasFlow(src, sink) |
38-
sink.getLocation() = location and
39-
element = sink.toString() and
40-
value = ""
41-
)
42-
or
43-
tag = "hasTaintFlow" and
44-
exists(DataFlow::Node src, DataFlow::Node sink, TaintFlowConf conf |
45-
conf.hasFlow(src, sink) and not any(ValueFlowConf c).hasFlow(src, sink)
46-
|
47-
sink.getLocation() = location and
48-
element = sink.toString() and
49-
value = ""
50-
)
51-
}
52-
}
4+
class HasFlowTest extends InlineFlowTest { }

0 commit comments

Comments
 (0)