warpnet / salt-lint

A command-line utility that checks for best practices in SaltStack.
https://salt-lint.readthedocs.io/en/latest/
MIT License
152 stars 39 forks source link

False positive for Jinja variables regex (test provided + failing CI output) #283

Open myii opened 2 years ago

myii commented 2 years ago

Describe the bug

Encountered a false positive for the Jinja variables check, based on this block:

  file.blockreplace:
    - ...
    - content: |
           DKIM_DOMAIN = ${lc:${domain:$h_from:}}
           DKIM_KEY_FILE = /etc/exim4/dkim/{{ pillar['dkim_private_key'] }}
           DKIM_PRIVATE_KEY = ${if exists{DKIM_KEY_FILE}{DKIM_KEY_FILE}{0}}
           DKIM_SELECTOR = {{ pillar['dkim_selector'] }}

With the error being:

[206] Jinja variables should have spaces before and after: '{{ var_name }}'
.../init.sls:71
           DKIM_DOMAIN = ${lc:${domain:$h_from:}}

To Reproduce

I've provided a failing test here:

As I've mentioned there, it fails within quotes as well:

    - content: 'DKIM_DOMAIN = ${lc:${domain:$h_from:}}'

Here's the failure in GitHub Actions based on that commit:

Note, there's also another commit there, which adjusts the CI so that the yamllint error is resolved and the CI doesn't fail fast (so that all instance failures can be seen):

Let me know if you'd like that in a PR here.

Expected behavior

The regex shouldn't catch this as a failure.