vault icon indicating copy to clipboard operation
vault copied to clipboard

Skip Formatting For NIL Secret

Open ltcarbonell opened this issue 2 years ago • 0 comments

Vault is currently panicking when trying to patch with the -field parameter set. This occurs because we are expecting there to be metadata around the secret, but none is getting returned due to the flag being set. A check has been added to ensure that the secret is populated before trying to access the Data from underneath it.

Previous Error:

vault kv patch -field=version  -method=rw -mount=kv /secrets test=- <<< "new"
4
= Secret Path =
kv/data/secrets

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x103aeab1c]

goroutine 1 [running]:
github.com/hashicorp/vault/command.(*KVPatchCommand).Run(0x14000aca440, {0x140001a0030, 0x5, 0x5})
	/Users/runner/work/vault/vault/command/kv_patch.go:232 +0x3fc
github.com/mitchellh/cli.(*CLI).Run(0x1400062edc0)
	/Users/runner/go/pkg/mod/github.com/mitchellh/[email protected]/cli.go:262 +0x4a8
github.com/hashicorp/vault/command.RunCustom({0x140001a0010?, 0x7?, 0x7?}, 0x140000021a0?)
	/Users/runner/work/vault/vault/command/main.go:237 +0x930
github.com/hashicorp/vault/command.Run(...)
	/Users/runner/work/vault/vault/command/main.go:142
main.main()
	/Users/runner/work/vault/vault/main.go:10 +0x54

After change:

vault kv patch -field=version  -method=rw -mount=kv /secrets test=- <<< "new2"     
10
= Secret Path =
kv/data/secrets

ltcarbonell avatar Nov 30 '22 15:11 ltcarbonell