forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbarrier-guards.ql
More file actions
37 lines (32 loc) · 1.13 KB
/
Copy pathbarrier-guards.ql
File metadata and controls
37 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import codeql.ruby.dataflow.internal.DataFlowPrivate
import codeql.ruby.dataflow.internal.DataFlowPublic
import codeql.ruby.dataflow.BarrierGuards
import codeql.ruby.controlflow.CfgNodes
import codeql.ruby.controlflow.ControlFlowGraph
import codeql.ruby.controlflow.BasicBlocks
import codeql.ruby.DataFlow
import utils.test.InlineExpectationsTest
query predicate newStyleBarrierGuards(DataFlow::Node n) {
n instanceof StringConstCompareBarrier or
n instanceof StringConstArrayInclusionCallBarrier
}
query predicate controls(CfgNode condition, BasicBlock bb, SuccessorTypes::ConditionalSuccessor s) {
exists(ConditionBlock cb |
cb.edgeDominates(bb, s) and
condition = cb.getLastNode()
)
}
module BarrierGuardTest implements TestSig {
string getARelevantTag() { result = "guarded" }
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "guarded" and
exists(DataFlow::Node n |
newStyleBarrierGuards(n) and
not n instanceof SsaInputNode and
location = n.getLocation() and
element = n.toString() and
value = ""
)
}
}
import MakeTest<BarrierGuardTest>