Fuzz introspector
For issues and ideas: https://github.com/ossf/fuzz-introspector/issues

Fuzzer details

Fuzzer: fuzz_parser

Call tree

The calltree shows the control flow of the fuzzer. This is overlaid with coverage information to display how much of the potential code a fuzzer can reach is in fact covered at runtime. In the following there is a link to a detailed calltree visualisation as well as a bitmap showing a high-level view of the calltree. For further information about these topics please see the glossary for full calltree and calltree overview

Call tree overview bitmap:

The distribution of callsites in terms of coloring is
Color Runtime hitcount Callsite count Percentage
red 0 6968 87.8%
gold [1:9] 183 2.30%
yellow [10:29] 50 0.63%
greenyellow [30:49] 6 0.07%
lawngreen 50+ 728 9.17%
All colors 7935 100

Fuzz blockers

The followings are the branches where fuzzer fails to bypass.

Unique non-covered Complexity Unique Reachable Complexities Unique Reachable Functions All non-covered Complexity All Reachable Complexity Function Name Function Callsite Blocked Branch
886 2681 6 :

['errstart_cold', 'errmsg', 'MemoryContextStats', 'errdetail', 'errcode', 'errfinish']

886 2681 AllocSetContextCreateInternal call site: 00006 /src/libpg_query/src/postgres/src_backend_utils_mmgr_aset.c:490
687 735 7 :

['fflush', 'EmitErrorReport', 'pfree', 'MemoryContextSwitchTo.267', 'ProcessInterrupts', 'proc_exit', 'abort']

687 735 errfinish call site: 00000 /src/libpg_query/src/postgres/src_backend_utils_error_elog.c:603
444 1353 3 :

['errstart_cold', 'errmsg_internal', 'errfinish']

444 1353 hexval call site: 00349 /src/libpg_query/src/postgres/src_backend_parser_parser.c:323
444 1353 3 :

['errstart_cold', 'errmsg_internal', 'errfinish']

444 1353 errstart call site: 00097 /src/libpg_query/src/postgres/src_backend_utils_error_elog.c:471
444 444 1 :

['errmsg_internal']

444 1353 enlargeStringInfo call site: 00773 /src/libpg_query/src/postgres/src_common_stringinfo.c:284
231 231 2 :

['write_stderr', 'exit']

231 231 errstart call site: 00084 /src/libpg_query/src/postgres/src_backend_utils_error_elog.c:439
7 7 1 :

['flushbuffer']

7 7 dostr call site: 00016 /src/libpg_query/src/postgres/src_port_snprintf.c:1337
7 7 1 :

['flushbuffer']

7 7 dopr_outch call site: 00016 /src/libpg_query/src/postgres/src_port_snprintf.c:1359
5 5 1 :

['cliplen']

5 5 pg_encoding_mbcliplen call site: 00279 /src/libpg_query/src/postgres/src_backend_utils_mb_mbutils.c:428
2 1797 5 :

['errstart_cold', 'errmsg', 'errcode', 'errfinish', 'GetDatabaseEncodingName']

2 1797 pg_unicode_to_server call site: 00231 /src/libpg_query/src/postgres/src_backend_utils_mb_mbutils.c:318
2 464 2 :

['truncate_identifier', 'strlen']

2 464 base_yylex call site: 00380 /src/libpg_query/src/postgres/src_backend_parser_parser.c:297
0 448 1 :

['new_list']

0 448 list_copy call site: 00802 /src/libpg_query/src/postgres/src_backend_nodes_list.c:906

Runtime coverage analysis

Covered functions
301
Functions that are reachable but not covered
1114
Reachable functions
1373
Percentage of reachable functions covered
18.86%
NB: The sum of covered functions and functions that are reachable but not covered need not be equal to Reachable functions . This is because the reachability analysis is an approximation and thus at runtime some functions may be covered that are not included in the reachability analysis. This is a limitation of our static analysis capabilities.
Function name source code lines source lines hit percentage hit

Files reached

