fix(misconf): escape all special sequences #7557
Labels
kind/bug
Categorizes issue or PR as related to a bug.
scan/misconfiguration
Issues relating to misconfiguration scanning
Milestone
Character escaping must be handled correctly
Discussed in #7555
Originally posted by armas-mk September 19, 2024
Description
Trivy crashes during config scanning a terraform plan if a .tftpl template file with grok pattern is rendered via the
templatefile()
built-in function in Terraform.Desired Behavior
trivy shouldn't try to process keywords escaped with %%. The templatefile syntax is correct and terraform validate reports no problem and can deploy with terraform with template rendered into desired output.
Actual Behavior
When templatefile has grok_pattern: '%%{TIMESTAMP_ISO8601:time} [%%{NUMBER:pid}] %%{GREEDYDATA:message}'
trivy throws
ERROR [terraform parser] Error parsing file module="root" file_path="main.tf" err="main.tf:604,63-69: Invalid template control keyword; \"NUMBER\" is not a valid template control keyword."
Reproduction Steps
1. Place a valid grok pattern in a terraform template file with proper %% escaping 2. run trivy config on the tfplan that has the rendered template
Target
None
Scanner
Misconfiguration
Output Format
Table
Mode
Standalone
Debug Output
Operating System
Ubuntu 22.04.4 LTS
Version
Checklist
trivy clean --all
The text was updated successfully, but these errors were encountered: