|
| 1 | +/** |
| 2 | + * Provides a module for implementing the `View DFG` query based on inputs to the data flow library. |
| 3 | + */ |
| 4 | + |
| 5 | +private import codeql.util.Location |
| 6 | +private import codeql.dataflow.DataFlow as DF |
| 7 | +private import codeql.dataflow.TaintTracking as TT |
| 8 | + |
| 9 | +module MakePrintDfg< |
| 10 | + LocationSig Location, DF::InputSig<Location> DataFlowLang, |
| 11 | + TT::InputSig<Location, DataFlowLang> TaintTrackingLang> |
| 12 | +{ |
| 13 | + private import DataFlowLang |
| 14 | + private import codeql.util.PrintGraph as Pp |
| 15 | + |
| 16 | + final private class FinalNode = Node; |
| 17 | + |
| 18 | + private module PrintGraphInput implements Pp::InputSig<Location> { |
| 19 | + class Callable = DataFlowLang::DataFlowCallable; |
| 20 | + |
| 21 | + class Node extends FinalNode { |
| 22 | + string getOrderDisambiguation() { result = DataFlowLang::nodeGetOrderDisambiguation(this) } |
| 23 | + |
| 24 | + Callable getEnclosingCallable() { result = DataFlowLang::nodeGetEnclosingCallable(this) } |
| 25 | + } |
| 26 | + |
| 27 | + predicate edge(Node node1, string label, Node node2) { |
| 28 | + simpleLocalFlowStep(node1, node2, _) and label = "value" |
| 29 | + or |
| 30 | + jumpStep(node1, node2) and label = "jump" |
| 31 | + or |
| 32 | + TaintTrackingLang::defaultAdditionalTaintStep(node1, node2, _) and label = "taint" |
| 33 | + or |
| 34 | + exists(ContentSet c | |
| 35 | + readStep(node1, c, node2) and label = "read[" + c.toString() + "]" |
| 36 | + or |
| 37 | + storeStep(node1, c, node2) and label = "store[" + c.toString() + "]" |
| 38 | + ) |
| 39 | + or |
| 40 | + node1 = node2.(PostUpdateNode).getPreUpdateNode() and label = "post-update" |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + import Pp::PrintGraph<Location, PrintGraphInput> |
| 45 | +} |
0 commit comments