sops
sops copied to clipboard
Decrypt with output-type dotenv panics on numbers
Create a file test.yaml
with just one key-value where the value consists of a number (i.e., integer or float). Plain decryption works fine:
$ sops --version
sops 3.7.1 (latest)
$ sops -d test.yaml
number: 123
$
The same call but using --output-type dotenv
panics:
$ sops -d --output-type dotenv test.yaml
panic: interface conversion: interface {} is int, not string
goroutine 1 [running]:
go.mozilla.org/sops/v3/stores/dotenv.(*Store).EmitPlainFile(0x23483b0, 0xc000129560, 0x1, 0x1, 0x0, 0x1da61b0, 0xc000424e40, 0xc0004d1200, 0x20)
/private/tmp/sops-20210408-88082-6m5hl1/sops-3.7.1/stores/dotenv/store.go:122 +0x40f
main.decrypt(0x1da61b0, 0xc000424e40, 0x27c72d0, 0x23483b0, 0x1db2998, 0x23483b0, 0x7ffeefbff03e, 0x9, 0x0, 0x0, ...)
/private/tmp/sops-20210408-88082-6m5hl1/sops-3.7.1/cmd/sops/decrypt.go:47 +0x278
main.main.func1(0xc00018cf20, 0x0, 0xc00018cf20)
/private/tmp/sops-20210408-88082-6m5hl1/sops-3.7.1/cmd/sops/main.go:156 +0x2f8
gopkg.in/urfave/cli%2ev1.HandleAction(0x1a6afc0, 0x1c28b80, 0xc00018cf20, 0xc0004c4100, 0x0)
/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/gopkg.in/urfave/[email protected]/app.go:490 +0x82
gopkg.in/urfave/cli%2ev1.Command.Run(0x1bde546, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c149fa, 0x45, 0x0, ...)
/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/gopkg.in/urfave/[email protected]/command.go:210 +0x9bb
gopkg.in/urfave/cli%2ev1.(*App).Run(0xc0003e8b60, 0xc000136000, 0x4, 0x4, 0x0, 0x0)
/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/gopkg.in/urfave/[email protected]/app.go:255 +0x768
main.main()
/private/tmp/sops-20210408-88082-6m5hl1/sops-3.7.1/cmd/sops/main.go:987 +0x3885
It's the same when using a float (interface {} is float64, not string
), or when using a JSON instead of a YAML file. I stumbled upon this while trying a sops exec-env
with a Docker .env-file that contains a port setting.
Duplicate of #857.
It works now with sops 3.8.1, closing the issue.
Oops, sorry, when I closed this as completed, I had accidentally tested this with a text string, and not a number. I still get an exception with a numerical value:
$ cat test.yaml
---
key: 234
$ sops --version
sops 3.8.1 (latest)
$ sops -e test.yaml > test_enc.yaml
$ sops -d test_enc.yaml
key: 234
$ sops -d --output-type dotenv test_enc.yaml
panic: interface conversion: interface {} is int, not string
goroutine 1 [running]:
github.com/getsops/sops/v3/stores/dotenv.(*Store).EmitPlainFile(0x140004e2000?, {0x1400000f230?, 0x1?, 0x1?})
github.com/getsops/sops/v3/stores/dotenv/store.go:130 +0x290
main.decrypt({{0x1019b1cb0, 0x140004cf1a0}, {0x10910aa18, 0x1020f8340}, {0x1019b8950, 0x1020f8340}, {0x14000047e50, 0x47}, 0x0, {0x0, ...}, ...})
github.com/getsops/sops/v3/cmd/sops/decrypt.go:52 +0x17c
main.main.func8(0x140000ffb80)
github.com/getsops/sops/v3/cmd/sops/main.go:821 +0x918
github.com/urfave/cli.HandleAction({0x1017c1000?, 0x1019a28f0?}, 0x14000481500?)
github.com/urfave/[email protected]/app.go:524 +0x58
github.com/urfave/cli.(*App).Run(0x14000481500, {0x1400003c0f0, 0x5, 0x5})
github.com/urfave/[email protected]/app.go:286 +0x548
main.main()
github.com/getsops/sops/v3/cmd/sops/main.go:1004 +0x2b28
This is happening still.
Any tracking on this?