mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Add tests for Pair.of and Triple.of
This commit is contained in:
@@ -19,6 +19,8 @@ class PairTest {
|
||||
ImmutablePair<String, String> taintedLeft2 = (ImmutablePair)taintedLeft2_;
|
||||
Pair<String, String> taintedRight2_ = ImmutablePair.right(taint());
|
||||
ImmutablePair<String, String> taintedRight2 = (ImmutablePair)taintedRight2_;
|
||||
Pair<String, String> taintedLeft3 = Pair.of(taint(), "clean-right");
|
||||
Pair<String, String> taintedRight3 = Pair.of("clean-left", taint());
|
||||
|
||||
// Check flow through ImmutablePairs:
|
||||
sink(taintedLeft.getLeft()); // $hasValueFlow
|
||||
@@ -45,6 +47,14 @@ class PairTest {
|
||||
sink(taintedRight2.getValue()); // $hasValueFlow
|
||||
sink(taintedRight2.left);
|
||||
sink(taintedRight2.right); // $hasValueFlow
|
||||
sink(taintedLeft3.getLeft()); // $hasValueFlow
|
||||
sink(taintedLeft3.getRight());
|
||||
sink(taintedLeft3.getKey()); // $hasValueFlow
|
||||
sink(taintedLeft3.getValue());
|
||||
sink(taintedRight3.getLeft());
|
||||
sink(taintedRight3.getRight()); // $hasValueFlow
|
||||
sink(taintedRight3.getKey());
|
||||
sink(taintedRight3.getValue()); // $hasValueFlow
|
||||
|
||||
// Check flow also works via an alias of type Pair:
|
||||
sink(taintedLeft2_.getLeft()); // $hasValueFlow
|
||||
|
||||
@@ -52,6 +52,21 @@ class TripleTest {
|
||||
sink(taintedRight2.getMiddle());
|
||||
sink(taintedRight2.getRight()); // $hasValueFlow
|
||||
|
||||
// Check flow via Triple.of:
|
||||
Triple<String, String, String> taintedLeft3 = Triple.of(taint(), "clean-middle", "clean-right");
|
||||
Triple<String, String, String> taintedMiddle3 = Triple.of("clean-left", taint(), "clean-right");
|
||||
Triple<String, String, String> taintedRight3 = Triple.of("clean-left", "clean-middle", taint());
|
||||
|
||||
sink(taintedLeft3.getLeft()); // $hasValueFlow
|
||||
sink(taintedLeft3.getMiddle());
|
||||
sink(taintedLeft3.getRight());
|
||||
sink(taintedMiddle3.getLeft());
|
||||
sink(taintedMiddle3.getMiddle()); // $hasValueFlow
|
||||
sink(taintedMiddle3.getRight());
|
||||
sink(taintedRight3.getLeft());
|
||||
sink(taintedRight3.getMiddle());
|
||||
sink(taintedRight3.getRight()); // $hasValueFlow
|
||||
|
||||
MutableTriple<String, String, String> mutableTaintedLeft = MutableTriple.of(taint(), "clean-middle", "clean-right");
|
||||
MutableTriple<String, String, String> mutableTaintedMiddle = MutableTriple.of("clean-left", taint(), "clean-right");
|
||||
MutableTriple<String, String, String> mutableTaintedRight = MutableTriple.of("clean-left", "clean-middle", taint());
|
||||
|
||||
Reference in New Issue
Block a user