]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: cfgparse: dump the "http-hardening" keywords with -dKcfg
authorWilly Tarreau <w@1wt.eu>
Mon, 26 Oct 2026 17:08:40 +0000 (18:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 4 Nov 2026 21:45:32 +0000 (22:45 +0100)
The keywords of the "http-hardening" section are not registered via the
cfg_kw_list mechanism but through their own table in http.c, so they were
missing from the output of "-dKcfg". Let's have cfg_dump_registered_keywords()
report them by calling dump_http_hardening_kws() once the other sections
were dumped. The function also reports the option numbers for pure options
(those which are not composite).

include/haproxy/http.h
src/cfgparse.c
src/http.c

index 50c47c9b2cce811562413f2d966b3da40c35eba2..d862db6ae58d7333b71e98d70d9d062fd8652fef 100644 (file)
@@ -42,6 +42,7 @@ extern struct http_hdng_prf http_hardening_trusted;
 enum http_meth_t find_http_meth(const char *str, const int len);
 int http_get_status_idx(unsigned int status);
 const char *http_get_reason(unsigned int status);
+void dump_http_hardening_kws();
 struct http_hdng_prf *http_hardening_lookup(const char *name);
 struct http_hdng_prf *http_hardening_resolve(const char *name, char **err);
 void http_status_add_range(long *array, uint low, uint high);
index e6667cbd7144f29806a02edb8863e0d119ef9f53..48b3d8bb9b3f59807618b6121feb966e634c19bc 100644 (file)
@@ -63,6 +63,7 @@
 #include <haproxy/global.h>
 #include <haproxy/http_ana.h>
 #include <haproxy/http_rules.h>
+#include <haproxy/http.h>
 #include <haproxy/http_htx.h>
 #include <haproxy/lb_chash.h>
 #include <haproxy/lb_fas.h>
@@ -3204,6 +3205,10 @@ void cfg_dump_registered_keywords()
 
                }
        }
+
+       /* this section's keywords are not registered via cfg_kw_list */
+       printf("http-hardening\n");
+       dump_http_hardening_kws();
 }
 
 /* these are the config sections handled by default */
index 6a1c6103f47bc3dc9c1dcb80c9b7bc105b65bd8e..143b5eec1525f58de0722709beb4a5edf30af143 100644 (file)
@@ -1772,6 +1772,18 @@ const struct http_hardening_kw http_hardening_kws[] = {
        { NULL, 0 }
 };
 
+/* Dumps the list of known HTTP hardening keywords on stdout, one per line. */
+void dump_http_hardening_kws()
+{
+       const struct http_hardening_kw *kw;
+
+       for (kw = http_hardening_kws; kw->name; kw++)
+               if (kw->mask & (kw->mask - 1)) // more than one bit set
+                       printf("\t%s\n", kw->name);
+               else // single bit, report its position starting at 1
+                       printf("\t%s (%d)\n", kw->name, my_flsl(kw->mask));
+}
+
 /* Declared profiles are indexed by name in <http_hardening_by_name>. They must
  * be declared before being referenced, like for "defaults" sections. The
  * implicit "untrusted" and "trusted" profiles are static, so that they may