Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vault path-help for selected paths with bad regexps #18571

Merged
merged 7 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions api/plugin_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
// path matches that path or not (useful specifically for the paths that
// contain templated fields.)
var sudoPaths = map[string]*regexp.Regexp{
"/auth/token/accessors/": regexp.MustCompile(`^/auth/token/accessors/?$`),
"/auth/token/accessors": regexp.MustCompile(`^/auth/token/accessors/?$`),
hghaf099 marked this conversation as resolved.
Show resolved Hide resolved
"/pki/root": regexp.MustCompile(`^/pki/root$`),
"/pki/root/sign-self-issued": regexp.MustCompile(`^/pki/root/sign-self-issued$`),
"/sys/audit": regexp.MustCompile(`^/sys/audit$`),
Expand All @@ -50,7 +50,7 @@ var sudoPaths = map[string]*regexp.Regexp{
"/sys/config/auditing/request-headers": regexp.MustCompile(`^/sys/config/auditing/request-headers$`),
"/sys/config/auditing/request-headers/{header}": regexp.MustCompile(`^/sys/config/auditing/request-headers/.+$`),
"/sys/config/cors": regexp.MustCompile(`^/sys/config/cors$`),
"/sys/config/ui/headers/": regexp.MustCompile(`^/sys/config/ui/headers/?$`),
"/sys/config/ui/headers": regexp.MustCompile(`^/sys/config/ui/headers/?$`),
"/sys/config/ui/headers/{header}": regexp.MustCompile(`^/sys/config/ui/headers/.+$`),
"/sys/leases": regexp.MustCompile(`^/sys/leases$`),
"/sys/leases/lookup/": regexp.MustCompile(`^/sys/leases/lookup/?$`),
Expand Down
3 changes: 3 additions & 0 deletions changelog/18571.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
auth/token, sys: Fix path-help being unavailable for some list-only endpoints
```
11 changes: 11 additions & 0 deletions sdk/framework/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ type Path struct {
// This should be a valid regular expression. Named captures will be
// exposed as fields that should map to a schema in Fields. If a named
// capture is not a field in the Fields map, then it will be ignored.
//
// The pattern will automatically have a ^ prepended and a $ appended before
// use, if these are not already present, so these may be omitted for clarity.
//
// If a ListOperation is being defined, the pattern must end with /? to match
// a trailing slash optionally, as ListOperations are always processed with a
// trailing slash added to the path if not already present. The match must not
// require the presence of a trailing slash, as HelpOperations, even for a
// path which only implements ListOperation, are processed without a trailing
// slash - so failure to make the trailing slash optional will break the
// `vault path-help` command for the path.
Pattern string

// Fields is the mapping of data fields to a schema describing that
Expand Down
4 changes: 2 additions & 2 deletions vault/logical_system_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (b *SystemBackend) configPaths() []*framework.Path {
},

{
Pattern: "config/ui/headers/$",
Pattern: "config/ui/headers/?$",

Operations: map[logical.Operation]framework.OperationHandler{
logical.ListOperation: &framework.PathOperation{
Expand Down Expand Up @@ -1426,7 +1426,7 @@ func (b *SystemBackend) statusPaths() []*framework.Path {
HelpDescription: strings.TrimSpace(sysHelp["ha-status"][1]),
},
{
Pattern: "version-history/$",
Pattern: "version-history/?$",

DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "version-history",
Expand Down
2 changes: 1 addition & 1 deletion vault/logical_system_pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func (b *SystemBackend) pprofPaths() []*framework.Path {
return []*framework.Path{
{
Pattern: "pprof/$",
Pattern: "pprof/?$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: "pprof",
Expand Down
2 changes: 1 addition & 1 deletion vault/token_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (ts *TokenStore) paths() []*framework.Path {
},

{
Pattern: "accessors/$",
Pattern: "accessors/?$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
Expand Down