sops
sops copied to clipboard
stores/ini - Block style comments fail to decrypt
An ini file with a block style comment such as the one below will fail to decrypt.
;;;;;;;;;;;;;;;;;
; block comment ;
;;;;;;;;;;;;;;;;;
[foo]
foo = 1
Encrypting appears to work fine. However, decrypting yields:
$ sops -d test.sops.ini
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
gopkg.in/ini%2ev1.(*File).writeToBuffer(0xc00001e0b0, 0x0, 0x0, 0x1ba0b20, 0xc00001e101, 0xc00043c3f0)
/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/gopkg.in/[email protected]/file.go:247 +0x1432
gopkg.in/ini%2ev1.(*File).WriteToIndent(0xc00001e0b0, 0x1e11440, 0xc00043c3f0, 0x0, 0x0, 0xc00015c460, 0x0, 0x0)
/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/gopkg.in/[email protected]/file.go:391 +0x45
gopkg.in/ini%2ev1.(*File).WriteTo(...)
/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/gopkg.in/[email protected]/file.go:400
go.mozilla.org/sops/v3/stores/ini.Store.encodeTree(0xc000417980, 0x1, 0x1, 0x0, 0x0, 0xc000417980, 0x1, 0x1)
/private/tmp/sops-20200914-69820-1n7esxf/sops-3.6.1/stores/ini/store.go:62 +0x10a
go.mozilla.org/sops/v3/stores/ini.Store.iniFromTreeBranches(...)
/private/tmp/sops-20200914-69820-1n7esxf/sops-3.6.1/stores/ini/store.go:89
go.mozilla.org/sops/v3/stores/ini.(*Store).EmitPlainFile(0x2428c20, 0xc000417980, 0x1, 0x1, 0x0, 0x1e1de60, 0xc0003a3ef0, 0xc000036540, 0x20)
/private/tmp/sops-20200914-69820-1n7esxf/sops-3.6.1/stores/ini/store.go:307 +0x4a
main.decrypt(0x1e1de60, 0xc0003a3ef0, 0x36ca138, 0x2428c20, 0x36ca138, 0x2428c20, 0xc0000428a0, 0x54, 0x0, 0x0, ...)
/private/tmp/sops-20200914-69820-1n7esxf/sops-3.6.1/cmd/sops/decrypt.go:47 +0x262
main.main.func8(0xc00016cc60, 0x0, 0x0)
/private/tmp/sops-20200914-69820-1n7esxf/sops-3.6.1/cmd/sops/main.go:769 +0x2a05
gopkg.in/urfave/cli%2ev1.HandleAction(0x1acfda0, 0x1cc4470, 0xc00016cc60, 0x0, 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.(*App).Run(0xc000345d40, 0xc0000321b0, 0x3, 0x3, 0x0, 0x0)
/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/gopkg.in/urfave/[email protected]/app.go:264 +0x5f5
main.main()
/private/tmp/sops-20200914-69820-1n7esxf/sops-3.6.1/cmd/sops/main.go:933 +0x3525
I was able to reproduce with something as simple as this:
;;
; comment
[foo]
foo = 1
Seems having the two or more colons followed by a line with another comment triggers it.
I am running into the same issue. Is there a solution for this?