Files
codeql-workshop-dataflow-c/readme-low-level.org
2025-03-17 19:21:15 -07:00

2.1 KiB

CodeQL AST in dot and pdf

  # 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
  unzip -v cpp-dataflow-part1-database/src.zip
  # Archive:  cpp-dataflow-part1-database/src.zip
  #  Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
  # --------  ------  ------- ---- ---------- ----- --------  ----
  #     3280  Defl:N      880  73% 03-17-2025 08:59 8057b2ea  Users/hohn/local/codeql-workshop-dataflow-c/tests-common/test_part1.c
  # --------          -------  ---                            -------
  #     3280              880  73%                            1 file

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,

  int copy_mem(unsigned int unused, dyn_input_t *input,
               unsigned int input_types) {...}

from ./tests-common/test_part1.c

  # 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