mirror of
https://github.com/hohn/codeql-workshop-dataflow-c.git
synced 2025-12-16 18:43:03 +01:00
51 lines
1.6 KiB
Org Mode
51 lines
1.6 KiB
Org Mode
* CodeQL AST in dot and pdf
|
|
#+BEGIN_SRC sh
|
|
# Produce ast in dot format
|
|
codeql database analyze \
|
|
--format=dot --output=ast.dot \
|
|
-j8 -v --ram=16000 \
|
|
--rerun \
|
|
-- \
|
|
cpp-dataflow-part1-database \
|
|
graphs/ast.ql
|
|
|
|
# Convert dot to pdf
|
|
dot -Tpdf < ast.dot/cpp/print-ast.dot > ast.dot/cpp/print-ast.pdf
|
|
|
|
# View the graph
|
|
open ast.dot/cpp/print-ast.pdf
|
|
|
|
|
|
# This comes from
|
|
tests-common/test_part1.c
|
|
#+END_SRC
|
|
|
|
* CodeQL CFG in dot and pdf
|
|
XX: The whole control flow graph is very large, so the query narrows it to the
|
|
function of interest,
|
|
#+BEGIN_SRC c++
|
|
int copy_mem(unsigned int unused, dyn_input_t *input,
|
|
unsigned int input_types) {...}
|
|
|
|
#+END_SRC
|
|
from [[./tests-common/test_part1.c]]
|
|
|
|
#+BEGIN_SRC sh
|
|
# Produce CFG in dot format
|
|
codeql database analyze \
|
|
--format=dot --output=cfg.dot \
|
|
-j8 -v --ram=16000 \
|
|
--rerun \
|
|
-- \
|
|
cpp-dataflow-part1-database \
|
|
graphs/cfg.ql
|
|
|
|
|
|
# Convert dot to pdf
|
|
dot -Tpdf < cfg.dot/cpp/print-cfg.dot > cfg.dot/cpp/print-cfg.pdf
|
|
|
|
# View the graph
|
|
open cfg.dot/cpp/print-cfg.pdf
|
|
#+END_SRC
|
|
|