mirror of
https://github.com/hohn/codeql-workshop-dataflow-c.git
synced 2025-12-16 10:33:04 +01:00
31 lines
775 B
Plaintext
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
|
|
)
|
|
}
|