diff --git a/pkg/appsec/query_utils.go b/pkg/appsec/query_utils.go index 4a45408bcc4..058a6313317 100644 --- a/pkg/appsec/query_utils.go +++ b/pkg/appsec/query_utils.go @@ -8,13 +8,13 @@ import ( ) // parseQuery and parseQuery are copied net/url package, but allow semicolon in values -func ParseQuery(query string) (url.Values, error) { +func ParseQuery(query string) url.Values { m := make(url.Values) - err := parseQuery(m, query) - return m, err + parseQuery(m, query) + return m } -func parseQuery(m url.Values, query string) (err error) { +func parseQuery(m url.Values, query string) { for query != "" { var key string key, query, _ = strings.Cut(query, "&") @@ -28,7 +28,7 @@ func parseQuery(m url.Values, query string) (err error) { value = unescape(value) m[key] = append(m[key], value) } - return err + return } func hexDigitToByte(digit byte) (byte, bool) { diff --git a/pkg/appsec/query_utils_test.go b/pkg/appsec/query_utils_test.go index 4cc0e74f3ce..2ad7927968d 100644 --- a/pkg/appsec/query_utils_test.go +++ b/pkg/appsec/query_utils_test.go @@ -198,10 +198,7 @@ func TestParseQuery(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - res, err := ParseQuery(test.query) - if err != nil { - t.Fatalf("unexpected error: %s", err) - } + res := ParseQuery(test.query) if !reflect.DeepEqual(res, test.expected) { t.Fatalf("unexpected result: %v", res) } diff --git a/pkg/appsec/request.go b/pkg/appsec/request.go index 36770789aec..effb1828307 100644 --- a/pkg/appsec/request.go +++ b/pkg/appsec/request.go @@ -355,11 +355,6 @@ func NewParsedRequestFromRequest(r *http.Request, logger *logrus.Entry) (ParsedR } } - parsed_args, err := ParseQuery(parsedURL.RawQuery) - if err != nil { - logger.Debugf("While parsing query %s : %s", parsedURL.RawQuery, err) - } - return ParsedRequest{ RemoteAddr: r.RemoteAddr, UUID: uuid.New().String(), @@ -372,7 +367,7 @@ func NewParsedRequestFromRequest(r *http.Request, logger *logrus.Entry) (ParsedR URL: r.URL, Proto: r.Proto, Body: body, - Args: parsed_args, + Args: ParseQuery(parsedURL.RawQuery), TransferEncoding: r.TransferEncoding, ResponseChannel: make(chan AppsecTempResponse), RemoteAddrNormalized: remoteAddrNormalized,