filename functions hit
./test/fuzz/fuzz_parser.c 1
src/pg_query_parse.c 3
src/pg_query.c 6
src/postgres/src_backend_utils_mmgr_mcxt.c 19
src/postgres/src_backend_utils_mmgr_aset.c 2
src/postgres/src_port_snprintf.c 20
src/postgres/src_port_strnlen.c 1
src/postgres/src_port_strerror.c 3
src/postgres/src_backend_utils_error_elog.c 11
src/postgres/src_backend_utils_mb_mbutils.c 12
./src/postgres/include/utils/palloc.h 1
src/postgres/src_backend_parser_parser.c 6
scan.l 18
scan.c 16
./src/postgres/include/utils/memutils.h 1
gram.y 43
gram.c 1
./src/postgres/include/port/pg_bitutils.h 2
src/postgres/src_common_kwlookup.c 1
./src/postgres/include/common/kwlookup.h 1
./src/postgres/include/mb/pg_wchar.h 4
src/postgres/src_common_wchar.c 3
src/postgres/src_backend_parser_scansup.c 4
/usr/include/stdlib.h 1
src/postgres/src_common_string.c 1
src/postgres/src_backend_nodes_list.c 19
./src/postgres/include/nodes/pg_list.h 5
src/postgres/src_backend_nodes_value.c 4
src/postgres/src_backend_nodes_makefuncs.c 12
src/postgres/src_common_psprintf.c 2
src/postgres/src_backend_commands_define.c 1
src/postgres/src_backend_catalog_namespace.c 1
src/postgres/src_common_stringinfo.c 8
src/postgres/src_backend_nodes_copyfuncs.c 300
src/postgres/src_backend_tcop_postgres.c 1
src/postgres/src_backend_nodes_bitmapset.c 3
src/postgres/src_backend_utils_adt_datum.c 3
src/postgres/src_backend_utils_adt_expandeddatum.c 3
src/postgres/src_backend_nodes_extensible.c 2
src/postgres/src_backend_nodes_equalfuncs.c 241
src/postgres/src_backend_nodes_nodeFuncs.c 2
src/pg_query_outfuncs_json.c 11
src/pg_query_outfuncs_defs.c 227
src/pg_query_json_helper.c 2
src/pg_query_enum_defs.c 51

Analyses and suggestions

Optimal target analysis

Remaining optimal interesting functions

The following table shows a list of functions that are optimal targets. Optimal targets are identified by finding the functions that in combination, yield a high code coverage.

Func name Functions filename Arg count Args Function depth hitcount instr count bb count cyclomatic complexity Reachable functions Incoming references total cyclomatic complexity Unreached complexity
protobuf_c_message_unpack /src/libpg_query/vendor/protobuf-c/protobuf-c.c 4 ['struct.ProtobufCMessageDescriptor *', 'struct.ProtobufCAllocator *', 'size_t', 'char *'] 11 0 1029 170 61 30 248 337 337
pg_query_parse_protobuf /src/libpg_query/src/pg_query_parse.c 2 ['struct.PgQueryProtobufParseResult *', 'char *'] 24 0 42 3 2 1409 0 7137 227
raw_expression_tree_walker /src/libpg_query/src/postgres/src_backend_nodes_nodeFuncs.c 3 ['struct.Node *', 'func_type *', 'char *'] 26 0 1752 294 112 85 0 554 112
protobuf_c_message_check /src/libpg_query/vendor/protobuf-c/protobuf-c.c 1 ['struct.ProtobufCMessage *'] 2 0 401 86 38 1 1 76 76
protobuf_c_message_pack_to_buffer /src/libpg_query/vendor/protobuf-c/protobuf-c.c 2 ['struct.ProtobufCMessage *', 'struct.ProtobufCBuffer.1141 *'] 11 0 180 29 11 37 248 205 70
pg_utf8_verifystr /src/libpg_query/src/postgres/src_common_wchar.c 2 ['char *', 'int'] 2 0 169 35 14 5 0 49 44
AllocSetRealloc /src/libpg_query/src/postgres/src_backend_utils_mmgr_aset.c 3 ['struct.MemoryContextData *', 'char *', 'size_t'] 25 0 172 28 11 88 0 481 41

Implementing fuzzers that target the above functions will improve reachability such that it becomes:

