Files
codeql-workshop-dataflow-c/graphs/dfg.ql

31 lines
775 B
Plaintext

/**
* @name Print part of the DFG
* @description Outputs a subset of the data flow graph
* @id cpp/print-dfg
* @kind graph
*/
// Just show the part for
// int copy_mem(unsigned int unused, dyn_input_t *input,
// unsigned int input_types)
import cpp
import semmle.code.cpp.dataflow.new.DataFlow
query predicate nodes(DataFlow::Node n1, string key, string value) {
(edges(n1, _) or edges(_, n1)) and
(
key = "color" and value = "black"
or
key = "line" and value = n1.getLocation().getStartLine().toString()
)
}
query predicate edges(DataFlow::Node n1, DataFlow::Node n2) {
exists(Function f1 |
f1.hasName("copy_mem") and
n1.getFunction() = f1 and
DataFlow::localFlowStep(n1, n2) and
n2.getLocation().getStartLine() < 46
)
}