Does liquid prevent include filenames from traversing directories?
Does liquid somehow prevent users from doing this:
{% include '../../header' %}
Also, is it possible to analyze a template to see how many if statements, loops, tag usages, etc the template contains?
There is some protection against directory traversal - see the local file system code
Also, is it possible to analyze a template to see how many if statements, loops, tag usages, etc the template contains?
You can traverse the AST starting from Liquid::Template#root, but this API is not guaranteed to remain stable between major Liquid versions. If you are trying to prevent excessive resource use, it's better to set Liquid::Template.default_resource_limits or Liquid::Template#resource_limits. It needs better documentation, but this is essentially how it should be used: https://github.com/Shopify/liquid/blob/2b3c81cfd05ef23869d88cde03faafa1d393ac5b/test/integration/template_test.rb#L104-L140
This is what Shopify does to safely run customer Liquid in production.
thanks!