From fc3a84eb2924b122ce76e86b16f4fcd1084d86f9 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Fri, 15 Nov 2024 11:16:11 +0100 Subject: [PATCH] [#3609] Checkpoint: doing syntax --- doc/examples/agent/comments.json | 10 ++++++++++ doc/examples/agent/simple.json | 15 +++++++++++++++ doc/examples/kea4/all-keys.json | 15 +++++++++++++++ doc/examples/kea6/all-keys.json | 15 +++++++++++++++ src/bin/agent/agent_parser.cc | 1 + src/bin/agent/agent_parser.yy | 5 +++-- src/bin/agent/tests/testdata/get_config.json | 9 +++++++++ src/bin/dhcp4/dhcp4_parser.cc | 1 + src/bin/dhcp4/dhcp4_parser.yy | 5 +++-- src/bin/dhcp6/dhcp6_parser.cc | 1 + src/bin/dhcp6/dhcp6_parser.yy | 5 +++-- 11 files changed, 76 insertions(+), 6 deletions(-) diff --git a/doc/examples/agent/comments.json b/doc/examples/agent/comments.json index 10c82e3fa3..b382a66bc3 100644 --- a/doc/examples/agent/comments.json +++ b/doc/examples/agent/comments.json @@ -18,6 +18,16 @@ // is specifically for HA updates only. "http-port": 8000, + // Extra HTTP headers to add in responses. + "http-headers": + [ + { + "comment": "HSTS header", + "name": "Strict-Transport-Security", + "value": "max-age=31536000" + } + ], + // In authentication "authentication": { diff --git a/doc/examples/agent/simple.json b/doc/examples/agent/simple.json index 7597f652db..fec2c3eef9 100644 --- a/doc/examples/agent/simple.json +++ b/doc/examples/agent/simple.json @@ -15,6 +15,21 @@ // is specifically for HA updates only. "http-port": 8000, + // Extra HTTP headers to add in responses. + "http-headers": + [ + { + // Optional user context. + "user-context": { "comment": "HSTS header" }, + + // Required HTTP header name. + "name": "Strict-Transport-Security", + + // Required HTTP header value. + "value": "max-age=31536000" + } + ], + // Optional authentication. "authentication": { diff --git a/doc/examples/kea4/all-keys.json b/doc/examples/kea4/all-keys.json index b68e6d2f04..0c71d8b9f1 100644 --- a/doc/examples/kea4/all-keys.json +++ b/doc/examples/kea4/all-keys.json @@ -191,6 +191,21 @@ // means they are optional. "cert-required": true, + // Extra HTTP headers to add in responses. + "http-headers": + [ + { + // Optional user context. + "user-context": { "comment": "HSTS header" }, + + // Required HTTP header name. + "name": "Strict-Transport-Security", + + // Required HTTP header value. + "value": "max-age=31536000" + } + ], + // Optional authentication. "authentication": { diff --git a/doc/examples/kea6/all-keys.json b/doc/examples/kea6/all-keys.json index 281627950c..6ac1bb3f83 100644 --- a/doc/examples/kea6/all-keys.json +++ b/doc/examples/kea6/all-keys.json @@ -142,6 +142,21 @@ // means they are optional. "cert-required": true, + // Extra HTTP headers to add in responses. + "http-headers": + [ + { + // Optional user context. + "user-context": { "comment": "HSTS header" }, + + // Required HTTP header name. + "name": "Strict-Transport-Security", + + // Required HTTP header value. + "value": "max-age=31536000" + } + ], + // Optional authentication. "authentication": { diff --git a/src/bin/agent/agent_parser.cc b/src/bin/agent/agent_parser.cc index 274ec2b257..964208fd31 100644 --- a/src/bin/agent/agent_parser.cc +++ b/src/bin/agent/agent_parser.cc @@ -1138,6 +1138,7 @@ namespace isc { namespace agent { ctx.unique("http-headers", ctx.loc2pos(yystack_[0].location)); ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("http-headers", l); + ctx.stack_.push_back(l); ctx.enter(ctx.HTTP_HEADERS); } #line 1144 "agent_parser.cc" diff --git a/src/bin/agent/agent_parser.yy b/src/bin/agent/agent_parser.yy index 228f5f56dc..9bd07e8900 100644 --- a/src/bin/agent/agent_parser.yy +++ b/src/bin/agent/agent_parser.yy @@ -412,6 +412,7 @@ http_headers: HTTP_HEADERS { ctx.unique("http-headers", ctx.loc2pos(@1)); ElementPtr l(new ListElement(ctx.loc2pos(@1))); ctx.stack_.back()->set("http-headers", l); + ctx.stack_.push_back(l); ctx.enter(ctx.HTTP_HEADERS); } COLON LSQUARE_BRACKET http_header_list RSQUARE_BRACKET { ctx.stack_.pop_back(); @@ -445,7 +446,7 @@ http_header_params: http_header_param ; http_header_param: name - | value + | header_value | user_context | comment | unknown_map_entry @@ -460,7 +461,7 @@ name: NAME { ctx.leave(); }; -value: VALUE { +header_value: VALUE { ctx.unique("value", ctx.loc2pos(@1)); ctx.enter(ctx.NO_KEYWORDS); } COLON STRING { diff --git a/src/bin/agent/tests/testdata/get_config.json b/src/bin/agent/tests/testdata/get_config.json index 3117d66fc3..4072ca3163 100644 --- a/src/bin/agent/tests/testdata/get_config.json +++ b/src/bin/agent/tests/testdata/get_config.json @@ -49,6 +49,15 @@ } } ], + "http-headers": [ + { + "name": "Strict-Transport-Security", + "user-context": { + "comment": "HSTS header" + }, + "value": "max-age=31536000" + } + ], "http-host": "127.0.0.1", "http-port": 8000 } diff --git a/src/bin/dhcp4/dhcp4_parser.cc b/src/bin/dhcp4/dhcp4_parser.cc index 2360f52c56..f24fbd2e96 100644 --- a/src/bin/dhcp4/dhcp4_parser.cc +++ b/src/bin/dhcp4/dhcp4_parser.cc @@ -4176,6 +4176,7 @@ namespace isc { namespace dhcp { ctx.unique("http-headers", ctx.loc2pos(yystack_[0].location)); ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("http-headers", l); + ctx.stack_.push_back(l); ctx.enter(ctx.HTTP_HEADERS); } #line 4182 "dhcp4_parser.cc" diff --git a/src/bin/dhcp4/dhcp4_parser.yy b/src/bin/dhcp4/dhcp4_parser.yy index 8bc762de50..a12cb4a7e5 100644 --- a/src/bin/dhcp4/dhcp4_parser.yy +++ b/src/bin/dhcp4/dhcp4_parser.yy @@ -2657,6 +2657,7 @@ http_headers: HTTP_HEADERS { ctx.unique("http-headers", ctx.loc2pos(@1)); ElementPtr l(new ListElement(ctx.loc2pos(@1))); ctx.stack_.back()->set("http-headers", l); + ctx.stack_.push_back(l); ctx.enter(ctx.HTTP_HEADERS); } COLON LSQUARE_BRACKET http_header_list RSQUARE_BRACKET { ctx.stack_.pop_back(); @@ -2690,13 +2691,13 @@ http_header_params: http_header_param ; http_header_param: name - | value + | header_value | user_context | comment | unknown_map_entry ; -value: VALUE { +header_value: VALUE { ctx.unique("value", ctx.loc2pos(@1)); ctx.enter(ctx.NO_KEYWORD); } COLON STRING { diff --git a/src/bin/dhcp6/dhcp6_parser.cc b/src/bin/dhcp6/dhcp6_parser.cc index a7b925c32f..80eaba0cfd 100644 --- a/src/bin/dhcp6/dhcp6_parser.cc +++ b/src/bin/dhcp6/dhcp6_parser.cc @@ -4331,6 +4331,7 @@ namespace isc { namespace dhcp { ctx.unique("http-headers", ctx.loc2pos(yystack_[0].location)); ElementPtr l(new ListElement(ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("http-headers", l); + ctx.stack_.push_back(l); ctx.enter(ctx.HTTP_HEADERS); } #line 4337 "dhcp6_parser.cc" diff --git a/src/bin/dhcp6/dhcp6_parser.yy b/src/bin/dhcp6/dhcp6_parser.yy index b58f10ac01..583a85a96f 100644 --- a/src/bin/dhcp6/dhcp6_parser.yy +++ b/src/bin/dhcp6/dhcp6_parser.yy @@ -2799,6 +2799,7 @@ http_headers: HTTP_HEADERS { ctx.unique("http-headers", ctx.loc2pos(@1)); ElementPtr l(new ListElement(ctx.loc2pos(@1))); ctx.stack_.back()->set("http-headers", l); + ctx.stack_.push_back(l); ctx.enter(ctx.HTTP_HEADERS); } COLON LSQUARE_BRACKET http_header_list RSQUARE_BRACKET { ctx.stack_.pop_back(); @@ -2832,13 +2833,13 @@ http_header_params: http_header_param ; http_header_param: name - | value + | header_value | user_context | comment | unknown_map_entry ; -value: VALUE { +header_value: VALUE { ctx.unique("value", ctx.loc2pos(@1)); ctx.enter(ctx.NO_KEYWORD); } COLON STRING {