Skip to content

Commit

Permalink
csi: Fix parsing of '=' in secrets at command line and HTTP (#15670)
Browse files Browse the repository at this point in the history
The command line flag parsing and the HTTP header parsing for CSI secrets
incorrectly split at more than one '=' rune, making it impossible to use secrets
that included that rune.
  • Loading branch information
tgross committed Jan 3, 2023
1 parent e27e1c6 commit 9b068bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .changelog/15670.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
csi: Fixed a bug where secrets that include '=' were incorrectly rejected
```
11 changes: 5 additions & 6 deletions command/agent/csi_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ func (s *HTTPServer) csiSnapshotDelete(resp http.ResponseWriter, req *http.Reque
query := req.URL.Query()
snap.PluginID = query.Get("plugin_id")
snap.ID = query.Get("snapshot_id")

secrets := query["secret"]
for _, raw := range secrets {
secret := strings.Split(raw, "=")
if len(secret) == 2 {
snap.Secrets[secret[0]] = secret[1]
if key, value, found := strings.Cut(raw, "="); found {
snap.Secrets[key] = value
}
}

Expand Down Expand Up @@ -340,9 +340,8 @@ func (s *HTTPServer) csiSnapshotList(resp http.ResponseWriter, req *http.Request
secrets := strings.Split(querySecrets[0], ",")
args.Secrets = make(structs.CSISecrets)
for _, raw := range secrets {
secret := strings.Split(raw, "=")
if len(secret) == 2 {
args.Secrets[secret[0]] = secret[1]
if key, value, found := strings.Cut(raw, "="); found {
args.Secrets[key] = value
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions command/volume_snapshot_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ func (c *VolumeSnapshotDeleteCommand) Run(args []string) int {

secrets := api.CSISecrets{}
for _, kv := range secretsArgs {
s := strings.Split(kv, "=")
if len(s) == 2 {
secrets[s[0]] = s[1]
if key, value, found := strings.Cut(kv, "="); found {
secrets[key] = value
}
}

Expand Down

0 comments on commit 9b068bd

Please sign in to comment.