-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12812 from egregius313/egregius313/java/dataflow/…
…refactor-tests Java: Refactor Test DataFlow configurations to new API
- Loading branch information
Showing
47 changed files
with
360 additions
and
431 deletions.
There are no files selected for viewing
16 changes: 7 additions & 9 deletions
16
java/ql/test/kotlin/library-tests/dataflow/extensionMethod/test.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import java | ||
import semmle.code.java.dataflow.TaintTracking | ||
|
||
class Conf extends TaintTracking::Configuration { | ||
Conf() { this = "qltest:extension-method" } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().hasName("taint") | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().hasName("sink") | ||
} | ||
predicate isSink(DataFlow::Node n) { n.asExpr().(Argument).getCall().getCallee().hasName("sink") } | ||
} | ||
|
||
from DataFlow::Node src, DataFlow::Node sink, Conf conf | ||
where conf.hasFlow(src, sink) | ||
module Flow = TaintTracking::Global<Config>; | ||
|
||
from DataFlow::Node src, DataFlow::Node sink | ||
where Flow::flow(src, sink) | ||
select src, sink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import java | ||
import semmle.code.java.dataflow.TaintTracking | ||
|
||
class Conf extends TaintTracking::Configuration { | ||
Conf() { this = "qltest:foreach-array-iterator" } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().hasName("taint") | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().hasName("sink") | ||
} | ||
predicate isSink(DataFlow::Node n) { n.asExpr().(Argument).getCall().getCallee().hasName("sink") } | ||
} | ||
|
||
from DataFlow::Node src, DataFlow::Node sink, Conf conf | ||
where conf.hasFlow(src, sink) | ||
module Flow = TaintTracking::Global<Config>; | ||
|
||
from DataFlow::Node src, DataFlow::Node sink | ||
where Flow::flow(src, sink) | ||
select src, sink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import java | ||
import semmle.code.java.dataflow.TaintTracking | ||
|
||
class Conf extends TaintTracking::Configuration { | ||
Conf() { this = "qltest:lambdaFlow" } | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { n.asExpr().(MethodAccess).getMethod().hasName("taint") } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(MethodAccess).getMethod().hasName("taint") | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().hasName("sink") | ||
} | ||
predicate isSink(DataFlow::Node n) { n.asExpr().(Argument).getCall().getCallee().hasName("sink") } | ||
} | ||
|
||
from DataFlow::Node src, DataFlow::Node sink, Conf conf | ||
where conf.hasFlow(src, sink) | ||
module Flow = TaintTracking::Global<Config>; | ||
|
||
from DataFlow::Node src, DataFlow::Node sink | ||
where Flow::flow(src, sink) | ||
select src, sink |
18 changes: 7 additions & 11 deletions
18
java/ql/test/kotlin/library-tests/dataflow/notnullexpr/test.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import java | ||
import semmle.code.java.dataflow.TaintTracking | ||
|
||
class Conf extends TaintTracking::Configuration { | ||
Conf() { this = "qltest:notNullExprFlow" } | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { n.asExpr().(MethodAccess).getMethod().hasName("taint") } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(MethodAccess).getMethod().hasName("taint") | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().hasName("sink") | ||
} | ||
predicate isSink(DataFlow::Node n) { n.asExpr().(Argument).getCall().getCallee().hasName("sink") } | ||
} | ||
|
||
from DataFlow::Node src, DataFlow::Node sink, Conf conf | ||
where conf.hasFlow(src, sink) | ||
module Flow = TaintTracking::Global<Config>; | ||
|
||
from DataFlow::Node src, DataFlow::Node sink | ||
where Flow::flow(src, sink) | ||
select src, sink |
16 changes: 7 additions & 9 deletions
16
java/ql/test/kotlin/library-tests/dataflow/stmtexpr/test.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import java | ||
import semmle.code.java.dataflow.DataFlow | ||
|
||
class Conf extends DataFlow::Configuration { | ||
Conf() { this = "qltest:exprStmtFlow" } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(ClassInstanceExpr).getType().(RefType).getASupertype*().hasName("Source") | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().hasName("sink") | ||
} | ||
predicate isSink(DataFlow::Node n) { n.asExpr().(Argument).getCall().getCallee().hasName("sink") } | ||
} | ||
|
||
from DataFlow::Node src, DataFlow::Node sink, Conf conf | ||
where conf.hasFlow(src, sink) | ||
module Flow = DataFlow::Global<Config>; | ||
|
||
from DataFlow::Node src, DataFlow::Node sink | ||
where Flow::flow(src, sink) | ||
select src, sink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import java | ||
import semmle.code.java.dataflow.TaintTracking | ||
|
||
class Conf extends TaintTracking::Configuration { | ||
Conf() { this = "kttaintconf" } | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { n.asExpr().(MethodAccess).getMethod().hasName("taint") } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(MethodAccess).getMethod().hasName("taint") | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().hasName("sink") | ||
} | ||
predicate isSink(DataFlow::Node n) { n.asExpr().(Argument).getCall().getCallee().hasName("sink") } | ||
} | ||
|
||
from DataFlow::Node src, DataFlow::Node sink, Conf conf | ||
where conf.hasFlow(src, sink) | ||
module Flow = TaintTracking::Global<Config>; | ||
|
||
from DataFlow::Node src, DataFlow::Node sink | ||
where Flow::flow(src, sink) | ||
select src, sink |
18 changes: 7 additions & 11 deletions
18
java/ql/test/kotlin/library-tests/dataflow/whenexpr/test.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import java | ||
import semmle.code.java.dataflow.TaintTracking | ||
|
||
class Conf extends TaintTracking::Configuration { | ||
Conf() { this = "qltest:notNullExprFlow" } | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { n.asExpr().(MethodAccess).getMethod().hasName("taint") } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(MethodAccess).getMethod().hasName("taint") | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().hasName("sink") | ||
} | ||
predicate isSink(DataFlow::Node n) { n.asExpr().(Argument).getCall().getCallee().hasName("sink") } | ||
} | ||
|
||
from DataFlow::Node src, DataFlow::Node sink, Conf conf | ||
where conf.hasFlow(src, sink) | ||
module Flow = TaintTracking::Global<Config>; | ||
|
||
from DataFlow::Node src, DataFlow::Node sink | ||
where Flow::flow(src, sink) | ||
select src, sink |
12 changes: 6 additions & 6 deletions
12
java/ql/test/kotlin/library-tests/field-initializer-flow/test.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import java | ||
import semmle.code.java.dataflow.DataFlow | ||
|
||
class Config extends DataFlow::Configuration { | ||
Config() { this = "Config" } | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { n.asExpr().(StringLiteral).getValue() = "Source" } | ||
|
||
override predicate isSource(DataFlow::Node n) { n.asExpr().(StringLiteral).getValue() = "Source" } | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().getName() = "sink" | ||
} | ||
} | ||
|
||
module Flow = DataFlow::Global<Config>; | ||
|
||
query predicate isFinalField(Field f) { | ||
exists(FieldDeclaration f2 | f = f2.getAField()) and f.isFinal() | ||
} | ||
|
||
from DataFlow::Node source, DataFlow::Node sink | ||
where any(Config c).hasFlow(source, sink) | ||
where Flow::flow(source, sink) | ||
select source, sink |
14 changes: 7 additions & 7 deletions
14
java/ql/test/kotlin/library-tests/jvmoverloads_flow/test.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import java | ||
import semmle.code.java.dataflow.DataFlow | ||
|
||
class Config extends DataFlow::Configuration { | ||
Config() { this = "config" } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(MethodAccess).getCallee().getName() = "source" | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().getName() = "sink" | ||
} | ||
} | ||
|
||
from Config c, DataFlow::Node source, DataFlow::Node sink | ||
where c.hasFlow(source, sink) | ||
module Flow = DataFlow::Global<Config>; | ||
|
||
from DataFlow::Node source, DataFlow::Node sink | ||
where Flow::flow(source, sink) | ||
select source, sink, source.getEnclosingCallable() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
java/ql/test/kotlin/library-tests/super-method-calls/test.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import java | ||
import semmle.code.java.dataflow.DataFlow | ||
|
||
class Config extends DataFlow::Configuration { | ||
Config() { this = "abc" } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(MethodAccess).getMethod().getName() = "source" | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
predicate isSink(DataFlow::Node n) { | ||
n.asExpr().(Argument).getCall().getCallee().getName() = "sink" | ||
} | ||
} | ||
|
||
from Config c, DataFlow::Node n1, DataFlow::Node n2 | ||
where c.hasFlow(n1, n2) | ||
module Flow = DataFlow::Global<Config>; | ||
|
||
from DataFlow::Node n1, DataFlow::Node n2 | ||
where Flow::flow(n1, n2) | ||
select n1, n2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import java | ||
import semmle.code.java.dataflow.DataFlow | ||
|
||
class Config extends DataFlow::Configuration { | ||
Config() { this = "varargs-dataflow-test" } | ||
|
||
override predicate isSource(DataFlow::Node n) { | ||
module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node n) { | ||
n.asExpr().(CompileTimeConstantExpr).getEnclosingCallable().fromSource() | ||
} | ||
|
||
override predicate isSink(DataFlow::Node n) { | ||
predicate isSink(DataFlow::Node n) { | ||
n.asExpr() = any(MethodAccess ma | ma.getMethod().getName() = "sink").getAnArgument() | ||
} | ||
} | ||
|
||
from DataFlow::Node source, DataFlow::Node sink, Config c | ||
where c.hasFlow(source, sink) | ||
module Flow = DataFlow::Global<Config>; | ||
|
||
from DataFlow::Node source, DataFlow::Node sink | ||
where Flow::flow(source, sink) | ||
select source, sink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.