From 29bbf63cb2ee22c67ec27efc19597cb344c4aa27 Mon Sep 17 00:00:00 2001 From: Chris Capurso <1036769+ccapurso@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:47:02 -0400 Subject: [PATCH 1/3] only strip v1 prefix from path if present --- http/handler.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/http/handler.go b/http/handler.go index ceaaf34b457f..c74f392aee75 100644 --- a/http/handler.go +++ b/http/handler.go @@ -1417,7 +1417,13 @@ func respondOIDCPermissionDenied(w http.ResponseWriter) { enc.Encode(oidcResponse) } -// trimPath removes the /v1/ prefix and the namespace from the path +// trimPath removes the /v1/ prefix (if present) and the namespace from the path func trimPath(ns *namespace.Namespace, path string) string { - return ns.TrimmedPath(path[len("/v1/"):]) + const v1Prefix = "/v1/" + + if strings.HasPrefix(path, v1Prefix) { + return ns.TrimmedPath(path[len(v1Prefix):]) + } + + return ns.TrimmedPath(path) } From fc028fd59d5bf7581813c611d723a6ac8cf3802f Mon Sep 17 00:00:00 2001 From: Chris Capurso <1036769+ccapurso@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:02:54 -0400 Subject: [PATCH 2/3] add changelog entry --- changelog/28669.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/28669.txt diff --git a/changelog/28669.txt b/changelog/28669.txt new file mode 100644 index 000000000000..90a1fa434128 --- /dev/null +++ b/changelog/28669.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: Extend panic fix for help request URL paths without /v1/ prefix provided by [#14704](https://github.com/hashicorp/vault/pull/14704). +``` From d404b9f128616d121fb1549e16abb8a019e9069d Mon Sep 17 00:00:00 2001 From: Chris Capurso <1036769+ccapurso@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:47:40 -0400 Subject: [PATCH 3/3] adjust changelog --- changelog/28669.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/28669.txt b/changelog/28669.txt index 90a1fa434128..e2594052edb5 100644 --- a/changelog/28669.txt +++ b/changelog/28669.txt @@ -1,3 +1,3 @@ ```release-note:bug -core: Extend panic fix for help request URL paths without /v1/ prefix provided by [#14704](https://github.com/hashicorp/vault/pull/14704). +core: Fixed panic seen when performing help requests without /v1/ in the URL. ```