LCOV - differential code coverage report
Current view: top level - src/backend/libpq - be-fe-helpers.c (source / functions) Coverage Total Hit UBC CBC
Current: 4b3c9325757dfd8f2312e9f1a8decf4431f344ae vs e87b024bfb8dd55e3049b1b6e6ab4e810cf1abc8 Lines: 46.3 % 123 57 66 57
Current Date: 2026-11-28 16:48:44 +0900 Functions: 100.0 % 1 1 1
Baseline: lcov-20261128-baseline Branches: 41.5 % 106 44 62 44
Baseline Date: 2026-11-28 16:48:48 +0900 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(7,30] days: 46.3 % 123 57 66 57
Function coverage date bins:
(7,30] days: 100.0 % 1 1 1
Branch coverage date bins:
(7,30] days: 41.5 % 106 44 62 44

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * be-fe-helpers.c
                                  4                 :                :  *    Helper functions for using libpq in extensions
                                  5                 :                :  *
                                  6                 :                :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
                                  7                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                  8                 :                :  *
                                  9                 :                :  *-------------------------------------------------------------------------
                                 10                 :                :  */
                                 11                 :                : 
                                 12                 :                : #include "postgres.h"
                                 13                 :                : 
                                 14                 :                : /*
                                 15                 :                :  * XXX: This is duplicated from libpq-be-fe-helpers.h, because including that
                                 16                 :                :  * header in backend source files is prohibited. Be sure to update its copy if
                                 17                 :                :  * this signature changes.
                                 18                 :                :  */
                                 19                 :                : extern bool libpqsrv_is_valid_proxy_option(const char *keyword);
                                 20                 :                : 
                                 21                 :                : /*
                                 22                 :                :  * Is the named libpq connection option known to be safe for an otherwise-
                                 23                 :                :  * unprivileged user to set on an outgoing connection, whether in a server
                                 24                 :                :  * extension, FDW, subscription, or otherwise?
                                 25                 :                :  *
                                 26                 :                :  * The vast majority of libpq-be-fe-helpers.h is `static inline`, but the
                                 27                 :                :  * safelist is kept here so that we can update it without recompiling dependent
                                 28                 :                :  * extensions. Since we must maintain safety with future versions of libpq, new
                                 29                 :                :  * known-safe options must unfortunately be backpatched into prior branches as
                                 30                 :                :  * needed.
                                 31                 :                :  */
                                 32                 :                : bool
   19 jchampion@postgresql       33                 :CBC        3658 : libpqsrv_is_valid_proxy_option(const char *keyword)
                                 34                 :                : {
                                 35                 :                :     /*-
                                 36                 :                :      * NB: When modifying this list, ask yourself:
                                 37                 :                :      * - Can this new option be used to write local files, disclose server
                                 38                 :                :      *   secrets, or bypass proxy authentication requirements?
                                 39                 :                :      * - When will you backpatch this addition to supported branches?
                                 40                 :                :      */
                                 41   [ +  +  +  +  :           3658 :     switch (keyword[0])
                                     -  +  -  -  -  
                                     +  +  +  +  -  
                                              +  - ]
                                 42                 :                :     {
                                 43                 :            283 :         case 'a':
                                 44         [ +  - ]:            283 :             if (strcmp(keyword, "application_name") == 0)
                                 45                 :            283 :                 return true;
   19 jchampion@postgresql       46                 :UBC           0 :             break;
                                 47                 :                : 
   19 jchampion@postgresql       48                 :CBC          91 :         case 'c':
                                 49         [ -  + ]:             91 :             if (strcmp(keyword, "channel_binding") == 0)
   19 jchampion@postgresql       50                 :UBC           0 :                 return true;
   19 jchampion@postgresql       51         [ +  - ]:CBC          91 :             if (strcmp(keyword, "client_encoding") == 0)
                                 52                 :             91 :                 return true;
   19 jchampion@postgresql       53         [ #  # ]:UBC           0 :             if (strcmp(keyword, "connect_timeout") == 0)
                                 54                 :              0 :                 return true;
                                 55                 :              0 :             break;
                                 56                 :                : 
   19 jchampion@postgresql       57                 :CBC        1119 :         case 'd':
                                 58         [ +  - ]:           1119 :             if (strcmp(keyword, "dbname") == 0)
                                 59                 :           1119 :                 return true;
   19 jchampion@postgresql       60                 :UBC           0 :             break;
                                 61                 :                : 
   19 jchampion@postgresql       62                 :CBC          91 :         case 'f':
                                 63         [ +  - ]:             91 :             if (strcmp(keyword, "fallback_application_name") == 0)
                                 64                 :             91 :                 return true;
   19 jchampion@postgresql       65                 :UBC           0 :             break;
                                 66                 :                : 
                                 67                 :              0 :         case 'g':
                                 68         [ #  # ]:              0 :             if (strcmp(keyword, "gssdelegation") == 0)
                                 69                 :              0 :                 return true;
                                 70         [ #  # ]:              0 :             if (strcmp(keyword, "gssencmode") == 0)
                                 71                 :              0 :                 return true;
                                 72         [ #  # ]:              0 :             if (strcmp(keyword, "gsslib") == 0)
                                 73                 :              0 :                 return true;
                                 74                 :              0 :             break;
                                 75                 :                : 
   19 jchampion@postgresql       76                 :CBC         862 :         case 'h':
                                 77         [ +  - ]:            862 :             if (strcmp(keyword, "host") == 0)
                                 78                 :            862 :                 return true;
   19 jchampion@postgresql       79         [ #  # ]:UBC           0 :             if (strcmp(keyword, "hostaddr") == 0)
                                 80                 :              0 :                 return true;
                                 81                 :              0 :             break;
                                 82                 :                : 
                                 83                 :              0 :         case 'k':
                                 84         [ #  # ]:              0 :             if (strcmp(keyword, "keepalives") == 0)
                                 85                 :              0 :                 return true;
                                 86         [ #  # ]:              0 :             if (strcmp(keyword, "keepalives_count") == 0)
                                 87                 :              0 :                 return true;
                                 88         [ #  # ]:              0 :             if (strcmp(keyword, "keepalives_idle") == 0)
                                 89                 :              0 :                 return true;
                                 90         [ #  # ]:              0 :             if (strcmp(keyword, "keepalives_interval") == 0)
                                 91                 :              0 :                 return true;
                                 92         [ #  # ]:              0 :             if (strcmp(keyword, "krbsrvname") == 0)
                                 93                 :              0 :                 return true;
                                 94                 :              0 :             break;
                                 95                 :                : 
                                 96                 :              0 :         case 'l':
                                 97         [ #  # ]:              0 :             if (strcmp(keyword, "load_balance_hosts") == 0)
                                 98                 :              0 :                 return true;
                                 99                 :              0 :             break;
                                100                 :                : 
                                101                 :              0 :         case 'm':
                                102         [ #  # ]:              0 :             if (strcmp(keyword, "max_protocol_version") == 0)
                                103                 :              0 :                 return true;
                                104         [ #  # ]:              0 :             if (strcmp(keyword, "min_protocol_version") == 0)
                                105                 :              0 :                 return true;
                                106                 :              0 :             break;
                                107                 :                : 
   19 jchampion@postgresql      108                 :CBC          14 :         case 'o':
                                109                 :                : 
                                110                 :                :             /*
                                111                 :                :              * oauth_* options are not ready for server-side use, due to the
                                112                 :                :              * builtin flow's use of stderr and the inability to constrain the
                                113                 :                :              * issuer.
                                114                 :                :              */
                                115                 :                : 
                                116                 :                :             /* if (strcmp(keyword, "oauth_ca_file") == 0) */
                                117                 :                :             /* if (strcmp(keyword, "oauth_client_id") == 0) */
                                118                 :                :             /* if (strcmp(keyword, "oauth_client_secret") == 0) */
                                119                 :                :             /* if (strcmp(keyword, "oauth_issuer") == 0) */
                                120                 :                :             /* if (strcmp(keyword, "oauth_scope") == 0) */
                                121                 :                : 
                                122         [ +  + ]:             14 :             if (strcmp(keyword, "options") == 0)
                                123                 :              9 :                 return true;
                                124                 :              5 :             break;
                                125                 :                : 
                                126                 :            990 :         case 'p':
                                127         [ -  + ]:            990 :             if (strcmp(keyword, "passfile") == 0)
   19 jchampion@postgresql      128                 :UBC           0 :                 return true;
   19 jchampion@postgresql      129         [ +  + ]:CBC         990 :             if (strcmp(keyword, "password") == 0)
                                130                 :             17 :                 return true;
                                131         [ +  - ]:            973 :             if (strcmp(keyword, "port") == 0)
                                132                 :            973 :                 return true;
   19 jchampion@postgresql      133                 :UBC           0 :             break;
                                134                 :                : 
   19 jchampion@postgresql      135                 :CBC           8 :         case 'r':
                                136         [ -  + ]:              8 :             if (strcmp(keyword, "replication") == 0)
   19 jchampion@postgresql      137                 :UBC           0 :                 return true;
   19 jchampion@postgresql      138         [ +  - ]:CBC           8 :             if (strcmp(keyword, "require_auth") == 0)
                                139                 :              8 :                 return true;
   19 jchampion@postgresql      140         [ #  # ]:UBC           0 :             if (strcmp(keyword, "requirepeer") == 0)
                                141                 :              0 :                 return true;
                                142                 :              0 :             break;
                                143                 :                : 
   19 jchampion@postgresql      144                 :CBC         180 :         case 's':
                                145         [ +  + ]:            180 :             if (strcmp(keyword, "scram_client_key") == 0)
                                146                 :              8 :                 return true;
                                147         [ +  + ]:            172 :             if (strcmp(keyword, "scram_server_key") == 0)
                                148                 :              8 :                 return true;
                                149         [ +  + ]:            164 :             if (strcmp(keyword, "service") == 0)
                                150                 :              1 :                 return true;
                                151         [ -  + ]:            163 :             if (strcmp(keyword, "ssl_max_protocol_version") == 0)
   19 jchampion@postgresql      152                 :UBC           0 :                 return true;
   19 jchampion@postgresql      153         [ -  + ]:CBC         163 :             if (strcmp(keyword, "ssl_min_protocol_version") == 0)
   19 jchampion@postgresql      154                 :UBC           0 :                 return true;
   19 jchampion@postgresql      155         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslcert") == 0)
   19 jchampion@postgresql      156                 :UBC           0 :                 return true;
   19 jchampion@postgresql      157         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslcertmode") == 0)
   19 jchampion@postgresql      158                 :UBC           0 :                 return true;
   19 jchampion@postgresql      159         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslcompression") == 0)
   19 jchampion@postgresql      160                 :UBC           0 :                 return true;
   19 jchampion@postgresql      161         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslcrl") == 0)
   19 jchampion@postgresql      162                 :UBC           0 :                 return true;
   19 jchampion@postgresql      163         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslcrldir") == 0)
   19 jchampion@postgresql      164                 :UBC           0 :                 return true;
   19 jchampion@postgresql      165         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslkey") == 0)
   19 jchampion@postgresql      166                 :UBC           0 :                 return true;
                                167                 :                : 
                                168                 :                :             /* sslkeylogfile writes to arbitrary file locations. */
                                169                 :                :             /* if (strcmp(keyword, "sslkeylogfile") == 0) */
                                170                 :                : 
   19 jchampion@postgresql      171         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslmode") == 0)
   19 jchampion@postgresql      172                 :UBC           0 :                 return true;
   19 jchampion@postgresql      173         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslnegotiation") == 0)
   19 jchampion@postgresql      174                 :UBC           0 :                 return true;
   19 jchampion@postgresql      175         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslpassword") == 0)
   19 jchampion@postgresql      176                 :UBC           0 :                 return true;
   19 jchampion@postgresql      177         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslrootcert") == 0)
   19 jchampion@postgresql      178                 :UBC           0 :                 return true;
   19 jchampion@postgresql      179         [ -  + ]:CBC         163 :             if (strcmp(keyword, "sslsni") == 0)
   19 jchampion@postgresql      180                 :UBC           0 :                 return true;
   19 jchampion@postgresql      181                 :CBC         163 :             break;
                                182                 :                : 
   19 jchampion@postgresql      183                 :UBC           0 :         case 't':
                                184         [ #  # ]:              0 :             if (strcmp(keyword, "target_session_attrs") == 0)
                                185                 :              0 :                 return true;
                                186         [ #  # ]:              0 :             if (strcmp(keyword, "tcp_user_timeout") == 0)
                                187                 :              0 :                 return true;
                                188                 :              0 :             break;
                                189                 :                : 
   19 jchampion@postgresql      190                 :CBC          20 :         case 'u':
                                191         [ +  - ]:             20 :             if (strcmp(keyword, "user") == 0)
                                192                 :             20 :                 return true;
   19 jchampion@postgresql      193                 :UBC           0 :             break;
                                194                 :                :     }
                                195                 :                : 
                                196                 :                :     /* Unknown or disallowed option. */
   19 jchampion@postgresql      197                 :CBC         168 :     return false;
                                198                 :                : }
        

Generated by: LCOV version 2.0-1