lpsmithOP•

I gave a short presentation on this at Hac Phi last Nov, 2015. I did receive some valuable feedback then; and since I've finally gotten around to working on this again, sprucing it up for some of my own projects, I'd love to have some more feedback.

So try it out for something if you'd like, contribute something or just look it over, I'd appreciate a few more eyeballs on this, especially with respect to interface design.

5
sopvop•

That's really awesome! I wanted to move from configurator for some time now, because of same reasons you list. But I really like the syntax and features of configurator, and all other tools seem over complicated and under-specified, like yaml. Or have hard to understand syntax, like TOML dict arrays.

2
Axman6•

We switched from using configurator to configuration-tools because we didn't need the live reloading, greatly preferred the YAML syntax and really loved the tying in with cabal to give lists of all dependencies and their licenses. This is hugely valuable for corporate code which we wish to open source and i'd love to see a lot of these features go back into configurator.

3
lpsmithOP•

Well, in this case, by dependency tracking I mean keeping track of which ConfigParsers depend on which configuration keys, not in terms of cabal packages...

1
mightybyte•

This sounds fantastic and addresses several pain points I have had with configurator! Another thing I've been wanting recently is awareness of sensitive config fields such as passwords. There are two things I would like here. First of all, the actual values of sensitive fields should not be written to any kind of logs. I have found it very useful to write configured values to my system logs so I can easily trace the source of misconfiguration problems. But you often want to make an exception for password fields so you don't leak sensitive deployment credentials to people who shouldn't have them.

Secondly, I find that it's convenient to check config files into source control so deployments can be version controlled and effectively a pure function of the state of the repo. But you probably don't want to have plaintext passwords preserved in git for eternity. One common way of solving this problem is encrypting all your config files and setting up some mechanism to decrypt them on the deployment systems. The downside to this is that it makes updating the config files much more cumbersome. A much nicer solution would be to leverage the aforementioned awareness of sensitive fields to store passwords in encrypted form. This would give us the best of both worlds. Any developer would be able to modify non-sensitive fields with no extra overhead. And people with the proper encryption keys would be able to modify individual passwords in a fairly straightforward way. The config system could even have a mode that could interpret secure fields as plaintext and automatically overwrite them with the encrypted values when requested. If you are using encryption for sensitive fields, then you could also choose to still log the values of those fields since doing so would not expose sensitive information and would regain the debugging convenience.

Would you be interested in putting this sort of thing into configurator-ng?

3
lpsmithOP•

Writing configurations to logs for auditing purposes is actually important for what I do, as I need to be able to ascertain with a high degree of accuracy what happened with any particular event after the fact. So I've implemented the "don't print database passwords to logs" thing in my code; in my case, I've implemented a secondary displayLibpqConnectionString :: [(Name, Value)] -> Text separate from libpqConnectionString :: [(Name, Value)] -> ByteString, with the former replaces the value field with a placeholder for any parameters that start with pass or pw (just in case someone fat-fingers the actual name of the password field).

It wouldn't be too difficult to add a new case for "this is a sensitive and/or encrypted string" to the Value type, and some syntax to the low-level parser. Many of the issues beyond that I think could and perhaps should be punted to client code.

I mean, there's nothing particularly stopping you from storing base-64 encoded encrypted data in your configuration, then decrypting it (or not) in a ConfigParser. Admittedly, it'd be a bit of a pain to manage the config files without a little bit of extra tooling, but it is possible.

So I hear you, it's definitely something to chew on, though I doubt it'll be a very high priority for myself for the time being.

2
mightybyte•

I was also thinking the encryption stuff could be punted to the client, but it relates to the "don't log passwords" issue, so maybe it would be better to put it in configurator-ng itself. Your approach of checking for a prefix of "pass" or "pw" seems kind of fragile and limiting to me. I was thinking about a newtype wrapper that would allow you to choose exactly which fields are encrypted (and also not printed to logs). It seems like this would need to be in the library proper unless you expose some kind of hooks that can be used to control whether a particular field is logged.

Also, I think that this is a pretty common concern in production systems, so it might as well be included.

1
lpsmithOP•

Oh, my solution is very specific to my situation; I'm not proposing it as a general purpose solution. And I'm not necessarily opposed to some kind of feature to mark sensitive data as such; I can see an argument for not completely punting that issue to the client.

Also, configurator allows you to define your own newtype wrappers (via the Configured typeclass), which I'm keeping around and will even be making a bit more powerful. See commit b33ce0 for starters; I also plan on enabling Configured instances to return informative error(s). (and possibly warning(s)?)

But it would seem to me that as far as fragility is concerned, there's always the possibility that the writer of the config might mess up and forget to mark something sensitive as sensitive.

1
mightybyte•

But it would seem to me that as far as fragility is concerned, there's always the possibility that the writer of the config might mess up and forget to mark something sensitive as sensitive.

True, I guess I should have left out the word "fragile" and just stuck with limiting. I want to be able to treat any field as sensitive. I'll see if I can find some time to contribute something like this.

1
lpsmithOP•

Hmm, if you wanted whole-file encryption, and you want it encrypted when it isn't being read by configurator, that's more complicated because of configurator's import functionality.

There would seem to need to be some sort of loading hook to support this; it could be as simple as making calls to System.IO.open a parameter instead of a hard-coded function.

1
mightybyte•

If I can get field-level encryption I don't see myself wanting whole-file encryption.

1
sopvop•

Have you thought about asking bos to pass maintainership of configurator to you and release this as 1.0? AFAIK bos is no longer doing much coding, and breaking API with major release would not be such a huge issue. At least not for me :)

2
lpsmithOP•

That would certainly be a possibliity; though I wouldn't ask until I'm nearly ready for a public release. (And I feel there's still quite a few things that should be dealt with before a public release: you might peek at the TODO I added.)

2
rampion•
2
yitz•

To solve your problem of non-atomic querying of parameters, why not use the simple and obvious solution: change IORef to TVar, and then wrap queries in atomically.

2
lpsmithOP•

Well, that doesn't solve the other issues, and honestly I started with the expressiveness issue first, which also happens to solve the race condition. Also, this is a special case where you don't need the full generality of stm. Also the API would ultimately feel somewhat similar either way.

I have considered switching to TVar to enable consistent reads across multiple ConfigCaches, but I haven't actually thought about that issue in depth yet. (It's pretty far down my priority list.)

1