|
| 1 | +predicate isLeft(string s) { none() } |
| 2 | + |
| 3 | +predicate isRight(string s) { none() } |
| 4 | + |
| 5 | +predicate disjunct() { |
| 6 | + exists(string x | |
| 7 | + x = "left_1" and |
| 8 | + isLeft(x) // $ getAStringValue=left_1 |
| 9 | + or |
| 10 | + x = "right_1" and |
| 11 | + isRight(x) // $ getAStringValue=right_1 |
| 12 | + ) |
| 13 | +} |
| 14 | + |
| 15 | +string sourceLeft2() { result = "left_2" } |
| 16 | + |
| 17 | +predicate sinkLeft2(string x) { |
| 18 | + isLeft(x) // $ getAStringValue=left_2 |
| 19 | +} |
| 20 | + |
| 21 | +string sourceRight2() { result = "right_2" } |
| 22 | + |
| 23 | +predicate sinkRight2(string x) { |
| 24 | + isRight(x) // $ getAStringValue=right_2 |
| 25 | +} |
| 26 | + |
| 27 | +predicate disjunctViaCall() { |
| 28 | + exists(string x | |
| 29 | + x = sourceLeft2() and |
| 30 | + sinkLeft2(x) // $ getAStringValue=left_2 |
| 31 | + or |
| 32 | + x = sourceRight2() and |
| 33 | + sinkRight2(x) // $ getAStringValue=right_2 |
| 34 | + ) |
| 35 | +} |
| 36 | + |
| 37 | +predicate distribute() { |
| 38 | + exists(string x | |
| 39 | + x = "left_3" |
| 40 | + or |
| 41 | + x = "right_3" |
| 42 | + | |
| 43 | + isLeft(x) // $ getAStringValue=left_3 getAStringValue=right_3 |
| 44 | + or |
| 45 | + isRight(x) // $ getAStringValue=left_3 getAStringValue=right_3 |
| 46 | + ) |
| 47 | +} |
| 48 | + |
| 49 | +predicate distributeSet() { |
| 50 | + exists(string x | x = ["left_4", "right_4"] | |
| 51 | + isLeft(x) // $ getAStringValue=left_4 getAStringValue=right_4 |
| 52 | + or |
| 53 | + isRight(x) // $ getAStringValue=left_4 getAStringValue=right_4 |
| 54 | + ) |
| 55 | +} |
| 56 | + |
| 57 | +predicate noFlowBackOut() { |
| 58 | + exists(string x | |
| 59 | + isLeft(x) // no value |
| 60 | + ) |
| 61 | +} |
| 62 | + |
| 63 | +class StringClass extends string { |
| 64 | + StringClass() { this = "StringClass" } |
| 65 | +} |
| 66 | + |
| 67 | +class FieldClass extends int { |
| 68 | + StringClass field; |
| 69 | + |
| 70 | + FieldClass() { this = 0 } |
| 71 | + |
| 72 | + StringClass getField() { result = field } |
| 73 | +} |
| 74 | + |
| 75 | +predicate isStringClass(string s) { none() } |
| 76 | + |
| 77 | +predicate test() { |
| 78 | + isStringClass(any(FieldClass f).getField()) // $ getAStringValue=StringClass |
| 79 | +} |
0 commit comments