4 ms·
This isn't an argument for putting a Turing-complete language in your config file parser. It's an argument for documenting your config file format so your users
by motogpjimbo 6y ago
This isn't an argument for putting a Turing-complete language in your config file parser. It's an argument for documenting your config file format so your users can write scripts (in a language of their choice) to generate config files programmatically.
It seems cute to do it this way, but now you have to start talking about removing certain functions from the standard library, running the script in a sandbox, etc.
- soapdog 6y agoLua has features to do just that. It is fairly easy for an app to load a protected environment around Lua source code and only expose what you need. You can clamp all forms of filesystem and hardware access and leave the user with only the functions you provide and the language itself.
- csharptwdec19 6y agoI've been working with Lua on a project and have found this to be a really neat concept. When you set up the runtime in your language most libraries make it trivial to define that a given function can call into your own code, i.e. I could define 'getUser' in my lua code to call back to a C# function with variables, etc...
- joppy 6y agoWhat is your opinion on config files used by the Bazel build system, written in a programming language called Skylark [1] (much like Python)? I haven't looked into it but it seems plausibly Turing-complete, or at least powerful enough to cause problems in the same way a Turing-complete language would. [1]: https://docs.bazel.build/versions/3.3.0/skylark/language.html https://docs.bazel.build/versions/3.3.0/skylark/language.htm...
- kstenerud 6y agoIt's fine if you don't consider the config files a threat vector.
- laurentlb 6y agoFor the record, Starlark has some restrictions: no infinite loops, no access to the world, etc. It's true that computations could be arbitrary long (as with most other languages). Bazel has a flag to reduce this kind of problem (--max_computation_steps).
- mirekrusin 6y agoOr use jsonnet or something like that.