PDG Query Example Cookbook
tools/ir/examples/ contains ready-to-run Cypher queries for lotus-ir-pdg-query.
Location: tools/ir/examples/
Contents:
primitives.cypherfor basic node and edge exploration.dataflow.cypherandsecurity.cypherfor flow-oriented triage.metrics.cypheranddebug-info.cypherfor inspection and reporting.static-analysis.cypherfor analysis-oriented query patterns.agent-guidance.cypherfor LLM-agent-guided PDG exploration primitives.security/— categorized security analysis patterns:injection.cypher— Command injection: system/popen/exec sinks + input source tracingmemory.cypher— Use-after-free, double-free, memory leaksunsafe-libc.cypher— strcpy/gets/sprintf, format string, buffer overflowresource.cypher— File handle leaks, lock/unlock, mmap/munmapdouble-free.cypher— Double-free, use-after-free, new/delete mismatchtaint.cypher— Input-to-sink taint tracking, format string, argument tracing
The directory acts as a practical cookbook for users learning the PDG query language.
How to use the examples
Start with primitives.cypher to inspect the graph schema and verify that a
PDG was imported as expected. Then adapt a focused query such as a dataflow or
security pattern to the node labels and properties in the target graph. Treat
the security examples as triage starting points: inspect their matches and
refine sources, sinks, and path constraints before reporting a finding.
See also PDG Query – Program Dependence Graph Queries and PDG Query Language (Cypher).