Functions statically reachable by fuzzers
51.0%
1435 / 2804
Cyclomatic complexity statically reachable by fuzzers
70.0%
7664 / 11027

All functions overview

If you implement fuzzers for these functions, the status of all functions in the project will be:

Func name Functions filename Args Function call depth Reached by Fuzzers Fuzzers runtime hit Func lines hit % I Count BB Count Cyclomatic complexity Functions reached Reached by functions Accumulated cyclomatic complexity Undiscovered complexity

Files and Directories in report

This section shows which files and directories are considered in this report. The main reason for showing this is fuzz introspector may include more code in the reasoning than is desired. This section helps identify if too many files/directories are included, e.g. third party code, which may be irrelevant for the threat model. In the event too much is included, fuzz introspector supports a configuration file that can exclude data from the report. See the following link for more information on how to create a config file: link

Files in report

Source file Reached by Covered by
[] []
/src/libpg_query/src/postgres/src_common_kwlookup.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/pg_query_parse.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_utils_error_assert.c [] []
/src/libpg_query/./test/fuzz/fuzz_parser.c ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_common_stringinfo.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_common_string.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_parser_scansup.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_utils_adt_expandeddatum.c ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_backend_utils_adt_datum.c ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_backend_utils_mmgr_mcxt.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_nodes_list.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_nodes_copyfuncs.c ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_backend_nodes_bitmapset.c ['fuzz_parser'] []
/src/libpg_query/vendor/protobuf-c/protobuf-c.c [] []
/src/libpg_query/./src/postgres/include/nodes/pg_list.h ['fuzz_parser'] []
/src/libpg_query/scan.l ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_utils_error_elog.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_commands_define.c ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_port_strerror.c ['fuzz_parser'] []
/src/libpg_query/gram.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/gram.y ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_port_strnlen.c ['fuzz_parser'] []
/src/libpg_query/./src/postgres/include/port/pg_bitutils.h ['fuzz_parser'] []
/src/libpg_query/./src/postgres/include/kwlist_d.h [] []
/src/libpg_query/protobuf/pg_query.pb-c.c [] []
/src/libpg_query/./src/postgres/include/mb/pg_wchar.h ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_backend_nodes_equalfuncs.c ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_backend_nodes_makefuncs.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_utils_mmgr_aset.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_nodes_extensible.c ['fuzz_parser'] []
/src/libpg_query/src/pg_query_enum_defs.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/pg_query_outfuncs_json.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_nodes_value.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/pg_query_json_helper.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/scan.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_common_wchar.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_tcop_postgres.c ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_backend_utils_mb_mbutils.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/./src/postgres/include/utils/palloc.h ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_port_snprintf.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_port_pg_bitutils.c [] []
/src/libpg_query/src/postgres/src_common_psprintf.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/pg_query.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_parser_parser.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/./src/postgres/include/utils/memutils.h ['fuzz_parser'] []
/usr/include/stdlib.h ['fuzz_parser'] []
/src/libpg_query/src/pg_query_outfuncs_protobuf.c [] []
/src/libpg_query/src/postgres/src_backend_storage_ipc_ipc.c [] []
/src/libpg_query/src/pg_query_outfuncs_defs.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/src/postgres/src_backend_nodes_nodeFuncs.c ['fuzz_parser'] ['fuzz_parser']
/src/libpg_query/./src/postgres/include/common/kwlookup.h ['fuzz_parser'] []
/src/libpg_query/src/postgres/src_backend_catalog_namespace.c ['fuzz_parser'] []

Directories in report

Directory
/src/libpg_query/./src/postgres/include/port/
/src/libpg_query/src/
/src/libpg_query/src/postgres/
/src/libpg_query/./src/postgres/include/common/
/src/libpg_query/vendor/protobuf-c/
/src/libpg_query/./src/postgres/include/
/src/libpg_query/./test/fuzz/
/src/libpg_query/./src/postgres/include/nodes/
/src/libpg_query/
/src/libpg_query/./src/postgres/include/utils/
/src/libpg_query/protobuf/
/usr/include/
/src/libpg_query/./src/postgres/include/mb/