Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/admin-guide/configuration/hrw4u.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ cond %{INBOUND:<C>} {in,out}bound.conn.<c> inbound (:r

- ``inbound.req.<header>`` → ``CLIENT-HEADER`` - Headers from the client request
- ``outbound.req.<header>`` → ``SERVER-HEADER`` - Headers in the request sent to origin
- ``inbound.url.<part>`` → ``CLIENT-URL`` - URL from the original client request
- ``inbound.url.<part>`` → ``CLIENT-URL`` - URL from the original client request (which is immutable)
- ``outbound.url.<part>`` → ``SERVER-URL`` - URL in the request sent to origin (after remapping)
- ``nexthop.<field>`` → ``NEXT-HOP`` - Network destination info (host, port, strategy)

Expand Down Expand Up @@ -319,7 +319,7 @@ add-header X-bar foo inbound.{req,resp}.x-Bar += "bar" Add the header t
counter my_stat counter("my_stat") Increment internal counter
rm-client-header X-Foo inbound.req.X-Foo = "" Remove a client request header
rm-cookie foo {in,out}bound.cookie.foo = "" Remove the cookie named foo
rm-destination <C> inbound.url.<C> = "" Remove an URL component, ``C`` is path, query etc.
rm-destination <C> outbound.url.<C> = "" Remove an URL component, ``C`` is path, query etc.
rm-header X-Foo {in,out}bound.req.X-Foo = "" Context sensitive header removal
rm-destination QUERY ... remove_query("foo,bar") Remove specified query keys
rm-destination QUERY ... [I] keep_query("foo,bar") Keep only specified query keys
Expand All @@ -330,7 +330,7 @@ set-config <name> 12 set-config("name", 17) Set a configurat
set-conn-dscp 8 inbound.conn.dscp = 8 Set the DSCP value for the connection
set-conn-mark 17 inbound.conn.mark = 17 Set the MARK value for the connection
set-cookie foo bar {in,out}bound.cookie.foo = "bar" Set a request/response cookie named foo
set-destination <C> bar {in,out}bound.url.<C> = "bar" Set a URL component, <:ref:`C<admin-plugins-header-rewrite-url-parts>`> is path, query etc.
set-destination <C> bar outbound.url.<C> = "bar" Set a URL component, <:ref:`C<admin-plugins-header-rewrite-url-parts>`> is path, query etc.
set-header X-Bar foo inbound.{req,resp}.X-Bar = "foo" Assign a client request/origin response header
set-plugin-cntl <C> <T> set-plugin-cntl(<C>) = <T> Set the plugin control <C> to <T>, see <:ref:`C<admin-plugins-header-rewrite-plugin-cntl>`>
set-redirect <Code> <URL> set-redirect(302, "\https://...") Set a redirect response
Expand Down Expand Up @@ -1075,7 +1075,7 @@ Remove Client Query Parameters
The following ruleset removes any query parameters set by the client.::

REMAP {
inbound.url.query = "";
outbound.url.query = "";
}

Remove only a few select query parameters::
Expand Down
4 changes: 2 additions & 2 deletions tools/hrw4u/src/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def generate_context_mappings(self) -> dict[str, dict[SectionType | frozenset[Se
},
"URL_CONTEXT_MAP":
{
SectionType.REMAP: "inbound.url.",
frozenset({SectionType.PRE_REMAP, SectionType.READ_REQUEST, SectionType.SEND_REQUEST}): "outbound.url."
frozenset({SectionType.REMAP, SectionType.PRE_REMAP, SectionType.READ_REQUEST,
SectionType.SEND_REQUEST}): "outbound.url."
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/hrw4u/src/hrw_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def op_to_hrw4u(self, cmd: str, args: list[str], section: SectionType | None, op
if len(args) > 1:
func = "keep_query" if op_state.invert else "remove_query"
return f"{func}({self._rewrite_inline_percents(args[1], section)})"
return 'inbound.url.query = ""'
return f'{self.get_prefix_for_context("destination_ops", section)}query = ""'

toks = [cmd] + args
line = " ".join(toks)
Expand Down
3 changes: 1 addition & 2 deletions tools/hrw4u/src/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"inbound.resp.": MapParams(target=HeaderOperations.OPERATIONS, add=True, validate=Validator.http_header_name(), sections={SectionType.READ_RESPONSE, SectionType.SEND_RESPONSE}),
"inbound.status.reason": MapParams(target="set-status-reason", validate=Validator.quoted_or_simple(), sections=HTTP_SECTIONS),
"inbound.status": MapParams(target="set-status", validate=Validator.range(0, 999), sections=HTTP_SECTIONS),
"inbound.url.": MapParams(target=HeaderOperations.DESTINATION_OPERATIONS, upper=True, validate=Validator.suffix_group(SuffixGroup.URL_FIELDS), sections=HTTP_SECTIONS),
"outbound.cookie.": MapParams(target=HeaderOperations.COOKIE_OPERATIONS, validate=Validator.http_token(), sections={SectionType.SEND_REQUEST, SectionType.READ_RESPONSE, SectionType.SEND_RESPONSE}),
"outbound.req.": MapParams(target=HeaderOperations.OPERATIONS, add=True, validate=Validator.http_header_name(), sections={SectionType.SEND_REQUEST, SectionType.READ_RESPONSE, SectionType.SEND_RESPONSE}),
"outbound.resp.": MapParams(target=HeaderOperations.OPERATIONS, add=True, validate=Validator.http_header_name(), sections={SectionType.READ_RESPONSE, SectionType.SEND_RESPONSE}),
Expand Down Expand Up @@ -156,7 +155,7 @@
"header_condition": ("HEADER_CONTEXT_MAP", "inbound.resp."),
"header_ops": ("HEADER_CONTEXT_MAP", "inbound.resp."),
"cookie_ops": "inbound.cookie.",
"destination_ops": ("URL_CONTEXT_MAP", "inbound.url.")
"destination_ops": ("URL_CONTEXT_MAP", "outbound.url.")
}

# Operator command mappings for reverse resolution
Expand Down
2 changes: 1 addition & 1 deletion tools/hrw4u/tests/data/examples/all-nonsense.ast.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tools/hrw4u/tests/data/examples/all-nonsense.input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ PRE_REMAP {

REMAP {
if (from.url.host == "old.example.com" with NOCASE) {
inbound.url.host = "new.example.com";
outbound.url.host = "new.example.com";
keep_query("id,utm_campaign");
}

if (to.url.path ~ /(?i)^\/legacy\//) {
inbound.url.path = "/v2/";
outbound.url.path = "/v2/";
remove_query("debug,trace");
}

Expand Down
2 changes: 1 addition & 1 deletion tools/hrw4u/tests/data/examples/rm-query.ast.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(program (programItem (section REMAP { (sectionBody (statement inbound.url.query = (value "") ;)) (sectionBody (statement (functionCall remove_query ( (argumentList (value "foo,bar")) )) ;)) (sectionBody (statement (functionCall keep_query ( (argumentList (value "foo,bar")) )) ;)) })) <EOF>)
(program (programItem (section REMAP { (sectionBody (statement outbound.url.query = (value "") ;)) (sectionBody (statement (functionCall remove_query ( (argumentList (value "foo,bar")) )) ;)) (sectionBody (statement (functionCall keep_query ( (argumentList (value "foo,bar")) )) ;)) })) <EOF>)
2 changes: 1 addition & 1 deletion tools/hrw4u/tests/data/examples/rm-query.input.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REMAP {
inbound.url.query = "";
outbound.url.query = "";
remove_query("foo,bar");
keep_query("foo,bar");
}
2 changes: 1 addition & 1 deletion tools/hrw4u/tests/data/ops/bad_path.fail.error.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tests/data/ops/bad_path.fail.input.txt:2:2: error: Invalid suffix 'ATH' for group 'URL_FIELDS'. Must be one of: HOST, PATH, PORT, QUERY, SCHEME, URL
2 | inbound.url.ath="foo";
2 | outbound.url.ath="foo";
| ^
2 changes: 1 addition & 1 deletion tools/hrw4u/tests/data/ops/bad_path.fail.input.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REMAP {
inbound.url.ath="foo";
outbound.url.ath="foo";
}
2 changes: 1 addition & 1 deletion tools/hrw4u/tests/data/ops/set-destination.ast.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(program (programItem (section REMAP { (sectionBody (statement inbound.url.host = (value "foo") ;)) })) (programItem (section SEND_REQUEST { (sectionBody (statement outbound.url.path = (value "foo/bar.txt") ;)) })) <EOF>)
(program (programItem (section REMAP { (sectionBody (statement outbound.url.host = (value "foo") ;)) })) (programItem (section SEND_REQUEST { (sectionBody (statement outbound.url.path = (value "foo/bar.txt") ;)) })) <EOF>)
2 changes: 1 addition & 1 deletion tools/hrw4u/tests/data/ops/set-destination.input.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REMAP {
inbound.url.host = "foo";
outbound.url.host = "foo";
}

SEND_REQUEST {
Expand Down