Skip to content

Commit

Permalink
Clarifies the :path pseudo-header includes query params (#35)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt authored Oct 10, 2022
1 parent 988df77 commit 1fc643d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ func (ctx *httpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) t
// and its request properties, but they may not be true of other proxies implementing
// proxy-wasm.

path, err := proxywasm.GetHttpRequestHeader(":path")
// Note the pseudo-header :path includes the query.
// See https://httpwg.org/specs/rfc9113.html#rfc.section.8.3.1
uri, err := proxywasm.GetHttpRequestHeader(":path")
if err != nil {
proxywasm.LogCriticalf("failed to get :path: %v", err)
return types.ActionContinue
Expand All @@ -154,7 +156,7 @@ func (ctx *httpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) t

ctx.httpProtocol = string(protocol)

tx.ProcessURI(path, method, ctx.httpProtocol)
tx.ProcessURI(uri, method, ctx.httpProtocol)

hs, err := proxywasm.GetHttpRequestHeaders()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func checkTXMetric(t *testing.T, host proxytest.HostEmulator, expectedCounter in

func TestLifecycle(t *testing.T) {
reqHdrs := [][2]string{
{":path", "/hello"},
{":path", "/hello?name=panda"},
{":method", "GET"},
{":authority", "localhost"},
{"User-Agent", "gotest"},
Expand Down Expand Up @@ -69,7 +69,7 @@ SecRuleEngine On\nSecRule REQUEST_URI \"@streq /admin\" \"id:101,phase:1,t:lower
{
name: "url denied",
inlineRules: `
SecRuleEngine On\nSecRule REQUEST_URI \"@streq /hello\" \"id:101,phase:1,t:lowercase,deny\"
SecRuleEngine On\nSecRule REQUEST_URI \"@streq /hello?name=panda\" \"id:101,phase:1,t:lowercase,deny\"
`,
requestHdrsAction: types.ActionPause,
requestBodyAction: types.ActionContinue,
Expand Down

0 comments on commit 1fc643d

Please sign in to comment.