sops icon indicating copy to clipboard operation
sops copied to clipboard

Add support for properties files

Open jessechahal opened this issue 8 years ago • 13 comments

Properties files are still used heavily in the Jvm world (which means java, scala, and tons of other languages). It would be nice if there was support for encrypting the values within a properties file. Property files are typically much simpler then yaml or json files. Every entry is a key/value pair separated by an = symbol. There are no dictionaries, lists, or any other type of tree structures within a properties file.

I haven't gone through the code base yet but how difficult do people believe it would be to add support for this filetype (and possibly other similar filetypes with different whitespace and seperate rules?)

A good looking project that supports reading and writing of properties file https://github.com/magiconair/properties using golang. It has functions for retrieving all of the keys: https://godoc.org/github.com/magiconair/properties#Properties.Keys Getting the value of a key: https://godoc.org/github.com/magiconair/properties#Properties.Get Setting a value of a key only if the key exists https://godoc.org/github.com/magiconair/properties#Properties.MustSet Forcing that certain keys must exist (good for making sure soaps related keys exist) https://godoc.org/github.com/magiconair/properties#Properties.MustGet

jessechahal avatar Nov 02 '16 17:11 jessechahal

This should be relatively easy to do. Basically all you have to do is comply with this interface. You can see how we do this for json here.

The main difference here is that as you said .properties files don't have maps or sequences, and sops's Metadata is something like a map, and it contains a sequence. For this reason marshaling and unmarshaling Metadata is going to be the most complex part. Otherwise, everything else can be parsed onto a simple TreeBranch, which is just a slice (array) of TreeItems, which are simple key-values.

If you decide to give it a shot, don't hesitate to ping me for questions.

autrilla avatar Nov 02 '16 18:11 autrilla

I haven't looked into golang yet (python and java guy) but this seems like a good place to start looking into it. Any good resources you would suggest I look into regarding golang?

jessechahal avatar Nov 02 '16 18:11 jessechahal

I just used the official tour at https://tour.golang.org/. I don't know of any better resources to learn.

autrilla avatar Nov 02 '16 18:11 autrilla

Is there a contributors guide? I'm already seeing problems with my fork not being able to build binaries even without any changes. Have others forked the golang version and attempted to build and test with it? As someone who has never done golang development before having to figure out things like the dependency management is done with govend (which I only found luckily through some old commit messages) and that the vendor for this project is go.mozilla.org instead of github.com/mozilla makes the project difficult to contribute to even if I was an experienced golang programmer.

jessechahal avatar Nov 05 '16 22:11 jessechahal

I will create a CONTRIBUTING.md on Monday. Sorry for the inconvenience, @jessechahal

autrilla avatar Nov 05 '16 22:11 autrilla

thanks, I'll take a look during the week to see if I can get properties files working. I'll probably just spend a bit of time today learning golang instead.

jessechahal avatar Nov 05 '16 22:11 jessechahal

How's this progressing?

I'm guessing not at all at the moment :(

magthe avatar Apr 18 '18 16:04 magthe

Yeah, this isn't really progressing. Part of it is on me for not writing the contribution guide (#170). I'll see if I can get around to doing that eventually...

autrilla avatar Apr 18 '18 16:04 autrilla

As the maintainers of Sops, the open source project, we try to support contributors who want specific features as much as possible, but as engineers with busy schedules, we only implement the features we directly need. That is to say, it's unlikely we'll implement this ourselves, as we don't use property files, but we'd be happy to help someone do it.

jvehent avatar Apr 18 '18 19:04 jvehent

Guess there's no update on this? Would really help our organization, as all our applications use .properties files.

andreas-bradahl avatar Jan 08 '21 07:01 andreas-bradahl

There's no update. If it's useful to your organization, maybe they can contribute the time to implement it?

autrilla avatar Jan 08 '21 09:01 autrilla

we also need .properties file support. But actually I saw that if you add .env suffix to sops, then it encrypt properties files well (instead of raw text it encrypt it by property. So i think its quite enough. Thoughts?

shay-berman avatar Jan 23 '22 21:01 shay-berman

+1, maybe it can use https://pkg.go.dev/github.com/magiconair/properties ?

rmannibucau avatar Jan 09 '24 19:01 rmannibucau