Skip to content

Decrypt with output-type dotenv panics on numbers #879

@andreaswachowski

Description

@andreaswachowski

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/cli.v1@v1.20.0/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/cli.v1@v1.20.0/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/cli.v1@v1.20.0/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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions