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

Decrypt with output-type dotenv panics on numbers #879

Open
andreaswachowski opened this issue May 31, 2021 · 4 comments
Open

Decrypt with output-type dotenv panics on numbers #879

andreaswachowski opened this issue May 31, 2021 · 4 comments

Comments

@andreaswachowski
Copy link

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.

@joshdk
Copy link

joshdk commented Jul 22, 2021

Duplicate of #857.

@andreaswachowski
Copy link
Author

It works now with sops 3.8.1, closing the issue.

@andreaswachowski
Copy link
Author

andreaswachowski commented Jan 28, 2024

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

@ekwoka
Copy link

ekwoka commented Mar 25, 2024

This is happening still.

Any tracking on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment