opened
chrisvanbreeden
username_0
Added rule: check that jinja template files have the correct extension
issue
created
jbouter
username_1
When using `file.recursive`, one might have jinja templates in there that can't be renamed to have the `.j2` extension, because then they'll have that extension on filesystem.

For example:

```code
nginx_vhosts:
  file.recursive:
    - name: /etc/nginx/sites-enabled/
    - source: salt://nginx/vhosts
    [..]
```

If `/nginx/vhosts/` is filled with `vhost.conf.j2` files, they will be put on the server's filesystem as `vhost.conf.j2` files.
comment
created
jbouter
username_1
First of all, thank you for your contribution!

We are, however, sadly closing this pull request due to the following reasons:

* We should only be linting SaltStack files, meaning only lint files ending in `.sls`. We don't want our users to lint all of their files, scanning for possible jinja.
* We can't rule out false positives as stated in the comment above.

I suggest this PR is rewritten to do the following:

* Check **only** `.sls` files
* Check if `file.managed` is being used
* If so, check if `- template: jinja` is set
* If these conditions match, check if a `- source: ` is set
* Check if the file path in `- source:` ends with `.j2`

If you do wish however to use this code, you can use `-r` option to specify your own set of rules in your own SaltStack linting pipeline. But we won't be merging this into the codebase.
comment